generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 277
replace kustomize with helm #587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
578271c
replace kustomize with helm
cjerad e0e0628
move tool download to script
cjerad 81088e3
restore # markers
cjerad 5ce2399
merge fmt and vet targets into verify
cjerad fde73f4
add kubebuilder setup with setup-envtest
cjerad 61c4799
do not use temp module
cjerad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,31 @@ | ||
| TBD | ||
| # Setup Development Environment | ||
|
|
||
| Clone the repo: | ||
|
|
||
| ```sh | ||
| git clone --branch v2 https://github.com/aws/aws-node-termination-handler.git | ||
| ``` | ||
|
|
||
| Install build tools | ||
|
|
||
| ```sh | ||
| make toolchain | ||
| ``` | ||
|
|
||
| Configure image repository location | ||
|
|
||
| ```sh | ||
| export KO_DOCKER_REPO=my.image.repo/path | ||
| ``` | ||
|
|
||
| Build and deploy controller to Kubernetes cluster | ||
|
|
||
| ```sh | ||
| make apply | ||
| ``` | ||
|
|
||
| Remove deployed controller from Kubernetes cluster | ||
|
|
||
| ```sh | ||
| make delete | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
| CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen | ||
| KO = $(PROJECT_DIR)/bin/ko | ||
| ENVTEST = $(PROJECT_DIR)/bin/setup-envtest | ||
|
|
||
|
|
||
| # Image URL to use all building/pushing image targets | ||
| IMG ?= controller:latest | ||
|
|
@@ -17,9 +22,6 @@ endif | |
| SHELL = /usr/bin/env bash -o pipefail | ||
| .SHELLFLAGS = -ec | ||
|
|
||
| .PHONY: all | ||
| all: build | ||
|
|
||
| ##@ General | ||
|
|
||
| # The help target prints out all targets with their descriptions organized | ||
|
|
@@ -37,22 +39,23 @@ all: build | |
| help: ## Display this help. | ||
| @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\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) | ||
|
|
||
| .PHONY: toolchain | ||
| toolchain: ## Download additional tools. | ||
| @./scripts/toolchain.sh -d "$(PROJECT_DIR)/bin" | ||
|
|
||
| ##@ Development | ||
|
|
||
| .PHONY: manifests | ||
| manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
| manifests: ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
| $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
|
||
| .PHONY: generate | ||
| generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
| generate: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. | ||
| $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
|
|
||
| .PHONY: fmt | ||
| fmt: ## Run go fmt against code. | ||
| .PHONY: verify | ||
| verify: ## Run go fmt and go vet against code. | ||
| go fmt ./... | ||
|
|
||
| .PHONY: vet | ||
| vet: ## Run go vet against code. | ||
| go vet ./... | ||
|
|
||
| .PHONY: test | ||
cjerad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -61,70 +64,19 @@ test: manifests generate fmt vet envtest ## Run tests. | |
|
|
||
| ##@ Build | ||
|
|
||
| .PHONY: build | ||
| build: generate fmt vet ## Build manager binary. | ||
| go build -o bin/manager main.go | ||
|
|
||
| .PHONY: run | ||
| run: manifests generate fmt vet ## Run a controller from your host. | ||
| go run ./main.go | ||
|
|
||
| .PHONY: docker-build | ||
| docker-build: test ## Build docker image with the manager. | ||
| docker build -t ${IMG} . | ||
|
|
||
| .PHONY: docker-push | ||
| docker-push: ## Push docker image with the manager. | ||
| docker push ${IMG} | ||
|
|
||
| ##@ Deployment | ||
|
|
||
| ifndef ignore-not-found | ||
| ignore-not-found = false | ||
| endif | ||
| .PHONY: apply | ||
| apply: ## Deploy the controller into the current kubernetes cluster. | ||
| helm upgrade --install dev charts/aws-node-termination-handler-2 --namespace nthv2 --create-namespace \ | ||
| $(HELM_OPTS) \ | ||
| --set controller.image=$(shell $(KO) publish -B github.com/aws/aws-node-termination-handler) \ | ||
| --set fullnameOverride=nthv2 | ||
|
|
||
| .PHONY: install | ||
| install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. | ||
| $(KUSTOMIZE) build config/crd | kubectl apply -f - | ||
|
|
||
| .PHONY: uninstall | ||
| uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. | ||
| $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - | ||
|
|
||
| .PHONY: deploy | ||
| deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. | ||
| cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
| $(KUSTOMIZE) build config/default | kubectl apply -f - | ||
|
|
||
| .PHONY: undeploy | ||
| undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. | ||
| $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - | ||
|
|
||
| CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
| .PHONY: controller-gen | ||
| controller-gen: ## Download controller-gen locally if necessary. | ||
| $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) | ||
|
|
||
| KUSTOMIZE = $(shell pwd)/bin/kustomize | ||
| .PHONY: kustomize | ||
| kustomize: ## Download kustomize locally if necessary. | ||
| $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||
|
|
||
| ENVTEST = $(shell pwd)/bin/setup-envtest | ||
| .PHONY: envtest | ||
| envtest: ## Download envtest-setup locally if necessary. | ||
| $(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) | ||
|
|
||
| # go-get-tool will 'go get' any package $2 and install it to $1. | ||
| PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
| define go-get-tool | ||
| @[ -f $(1) ] || { \ | ||
| set -e ;\ | ||
| TMP_DIR=$$(mktemp -d) ;\ | ||
| cd $$TMP_DIR ;\ | ||
| go mod init tmp ;\ | ||
| echo "Downloading $(2)" ;\ | ||
| GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\ | ||
| rm -rf $$TMP_DIR ;\ | ||
| } | ||
| endef | ||
| .PHONY: delete | ||
| delete: ## Delete controller from current kubernetes cluster. | ||
| helm uninstall dev --namespace nthv2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| apiVersion: v2 | ||
| name: aws-node-termination-handler-2 | ||
| description: A Helm chart for aws-node-termination-handler, an open-source component for gracefully handling termination events for node hosted in AWS. | ||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "2.0.0-0.1" | ||
| kubeVersion: ">=1.16-0" | ||
| keywords: | ||
| - aws | ||
| - ec2 | ||
| - ec2-spot | ||
| - eks | ||
| - node | ||
| - node-termination | ||
| - spot | ||
| home: https://github.com/aws/eks-charts | ||
| sources: | ||
| - https://github.com/aws/aws-node-termination-handler | ||
| - https://github.com/aws/eks-charts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # AWS Node Termination Handler | ||
|
|
||
| AWS Node Termination Handler Helm chart for Kubernetes. For more information on this project see the project repo at [github.com/aws/aws-node-termination-handler](https://github.com/aws/aws-node-termination-handler). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - _Kubernetes_ >= 1.16 | ||
|
|
||
| ## Installing the Chart | ||
|
|
||
| Before you can install the chart you will need to add the `aws` repo to [Helm](https://helm.sh/). | ||
|
|
||
| ```shell | ||
| helm repo add eks https://aws.github.io/eks-charts/ | ||
| ``` |
56 changes: 56 additions & 0 deletions
56
src/charts/aws-node-termination-handler-2/crds/node.k8s.aws_terminators.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| --- | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| annotations: | ||
| controller-gen.kubebuilder.io/version: v0.8.0 | ||
| creationTimestamp: null | ||
| name: terminators.node.k8s.aws | ||
| spec: | ||
| group: node.k8s.aws | ||
| names: | ||
| kind: Terminator | ||
| listKind: TerminatorList | ||
| plural: terminators | ||
| singular: terminator | ||
| scope: Namespaced | ||
| versions: | ||
| - name: v1alpha1 | ||
| schema: | ||
| openAPIV3Schema: | ||
| description: Terminator is the Schema for the terminators API | ||
| properties: | ||
| apiVersion: | ||
| description: 'APIVersion defines the versioned schema of this representation | ||
| of an object. Servers should convert recognized schemas to the latest | ||
| internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
| type: string | ||
| kind: | ||
| description: 'Kind is a string value representing the REST resource this | ||
| object represents. Servers may infer this from the endpoint the client | ||
| submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
| type: string | ||
| metadata: | ||
| type: object | ||
| spec: | ||
| description: TerminatorSpec defines the desired state of Terminator | ||
| properties: | ||
| foo: | ||
| description: Foo is an example field of Terminator. Edit terminator_types.go | ||
| to remove/update | ||
| type: string | ||
| type: object | ||
| status: | ||
| description: TerminatorStatus defines the observed state of Terminator | ||
| type: object | ||
| type: object | ||
| served: true | ||
| storage: true | ||
| subresources: | ||
| status: {} | ||
| status: | ||
| acceptedNames: | ||
| kind: "" | ||
| plural: "" | ||
| conditions: [] | ||
| storedVersions: [] |
65 changes: 65 additions & 0 deletions
65
src/charts/aws-node-termination-handler-2/templates/_helpers.tpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| {{/* | ||
| Expand the name of the chart. | ||
| */}} | ||
| {{- define "aws-node-termination-handler.name" -}} | ||
| {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Create a default fully qualified app name. | ||
| We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
| If release name contains chart name it will be used as a full name. | ||
| */}} | ||
| {{- define "aws-node-termination-handler.fullname" -}} | ||
| {{- if .Values.fullnameOverride -}} | ||
| {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
| {{- else -}} | ||
| {{- $name := default .Chart.Name .Values.nameOverride -}} | ||
| {{- if contains $name .Release.Name -}} | ||
| {{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
| {{- else -}} | ||
| {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Create chart name and version as used by the chart label. | ||
| */}} | ||
| {{- define "aws-node-termination-handler.chart" -}} | ||
| {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Common labels | ||
| */}} | ||
| {{- define "aws-node-termination-handler.labels" -}} | ||
| helm.sh/chart: {{ include "aws-node-termination-handler.chart" . | quote }} | ||
| {{ include "aws-node-termination-handler.selectorLabels" . }} | ||
| {{- if .Chart.AppVersion }} | ||
| app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
| {{- end }} | ||
| app.kubernetes.io/managed-by: {{ .Release.Service | quote }} | ||
| {{- with .Values.labels }} | ||
| {{ toYaml . }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Selector labels | ||
| */}} | ||
| {{- define "aws-node-termination-handler.selectorLabels" -}} | ||
| app.kubernetes.io/name: {{ include "aws-node-termination-handler.name" . | quote }} | ||
| app.kubernetes.io/instance: {{ .Release.Name | quote }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Create the name of the service account to use | ||
| */}} | ||
| {{- define "aws-node-termination-handler.serviceAccountName" -}} | ||
| {{- if .Values.serviceAccount.create }} | ||
| {{- default (include "aws-node-termination-handler.fullname" .) .Values.serviceAccount.name }} | ||
| {{- else }} | ||
| {{- default "default" .Values.serviceAccount.name }} | ||
| {{- end }} | ||
| {{- end }} |
46 changes: 46 additions & 0 deletions
46
src/charts/aws-node-termination-handler-2/templates/clusterrole.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| {{- if .Values.rbac.create -}} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: {{ include "aws-node-termination-handler.fullname" . }} | ||
| labels: | ||
| {{- include "aws-node-termination-handler.labels" . | nindent 8 }} | ||
| {{- with .Values.annotations }} | ||
| annotations: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| rules: | ||
| - apiGroups: ["node.k8s.aws"] | ||
| resources: ["terminators"] | ||
| verbs: ["get", "list", "watch"] | ||
|
|
||
| - apiGroups: ["node.k8s.aws"] | ||
| resources: ["terminators/status"] | ||
| verbs: ["create", "delete", "patch", "get", "list", "watch"] | ||
|
|
||
| - apiGroups: [""] | ||
| resources: ["nodes"] | ||
| verbs: ["get", "list", "patch", "update"] | ||
|
|
||
| - apiGroups: [""] | ||
| resources: ["pods"] | ||
| verbs: ["get", "list"] | ||
|
|
||
| - apiGroups: [""] | ||
| resources: ["pods/eviction"] | ||
| verbs: ["create"] | ||
|
|
||
| - apiGroups: ["apps", "extensions"] | ||
| resources: ["daemonsets"] | ||
| verbs: ["get"] | ||
|
|
||
| - apiGroups: ["admissionregistration.k8s.io"] | ||
| resources: ["validatingwebhookconfigurations", "mutatingwebhookconfigurations"] | ||
| verbs: ["get", "list", "watch", "update"] | ||
|
|
||
| {{- if .Values.emitKubernetesEvents }} | ||
| - apiGroups: [""] | ||
| resources: ["events"] | ||
| verbs: ["create", "patch"] | ||
| {{- end }} | ||
| {{- end -}} |
20 changes: 20 additions & 0 deletions
20
src/charts/aws-node-termination-handler-2/templates/clusterrole_binding.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| {{- if .Values.rbac.create -}} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: {{ include "aws-node-termination-handler.fullname" . }} | ||
| labels: | ||
| {{- include "aws-node-termination-handler.labels" . | nindent 8 }} | ||
| {{- with .Values.annotations }} | ||
| annotations: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: {{ include "aws-node-termination-handler.fullname" . }} | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ template "aws-node-termination-handler.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} | ||
| {{- end }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.