From d315308c069dfd36da16a8bdd0c69f007eb73a46 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 12 Aug 2020 10:08:15 -0700 Subject: [PATCH 01/14] update dependencies info for building project --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa1cd689c322..bdf8f094ead0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ Karpenter is a Cluster Autoscaling solution optimized for AWS and compatible wit ![](./docs/logo.jpeg) # Usage ## Dependencies -TODO + +To build Karpenter from source, please first install the following: + +1. [go v1.14.4+](https://golang.org/dl/) +2. [kubebuilder dependencies]([dependencies](https://book.kubebuilder.io/quick-start.html#prerequisites) +3. [kubebuilder](https://book.kubebuilder.io/quick-start.html#installation) + ## Install -TODO \ No newline at end of file +TODO From 3605cf9590c292b14187fc16c2e3ed3dd0d1d704 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Thu, 13 Aug 2020 19:54:39 -0700 Subject: [PATCH 02/14] correct bad markdown --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bdf8f094ead0..13bc8445509d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Karpenter is a Cluster Autoscaling solution optimized for AWS and compatible wit To build Karpenter from source, please first install the following: 1. [go v1.14.4+](https://golang.org/dl/) -2. [kubebuilder dependencies]([dependencies](https://book.kubebuilder.io/quick-start.html#prerequisites) +2. [kubebuilder dependencies](https://book.kubebuilder.io/quick-start.html#prerequisites) 3. [kubebuilder](https://book.kubebuilder.io/quick-start.html#installation) ## Install From ae4d2325bf6e422fcf5941e1c0386202eea45de8 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Thu, 13 Aug 2020 21:58:48 -0700 Subject: [PATCH 03/14] auto-download controller-gen if missing copied from boilerplate Makefile that kubebuilder creates --- Makefile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index efb7246ba7d8..a8195513a9be 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ undeploy: manifests kustomize build config/default | kubectl delete -f - # Generate manifests e.g. CRD, RBAC etc. -manifests: +manifests: controller-gen controller-gen $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases # Run go fmt against code @@ -54,7 +54,7 @@ vet: go vet ./... # Generate code -generate: +generate: controller-gen controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." # Build the docker image @@ -66,3 +66,20 @@ docker-push: docker push ${IMG} docker-release: docker-build docker-push + +# find or download controller-gen +# download controller-gen if necessary +controller-gen: +ifeq (, $(shell which controller-gen)) + @{ \ + set -e ;\ + CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ + cd $$CONTROLLER_GEN_TMP_DIR ;\ + go mod init tmp ;\ + go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\ + rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ + } +CONTROLLER_GEN=$(GOBIN)/controller-gen +else +CONTROLLER_GEN=$(shell which controller-gen) +endif From 41e269c43dfa551ccf0f3f0b4cf82319ead809cd Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Thu, 13 Aug 2020 22:18:25 -0700 Subject: [PATCH 04/14] fix Dockerfile for when under VPN this might not be the right long-term solution --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ed3693c302a1..33c358cc7c80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,11 @@ COPY go.mod go.mod COPY go.sum go.sum # Build src -RUN go mod download +RUN GOPROXY=direct go mod download RUN go build -o karpenter ./cmd # Copy to slim image FROM gcr.io/distroless/static:latest WORKDIR / COPY --from=builder /go/src/github.com/ellistarn/karpenter . -ENTRYPOINT ["/karpenter"] \ No newline at end of file +ENTRYPOINT ["/karpenter"] From 680bccafcd503fbb86b15787bc02c85cf6b3fb26 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Thu, 13 Aug 2020 22:22:58 -0700 Subject: [PATCH 05/14] Add a little more info on building --- README.md | 7 ++++++- go.sum | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 13bc8445509d..7d7557ef9d1a 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,9 @@ To build Karpenter from source, please first install the following: 3. [kubebuilder](https://book.kubebuilder.io/quick-start.html#installation) ## Install -TODO + +After installing the dependencies from the previous section, build the software: + +```bash +make +``` diff --git a/go.sum b/go.sum index 5ed5ac5885b5..6ca3853ed4e5 100644 --- a/go.sum +++ b/go.sum @@ -123,6 +123,7 @@ github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+ github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobuffalo/flect v0.2.0/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= @@ -210,7 +211,9 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -238,6 +241,7 @@ github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= @@ -364,6 +368,7 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -448,22 +453,30 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20190905181640-827449938966/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= k8s.io/api v0.18.4 h1:8x49nBRxuXGUlDlwlWd3RMY1SayZrzFfxea3UZSkFw4= k8s.io/api v0.18.4/go.mod h1:lOIQAKYgai1+vz9J7YcDZwC26Z0zQewYOGWdyIPUUQ4= +k8s.io/apiextensions-apiserver v0.18.2/go.mod h1:q3faSnRGmYimiocj6cHQ1I3WpLqmDgJFlKL37fC4ZvY= k8s.io/apiextensions-apiserver v0.18.4 h1:Y3HGERmS8t9u12YNUFoOISqefaoGRuTc43AYCLzWmWE= k8s.io/apiextensions-apiserver v0.18.4/go.mod h1:NYeyeYq4SIpFlPxSAB6jHPIdvu3hL0pc36wuRChybio= +k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= k8s.io/apimachinery v0.18.4 h1:ST2beySjhqwJoIFk6p7Hp5v5O0hYY6Gngq/gUYXTPIA= k8s.io/apimachinery v0.18.4/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko= k8s.io/apimachinery v0.18.6 h1:RtFHnfGNfd1N0LeSrKCUznz5xtUP1elRGvHJbL3Ntag= k8s.io/apimachinery v0.18.6/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko= +k8s.io/apiserver v0.18.2/go.mod h1:Xbh066NqrZO8cbsoenCwyDJ1OSi8Ag8I2lezeHxzwzw= k8s.io/apiserver v0.18.4/go.mod h1:q+zoFct5ABNnYkGIaGQ3bcbUNdmPyOCoEBcg51LChY8= +k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU= k8s.io/client-go v0.18.4 h1:un55V1Q/B3JO3A76eS0kUSywgGK/WR3BQ8fHQjNa6Zc= k8s.io/client-go v0.18.4/go.mod h1:f5sXwL4yAZRkAtzOxRWUhA/N8XzGCb+nPZI8PfobZ9g= +k8s.io/code-generator v0.18.2/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= k8s.io/code-generator v0.18.4/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c= +k8s.io/component-base v0.18.2/go.mod h1:kqLlMuhJNHQ9lz8Z7V5bxUUtjFZnrypArGl58gmDfUM= k8s.io/component-base v0.18.4/go.mod h1:7jr/Ef5PGmKwQhyAz/pjByxJbC58mhKAhiaDu0vXfPk= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= @@ -473,6 +486,7 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0 h1:Foj74zO6RbjjP4hBEKjnYtjjAhGg4jNynUdYF6fJrok= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= +k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 h1:Oh3Mzx5pJ+yIumsAD0MOECPVeXsVot0UkiaCGVyfGQY= k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU= @@ -482,6 +496,8 @@ k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7/go.mod h1:PHgbrJT7lCHcxMU+mDHEm+nx46H4zuuHZkDP6icnhu0= sigs.k8s.io/controller-runtime v0.6.1 h1:LcK2+nk0kmaOnKGN+vBcWHqY5WDJNJNB/c5pW+sU8fc= sigs.k8s.io/controller-runtime v0.6.1/go.mod h1:XRYBPdbf5XJu9kpS84VJiZ7h/u1hF3gEORz0efEja7A= +sigs.k8s.io/controller-tools v0.3.0 h1:y3YD99XOyWaXkiF1kd41uRvfp/64teWcrEZFuHxPhJ4= +sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI= sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/structured-merge-diff/v3 v3.0.0 h1:dOmIZBMfhcHS09XZkMyUgkq5trg3/jRyJYFZUiaOp8E= sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= From 92ffda6c40095c587dcd1f4540f40fae5deefdcb Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Thu, 13 Aug 2020 22:37:42 -0700 Subject: [PATCH 06/14] More info about how to build/deploy --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 7d7557ef9d1a..7adb48e945a3 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,36 @@ After installing the dependencies from the previous section, build the software: ```bash make ``` + +## Setting up Container Repository + +### Using AWS ECR + +If you plan on using the AWS ECR and haven't yet set it up, you will want to do something like the following (which come from [these instructions](https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html) + +```bash +# Replace the values in the following 2 lines: +AWS_ACCOUNT_ID=fillThisIn +AWS_REGION=us-west-2 +aws ecr get-login-password --region $AWS_ACCOUNT_ID | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com +aws ecr create-repository --repository-name karpenter --image-scanning-configuration scanOnPush=true --region ${AWS_REGION} +``` + +You will then want to add the following to your shell's init script: + +```bash +export KO_DOCKER_REPO=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com +``` +## Build and Push Docker Image + +Make sure you have set `KO_DOCKER_REPO` before running the following commands: + +```bash +make docker-build && make docker-push +``` + +If the above works, then you can deploy to your Kubernetes cluster: + +```bash +make deploy +``` From 80881787818d80506400dde2f026faf83d87a811 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 09:51:53 -0700 Subject: [PATCH 07/14] initial version of AWS specific steps for developers --- docs/AWS_DEVELOPER_GUIDE.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/AWS_DEVELOPER_GUIDE.md diff --git a/docs/AWS_DEVELOPER_GUIDE.md b/docs/AWS_DEVELOPER_GUIDE.md new file mode 100644 index 000000000000..2e91b0b35b80 --- /dev/null +++ b/docs/AWS_DEVELOPER_GUIDE.md @@ -0,0 +1,25 @@ +# AWS Developer Guide + +This file walks through any steps needed when developing Karpenter using AWS services. + +## Set up EKS Cluster + +_TODO_ + +## Set up ECR + +If you plan on using the AWS ECR and haven't yet set it up, you will want to do something like the following (which come from [these instructions](https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html) + +```bash +# Replace the values in the following 2 lines: +AWS_ACCOUNT_ID=my-account-id +AWS_REGION=region +aws ecr get-login-password --region $AWS_ACCOUNT_ID | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com +aws ecr create-repository --repository-name karpenter --image-scanning-configuration scanOnPush=true --region ${AWS_REGION} +``` + +You will then want to add the following to your shell's init script: + +```bash +export KO_DOCKER_REPO=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com +``` From f660d03abacba1df36468827ef21ad5c8267e4f9 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 10:01:35 -0700 Subject: [PATCH 08/14] address some comments from pull request https://github.com/ellistarn/karpenter/pull/2 --- README.md | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/README.md b/README.md index 7adb48e945a3..9730bf6176c6 100644 --- a/README.md +++ b/README.md @@ -19,31 +19,12 @@ After installing the dependencies from the previous section, build the software: make ``` -## Setting up Container Repository - -### Using AWS ECR - -If you plan on using the AWS ECR and haven't yet set it up, you will want to do something like the following (which come from [these instructions](https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html) - -```bash -# Replace the values in the following 2 lines: -AWS_ACCOUNT_ID=fillThisIn -AWS_REGION=us-west-2 -aws ecr get-login-password --region $AWS_ACCOUNT_ID | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com -aws ecr create-repository --repository-name karpenter --image-scanning-configuration scanOnPush=true --region ${AWS_REGION} -``` - -You will then want to add the following to your shell's init script: - -```bash -export KO_DOCKER_REPO=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com -``` ## Build and Push Docker Image Make sure you have set `KO_DOCKER_REPO` before running the following commands: ```bash -make docker-build && make docker-push +make docker-release ``` If the above works, then you can deploy to your Kubernetes cluster: From a873846e1ca5215b60f68eda41e5d5528279f18c Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 10:02:11 -0700 Subject: [PATCH 09/14] address comments from pull request https://github.com/ellistarn/karpenter/pull/2 --- config/crd/bases/karpenter.sh_horizontalautoscalers.yaml | 4 ++-- config/manager/kustomization.yaml | 2 +- pkg/api/v1alpha1/horizontalautoscaler.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml b/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml index 9ed869041ee5..af961ca71d8e 100644 --- a/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml +++ b/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml @@ -36,7 +36,7 @@ spec: description: HorizontalAutoscalerSpec is modeled after https://godoc.org/k8s.io/api/autoscaling/v2beta2#HorizontalPodAutoscalerSpec This enables parity of functionality between Pod and Node autoscaling, with a few minor differences. 1. ObjectSelector is replaced by NodeSelector. - 2. Metrics.PodsMetricSelector is replaced by the more generic ReplicaMetricSelector. + 2. Metrics.PodsMetricSelector is replaced by the more generic Metrics.ReplicaMetricSelector. properties: behavior: description: Behavior configures the scaling behavior of the target @@ -573,7 +573,7 @@ spec: type: string description: NodeLabelSelector identifies Nodes, which in turn identify NodeGroups controlled by this scale policy. NodeGroup and Provider - are identified from node.providerId and node.metadata.labels["NGName"]. + are identified from node.providerId and node.metadata.labels["k8s.amazonaws.com/node-group"]=node-group-arn. type: object required: - maxReplicas diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index a68999f7a779..017f8cab80cb 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,7 +4,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: 767520670908.dkr.ecr.us-west-2.amazonaws.com/karpenter + newName: 741206201142.dkr.ecr.us-west-2.amazonaws.com/karpenter newTag: latest - name: karpenter newName: controller diff --git a/pkg/api/v1alpha1/horizontalautoscaler.go b/pkg/api/v1alpha1/horizontalautoscaler.go index 5570b45a9118..98ab53c24e19 100644 --- a/pkg/api/v1alpha1/horizontalautoscaler.go +++ b/pkg/api/v1alpha1/horizontalautoscaler.go @@ -59,14 +59,14 @@ type HorizontalAutoscalerSpec struct { // HorizontalAutoscalerBehavior configures the scaling behavior of the target // in both Up and Down directions (scaleUp and scaleDown fields respectively). type HorizontalAutoscalerBehavior struct { - // scaleUp is scaling policy for scaling Up. + // ScaleUp is scaling policy for scaling Up. // If not set, the default value is the higher of: // * increase no more than 4 replicas per 60 seconds // * double the number of replicas per 60 seconds // No stabilization is used. // +optional ScaleUp *ScalingRules `json:"scaleUp,omitempty"` - // scaleDown is scaling policy for scaling Down. + // ScaleDown is scaling policy for scaling Down. // If not set, the default value is to allow to scale down to minReplicas, with a // 300 second stabilization window (i.e., the highest recommendation for // the last 300sec is used). From b8cd36e8bdcf7db4fc016b0eca100f0765ec65ac Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 12:04:55 -0700 Subject: [PATCH 10/14] initial cut at doc for contributors to get started right now just has info on how to get the dependencies for building --- CONTRIBUTING.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e69de29bb2d1..dafc3bd60950 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -0,0 +1,12 @@ +To build Karpenter from source, please first install the following: + +1. [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) +2. [kustomize](https://kubernetes-sigs.github.io/kustomize/installation/) +3. [controller-gen](https://book.kubebuilder.io/reference/controller-gen.html); to install it you can do: + + CONTROLLER_GEN_TMP_DIR=$(mktemp -d) + cd $CONTROLLER_GEN_TMP_DIR + go mod init tmp + go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 + rm -rf $CONTROLLER_GEN_TMP_DIR + From 55cfe8b1ce030d0c507aaadc1255f3a2542ac5db Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 12:08:27 -0700 Subject: [PATCH 11/14] more some more build related instructions to contributor doc --- CONTRIBUTING.md | 5 +++++ README.md | 13 +------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dafc3bd60950..cd063e927c69 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,3 +10,8 @@ To build Karpenter from source, please first install the following: go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 rm -rf $CONTROLLER_GEN_TMP_DIR +After installing the dependencies from the previous section, as well as those in the [README](README.md), you should be able to build the software: + +```bash +make +``` diff --git a/README.md b/README.md index 9730bf6176c6..eb414584ef24 100644 --- a/README.md +++ b/README.md @@ -5,22 +5,11 @@ Karpenter is a Cluster Autoscaling solution optimized for AWS and compatible wit # Usage ## Dependencies -To build Karpenter from source, please first install the following: - 1. [go v1.14.4+](https://golang.org/dl/) -2. [kubebuilder dependencies](https://book.kubebuilder.io/quick-start.html#prerequisites) -3. [kubebuilder](https://book.kubebuilder.io/quick-start.html#installation) +2. [docker](https://docs.docker.com/install/) ## Install -After installing the dependencies from the previous section, build the software: - -```bash -make -``` - -## Build and Push Docker Image - Make sure you have set `KO_DOCKER_REPO` before running the following commands: ```bash From f8aeb4b420e333cc886da3c0b23d04c41c98b221 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 12:09:57 -0700 Subject: [PATCH 12/14] remove controller-gen downloading instead document how to get it in project docs --- Makefile | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Makefile b/Makefile index a8195513a9be..21286359992b 100644 --- a/Makefile +++ b/Makefile @@ -66,20 +66,3 @@ docker-push: docker push ${IMG} docker-release: docker-build docker-push - -# find or download controller-gen -# download controller-gen if necessary -controller-gen: -ifeq (, $(shell which controller-gen)) - @{ \ - set -e ;\ - CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ - cd $$CONTROLLER_GEN_TMP_DIR ;\ - go mod init tmp ;\ - go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\ - rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ - } -CONTROLLER_GEN=$(GOBIN)/controller-gen -else -CONTROLLER_GEN=$(shell which controller-gen) -endif From 6509a053f43ef398cc3561b7e9efac00b30318a0 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 12:10:31 -0700 Subject: [PATCH 13/14] remove references to controller-gen as dependency --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 21286359992b..efb7246ba7d8 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ undeploy: manifests kustomize build config/default | kubectl delete -f - # Generate manifests e.g. CRD, RBAC etc. -manifests: controller-gen +manifests: controller-gen $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases # Run go fmt against code @@ -54,7 +54,7 @@ vet: go vet ./... # Generate code -generate: controller-gen +generate: controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." # Build the docker image From 7177ec9061c1a0a28851423e96d93c62c6b9c767 Mon Sep 17 00:00:00 2001 From: Jacob Gabrielson Date: Fri, 14 Aug 2020 12:12:36 -0700 Subject: [PATCH 14/14] correct capitalization --- config/crd/bases/karpenter.sh_horizontalautoscalers.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml b/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml index af961ca71d8e..94359d406021 100644 --- a/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml +++ b/config/crd/bases/karpenter.sh_horizontalautoscalers.yaml @@ -45,7 +45,7 @@ spec: used. properties: scaleDown: - description: scaleDown is scaling policy for scaling Down. If not + description: ScaleDown is scaling policy for scaling Down. If not set, the default value is to allow to scale down to minReplicas, with a 300 second stabilization window (i.e., the highest recommendation for the last 300sec is used). @@ -98,7 +98,7 @@ spec: type: integer type: object scaleUp: - description: 'scaleUp is scaling policy for scaling Up. If not set, + description: 'ScaleUp is scaling policy for scaling Up. If not set, the default value is the higher of: * increase no more than 4 replicas per 60 seconds * double the number of replicas per 60 seconds No stabilization is used.'