Skip to content

Commit

Permalink
Add Karpenter Azure provider with machine controllers enabled only
Browse files Browse the repository at this point in the history
  • Loading branch information
Fei-Guo committed Aug 8, 2023
1 parent 587f881 commit c131622
Show file tree
Hide file tree
Showing 7,304 changed files with 2,789,995 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
16 changes: 16 additions & 0 deletions ADOPTERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Who is using Karpenter?
Karpenter has a variety of users and use cases for scaling Kubernetes.
Many customers want to learn from others who have already implemented Karpenter in their environments.

The following is a self-reported list of users to help identify adoption and points of contact.

## Community
If you would like to ask question from the community please join the [Karpenter slack channel in the Kubernetes Slack](https://kubernetes.slack.com/archives/C02SFFZSA2K) or join the [Karpenter working group](https://karpenter.sh/docs/contributing/working-group/) bi-weekly calls.

## Add yourself
Please add yourself if you or your organization is leveraging azure karpenter!
## Adopters (Alphabetical)

| Organization | Description | Contacts | Link |
| --- | --- | --- | --- |
| Microsoft | Scaling production workloads and batch jobs in all Azure Workloads | `@Alex Leites`, `@Bryce-Soghigian`, `@Charlie McBride` | [Introducing Karpenter](TBD)
4 changes: 4 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Require approvals from someone in the owner team before merging
# More information here: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

* @aws/karpenter
9 changes: 9 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Code of Conduct
The Karpenter project follows the [CNCF Community Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md)
and the Microsoft Code of Conduct [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).

Resources:

- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [[email protected]](mailto:[email protected]) with questions or concerns
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
211 changes: 211 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
include Makefile-az.mk

export K8S_VERSION ?= 1.27.x
export KUBEBUILDER_ASSETS ?= ${HOME}/.kubebuilder/bin
CLUSTER_NAME ?= $(shell kubectl config view --minify -o jsonpath='{.clusters[].name}' | rev | cut -d"/" -f1 | rev | cut -d"." -f1)

## Inject the app version into project.Version
ifdef SNAPSHOT_TAG
LDFLAGS ?= -ldflags=-X=github.com/aws/karpenter/pkg/utils/project.Version=$(SNAPSHOT_TAG)
else
LDFLAGS ?= -ldflags=-X=github.com/aws/karpenter/pkg/utils/project.Version=$(shell git describe --tags --always)
endif

GOFLAGS ?= $(LDFLAGS)
WITH_GOFLAGS = GOFLAGS="$(GOFLAGS)"

## Extra helm options
CLUSTER_ENDPOINT ?= $(shell kubectl config view --minify -o jsonpath='{.clusters[].cluster.server}')
AWS_ACCOUNT_ID ?= $(shell aws sts get-caller-identity --query Account --output text)
KARPENTER_IAM_ROLE_ARN ?= arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-karpenter
HELM_OPTS ?= --set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=${KARPENTER_IAM_ROLE_ARN} \
--set settings.aws.clusterName=${CLUSTER_NAME} \
--set settings.aws.clusterEndpoint=${CLUSTER_ENDPOINT} \
--set settings.featureGates.driftEnabled=true \
--set controller.resources.requests.cpu=1 \
--set controller.resources.requests.memory=1Gi \
--set controller.resources.limits.cpu=1 \
--set controller.resources.limits.memory=1Gi \
--create-namespace

# CR for local builds of Karpenter
SYSTEM_NAMESPACE ?= karpenter
KARPENTER_VERSION ?= $(shell git tag --sort=committerdate | tail -1)
KO_DOCKER_REPO ?= ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/karpenter
GETTING_STARTED_SCRIPT_DIR = website/content/en/preview/getting-started/getting-started-with-karpenter/scripts

# TEST_SUITE enables you to select a specific test suite directory to run "make e2etests" or "make test" against
TEST_SUITE ?= "..."
TEST_TIMEOUT ?= "3h"

# Common Directories
# TODO: revisit testing tools (temporarily excluded here, for make verify)
MOD_DIRS = $(shell find . -name go.mod -type f ! -path "./test/*" | xargs dirname)
KARPENTER_CORE_DIR = $(shell go list -m -f '{{ .Dir }}' github.com/aws/karpenter-core)

# TEST_SUITE enables you to select a specific test suite directory to run "make e2etests" or "make test" against
TEST_SUITE ?= "..."
TEST_TIMEOUT ?= "3h"

help: ## Display help
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

presubmit: verify test ## Run all steps in the developer loop

ci-test: battletest coverage ## Runs tests and submits coverage

ci-non-test: verify licenses vulncheck ## Runs checks other than tests

run: ## Run Karpenter controller binary against your local cluster
kubectl create configmap -n ${SYSTEM_NAMESPACE} karpenter-global-settings \
--from-literal=aws.clusterName=${CLUSTER_NAME} \
--from-literal=aws.clusterEndpoint=${CLUSTER_ENDPOINT} \
--from-literal=aws.defaultInstanceProfile=KarpenterNodeInstanceProfile-${CLUSTER_NAME} \
--from-literal=aws.interruptionQueueName=${CLUSTER_NAME} \
--from-literal=featureGates.driftEnabled=true \
--dry-run=client -o yaml | kubectl apply -f -


SYSTEM_NAMESPACE=${SYSTEM_NAMESPACE} KUBERNETES_MIN_VERSION="1.19.0-0" LEADER_ELECT=false DISABLE_WEBHOOK=true \
go run ./cmd/controller/main.go

clean-run: ## Clean resources deployed by the run target
kubectl delete configmap -n ${SYSTEM_NAMESPACE} karpenter-global-settings --ignore-not-found

test: ## Run tests
ginkgo -v --focus="${FOCUS}" ./pkg/$(shell echo $(TEST_SUITE) | tr A-Z a-z)

battletest: ## Run randomized, racing, code-covered tests
ginkgo -v \
-race \
-cover -coverprofile=coverage.out -output-dir=. -coverpkg=./pkg/... \
--focus="${FOCUS}" \
--randomize-all \
-tags random_test_delay \
./pkg/...

e2etests: ## Run the e2e suite against your local cluster
cd test && CLUSTER_NAME=${CLUSTER_NAME} go test \
-p 1 \
-count 1 \
-timeout ${TEST_TIMEOUT} \
-v \
./suites/$(shell echo $(TEST_SUITE) | tr A-Z a-z)/... \
--ginkgo.focus="${FOCUS}" \
--ginkgo.timeout=${TEST_TIMEOUT} \
--ginkgo.grace-period=3m \
--ginkgo.vv

benchmark:
go test -tags=test_performance -run=NoTests -bench=. ./...

deflake: ## Run randomized, racing, code-covered tests to deflake failures
for i in $(shell seq 1 5); do make battletest || exit 1; done

deflake-until-it-fails: ## Run randomized, racing tests until the test fails to catch flakes
ginkgo \
--race \
--focus="${FOCUS}" \
--randomize-all \
--until-it-fails \
-v \
./pkg/...

coverage:
go tool cover -html coverage.out -o coverage.html

verify: tidy download ## Verify code. Includes dependencies, linting, formatting, etc
go generate ./...
hack/boilerplate.sh
cp $(KARPENTER_CORE_DIR)/pkg/apis/crds/* pkg/apis/crds
yq -i '(.spec.versions[0].additionalPrinterColumns[] | select (.name=="Zone")) .jsonPath=".metadata.labels.karpenter\.k8s\.azure/zone"' \
pkg/apis/crds/karpenter.sh_machines.yaml
$(foreach dir,$(MOD_DIRS),cd $(dir) && golangci-lint run $(newline))
@git diff --quiet ||\
{ echo "New file modification detected in the Git working tree. Please check in before commit."; git --no-pager diff --name-only | uniq | awk '{print " - " $$0}'; \
if [ "${CI}" = true ]; then\
exit 1;\
fi;}
# TODO: restore codegen if needed; decide on the future of docgen
#@echo "Validating codegen/docgen build scripts..."
#@find hack/code hack/docs -name "*.go" -type f -print0 | xargs -0 -I {} go build -o /dev/null {}

vulncheck: ## Verify code vulnerabilities
@govulncheck ./pkg/...

licenses: download ## Verifies dependency licenses
! go-licenses csv ./... | grep -v -e 'MIT' -e 'Apache-2.0' -e 'BSD-3-Clause' -e 'BSD-2-Clause' -e 'ISC' -e 'MPL-2.0'

setup: ## Sets up the IAM roles needed prior to deploying the karpenter-controller. This command only needs to be run once
CLUSTER_NAME=${CLUSTER_NAME} ./$(GETTING_STARTED_SCRIPT_DIR)/add-roles.sh $(KARPENTER_VERSION)

build: ## Build the Karpenter controller images using ko build
$(eval CONTROLLER_IMG=$(shell $(WITH_GOFLAGS) KO_DOCKER_REPO="$(KO_DOCKER_REPO)" ko build -B github.com/aws/karpenter/cmd/controller))
$(eval IMG_REPOSITORY=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 1 | cut -d ":" -f 1))
$(eval IMG_TAG=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 1 | cut -d ":" -f 2 -s))
$(eval IMG_DIGEST=$(shell echo $(CONTROLLER_IMG) | cut -d "@" -f 2))

apply: build ## Deploy the controller from the current state of your git repository into your ~/.kube/config cluster
helm upgrade --install karpenter charts/karpenter --namespace ${SYSTEM_NAMESPACE} \
$(HELM_OPTS) \
--set controller.image.repository=$(IMG_REPOSITORY) \
--set controller.image.tag=$(IMG_TAG) \
--set controller.image.digest=$(IMG_DIGEST)

install: ## Deploy the latest released version into your ~/.kube/config cluster
@echo Upgrading to ${KARPENTER_VERSION}
helm upgrade --install karpenter oci://public.ecr.aws/karpenter/karpenter --version ${KARPENTER_VERSION} --namespace ${SYSTEM_NAMESPACE} \
$(HELM_OPTS)

delete: ## Delete the controller from your ~/.kube/config cluster
helm uninstall karpenter --namespace karpenter

docgen: ## Generate docs
go run hack/docs/metrics_gen_docs.go pkg/ $(KARPENTER_CORE_DIR)/pkg website/content/en/preview/concepts/metrics.md
go run hack/docs/instancetypes_gen_docs.go website/content/en/preview/concepts/instance-types.md
go run hack/docs/configuration_gen_docs.go website/content/en/preview/concepts/settings.md
cd charts/karpenter && helm-docs

codegen: ## Auto generate files based on AWS APIs response
$(WITH_GOFLAGS) ./hack/codegen.sh

stable-release-pr: ## Generate PR for stable release
$(WITH_GOFLAGS) ./hack/release/stable-pr.sh

release: ## Builds and publishes stable release if env var RELEASE_VERSION is set, or a snapshot release otherwise
$(WITH_GOFLAGS) ./hack/release/release.sh

release-crd: ## Packages and publishes a karpenter-crd helm chart
$(WITH_GOFLAGS) ./hack/release/release-crd.sh

prepare-website: ## prepare the website for release
./hack/release/prepare-website.sh

toolchain: ## Install developer toolchain
./hack/toolchain.sh

issues: ## Run GitHub issue analysis scripts
pip install -r ./hack/github/requirements.txt
@echo "Set GH_TOKEN env variable to avoid being rate limited by Github"
./hack/github/feature_request_reactions.py > "karpenter-feature-requests-$(shell date +"%Y-%m-%d").csv"
./hack/github/label_issue_count.py > "karpenter-labels-$(shell date +"%Y-%m-%d").csv"

website: ## Serve the docs website locally
cd website && npm install && git submodule update --init --recursive && hugo server

tidy: ## Recursively "go mod tidy" on all directories where go.mod exists
$(foreach dir,$(MOD_DIRS),cd $(dir) && go mod tidy $(newline))

download: ## Recursively "go mod download" on all directories where go.mod exists
$(foreach dir,$(MOD_DIRS),cd $(dir) && go mod download $(newline))

update-core: ## Update karpenter-core to latest
go get -u github.com/aws/karpenter-core@HEAD
go mod tidy

.PHONY: help dev ci release test battletest e2etests verify tidy download docgen codegen apply delete toolchain licenses vulncheck issues website nightly snapshot

define newline


endef
Loading

0 comments on commit c131622

Please sign in to comment.