Skip to content

Commit c46f599

Browse files
committed
feat: Refactor Helm chart
Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
1 parent 955ed8c commit c46f599

24 files changed

+583
-550
lines changed

Makefile

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ WITH_RELEASE_REPO = KO_DOCKER_REPO=$(RELEASE_REPO)
2222
## Extra helm options
2323
CLUSTER_NAME ?= $(shell kubectl config view --minify -o jsonpath='{.clusters[].name}' | rev | cut -d"/" -f1 | rev)
2424
CLUSTER_ENDPOINT ?= $(shell kubectl config view --minify -o jsonpath='{.clusters[].cluster.server}')
25-
HELM_OPTS ?= --set controller.clusterName=${CLUSTER_NAME} \
26-
--set controller.clusterEndpoint=${CLUSTER_ENDPOINT} \
27-
--set aws.defaultInstanceProfile=KarpenterNodeInstanceProfile-${CLUSTER_NAME}
25+
HELM_OPTS ?= --set clusterName=${CLUSTER_NAME} \
26+
--set clusterEndpoint=${CLUSTER_ENDPOINT} \
27+
--set aws.defaultInstanceProfile=KarpenterNodeInstanceProfile-${CLUSTER_NAME}
2828

2929
help: ## Display help
3030
@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)
@@ -64,7 +64,7 @@ licenses: ## Verifies dependency licenses and requires GITHUB_TOKEN to be set
6464
golicense hack/license-config.hcl karpenter
6565

6666
apply: ## Deploy the controller into your ~/.kube/config cluster
67-
helm template --include-crds karpenter charts/karpenter --namespace karpenter \
67+
helm template --include-crds karpenter charts/karpenter --namespace karpenter \
6868
$(HELM_OPTS) \
6969
--set controller.image=ko://github.com/aws/karpenter/cmd/controller \
7070
--set webhook.image=ko://github.com/aws/karpenter/cmd/webhook \
@@ -73,7 +73,6 @@ apply: ## Deploy the controller into your ~/.kube/config cluster
7373
delete: ## Delete the controller from your ~/.kube/config cluster
7474
helm template karpenter charts/karpenter --namespace karpenter \
7575
$(HELM_OPTS) \
76-
--set serviceAccount.create=false \
7776
| kubectl delete -f -
7877

7978
codegen: ## Generate code. Must be run if changes are made to ./pkg/apis/...

charts/karpenter/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/karpenter/Chart.yaml

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
apiVersion: v2
2-
appVersion: 0.5.6
32
name: karpenter
4-
description: A Helm chart for https://github.com/aws/karpenter/.
3+
description: A Helm chart for Karpenter, an open-source node provisioning project built for Kubernetes.
54
type: application
65
version: 0.5.6
6+
appVersion: 0.5.6
7+
keywords:
8+
- cluster
9+
- node
10+
- scheduler
11+
- autoscaling
12+
- lifecycle
13+
home: https://karpenter.sh/
14+
icon: https://repository-images.githubusercontent.com/278480393/dab059c8-caa1-4b55-aaa7-3d30e47a5616
15+
sources:
16+
- https://github.com/aws/karpenter/

charts/karpenter/README.md

+39-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# karpenter
22

3-
A Helm chart for https://github.com/aws/karpenter/.
3+
A Helm chart for Karpenter, an open-source node provisioning project built for Kubernetes.
44

55
![Version: 0.5.6](https://img.shields.io/badge/Version-0.5.6-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.5.6](https://img.shields.io/badge/AppVersion-0.5.6-informational?style=flat-square)
66

@@ -12,10 +12,10 @@ To install the chart with the release name `karpenter`:
1212
$ helm repo add karpenter https://charts.karpenter.sh
1313
$ helm repo update
1414
$ helm upgrade --install karpenter karpenter/karpenter --namespace karpenter \
15-
--create-namespace --set serviceAccount.create=false --version 0.5.6 \
16-
--set controller.clusterName=${CLUSTER_NAME} \
17-
--set controller.clusterEndpoint=$(aws eks describe-cluster --name ${CLUSTER_NAME} --query "cluster.endpoint" --output json) \
18-
--wait # for the defaulting webhook to install before creating a Provisioner
15+
--create-namespace --version 0.5.6 \
16+
--set clusterName=${CLUSTER_NAME} \
17+
--set clusterEndpoint=$(aws eks describe-cluster --name ${CLUSTER_NAME} --query "cluster.endpoint" --output json) \
18+
--wait # for the defaulting webhook to install before creating a Provisioner
1919
```
2020

2121
You can follow the detailed installation instruction [here](https://karpenter.sh/docs/getting-started/#install).
@@ -24,35 +24,40 @@ You can follow the detailed installation instruction [here](https://karpenter.sh
2424

2525
| Key | Type | Default | Description |
2626
|-----|------|---------|-------------|
27-
| additionalLabels | object | `{}` | Additional labels to add into metadata |
27+
| additionalLabels | object | `{}` | Additional labels to add into metadata. |
28+
| affinity | object | `{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"key":"karpenter.sh/provisioner-name","operator":"DoesNotExist"}]}}}` | Affinity rules for scheduling the pod. |
2829
| aws.defaultInstanceProfile | string | `""` | The default instance profile to use when launching nodes on AWS |
29-
| controller.affinity | object | `{}` | Affinity rules for scheduling |
30-
| controller.clusterEndpoint | string | `""` | Cluster endpoint |
31-
| controller.clusterName | string | `""` | Cluster name |
32-
| controller.env | list | `[]` | Additional environment variables to run with |
33-
| controller.image | string | `"public.ecr.aws/karpenter/controller:v0.5.6@sha256:12ae0ca9d48155ab881c6d76930bd67d503952a1a50269821a4118aa0228ca7e"` | Image to use for the Karpenter controller |
34-
| controller.nodeSelector | object | `{}` | Node selectors to schedule to nodes with labels. |
35-
| controller.replicas | int | `1` | |
36-
| controller.resources.limits.cpu | int | `1` | |
37-
| controller.resources.limits.memory | string | `"1Gi"` | |
38-
| controller.resources.requests.cpu | int | `1` | |
39-
| controller.resources.requests.memory | string | `"1Gi"` | |
40-
| controller.tolerations | list | `[]` | Tolerations to schedule to nodes with taints. |
41-
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account (like the ARN of the IRSA role) |
42-
| serviceAccount.create | bool | `true` | Create a service account for the application controller |
43-
| serviceAccount.name | string | `"karpenter"` | Service account name |
44-
| webhook.affinity | object | `{}` | Affinity rules for scheduling |
45-
| webhook.env | list | `[]` | List of environment items to add to the webhook |
46-
| webhook.hostNetwork | bool | `false` | Set to true if using custom CNI on EKS |
47-
| webhook.image | string | `"public.ecr.aws/karpenter/webhook:v0.5.6@sha256:4b289e73e728744ffdce39d37440a87a9b1df7c36110f55030de679a4579a3e2"` | Image to use for the webhook |
48-
| webhook.nodeSelector | object | `{}` | Node selectors to schedule to nodes with labels. |
49-
| webhook.port | int | `8443` | |
50-
| webhook.replicas | int | `1` | |
51-
| webhook.resources.limits.cpu | string | `"100m"` | |
52-
| webhook.resources.limits.memory | string | `"50Mi"` | |
53-
| webhook.resources.requests.cpu | string | `"100m"` | |
54-
| webhook.resources.requests.memory | string | `"50Mi"` | |
55-
| webhook.tolerations | list | `[]` | Tolerations to schedule to nodes with taints. |
30+
| clusterEndpoint | string | `""` | Cluster endpoint. |
31+
| clusterName | string | `""` | Cluster name. |
32+
| controller.env | list | `[]` | Additional environment variables for the controller pod. |
33+
| controller.image | string | `"public.ecr.aws/karpenter/controller:v0.5.6@sha256:12ae0ca9d48155ab881c6d76930bd67d503952a1a50269821a4118aa0228ca7e"` | Controller image. |
34+
| controller.resources | object | `{"limits":{"cpu":1,"memory":"1Gi"},"requests":{"cpu":1,"memory":"1Gi"}}` | Resources for the controller pod. |
35+
| controller.securityContext | object | `{}` | SecurityContext for the controller container. |
36+
| fullnameOverride | string | `""` | Overrides the chart's computed fullname. |
37+
| hostNetwork | bool | `false` | Bind the pod to the host network. This is required when using a custom CNI. |
38+
| imagePullPolicy | string | `"IfNotPresent"` | Image pull policy for Docker images. |
39+
| imagePullSecrets | list | `[]` | Image pull secrets for Docker images. |
40+
| nameOverride | string | `""` | Overrides the chart's name. |
41+
| nodeSelector | object | `{"kubernetes.io/os":"linux"}` | Node selectors to schedule the pod to nodes with labels. |
42+
| podAnnotations | object | `{}` | Additional annotations for the pod. |
43+
| podLabels | object | `{}` | Additional labels for the pod. |
44+
| podSecurityContext | object | `{"fsGroup":1000}` | SecurityContext for the pod. |
45+
| priorityClassName | string | `"system-cluster-critical"` | PriorityClass name for the pod. |
46+
| replicas | int | `1` | Number of replicas. |
47+
| serviceAccount.annotations | object | `{}` | Additional annotations for the ServiceAccount. |
48+
| serviceAccount.create | bool | `true` | Specifies if a ServiceAccount should be created. |
49+
| serviceAccount.name | string | `""` | The name of the ServiceAccount to use. If not set and create is true, a name is generated using the fullname template. |
50+
| serviceMonitor.additionalLabels | object | `{}` | Additional labels for the ServiceMonitor. |
51+
| serviceMonitor.enabled | bool | `false` | Specifies whether a ServiceMonitor should be created. |
52+
| serviceMonitor.interval | string | `"1m"` | Scrape interval for the ServiceMonitor. |
53+
| strategy | object | `{"type":"Recreate"}` | Strategy for updating the pod. |
54+
| terminationGracePeriodSeconds | string | `nil` | Override the default termination grace period for the pod. |
55+
| tolerations | list | `[]` | Tolerations to allow the pod to be scheduled to nodes with taints. |
56+
| webhook.env | list | `[]` | Additional environment variables for the webhook pod. |
57+
| webhook.image | string | `"public.ecr.aws/karpenter/webhook:v0.5.6@sha256:4b289e73e728744ffdce39d37440a87a9b1df7c36110f55030de679a4579a3e2"` | Webhook image. |
58+
| webhook.port | int | `8443` | The container port to use for the webhook. |
59+
| webhook.resources | object | `{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}}` | Resources for the webhook pod. |
60+
| webhook.securityContext | object | `{}` | SecurityContext for the webhook container. |
5661

5762
----------------------------------------------
58-
Autogenerated from chart metadata using [helm-docs v1.6.0](https://github.com/norwoodj/helm-docs/releases/v1.6.0)
63+
Autogenerated from chart metadata using [helm-docs v1.7.0](https://github.com/norwoodj/helm-docs/releases/v1.7.0)

charts/karpenter/README.md.gotmpl

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ To install the chart with the release name `karpenter`:
1111
$ helm repo add karpenter https://charts.karpenter.sh
1212
$ helm repo update
1313
$ helm upgrade --install karpenter karpenter/{{ template "chart.name" . }} --namespace karpenter \
14-
--create-namespace --set serviceAccount.create=false --version {{ template "chart.version" . }} \
15-
--set controller.clusterName=${CLUSTER_NAME} \
16-
--set controller.clusterEndpoint=$(aws eks describe-cluster --name ${CLUSTER_NAME} --query "cluster.endpoint" --output json) \
17-
--wait # for the defaulting webhook to install before creating a Provisioner
14+
--create-namespace --version {{ template "chart.version" . }} \
15+
--set clusterName=${CLUSTER_NAME} \
16+
--set clusterEndpoint=$(aws eks describe-cluster --name ${CLUSTER_NAME} --query "cluster.endpoint" --output json) \
17+
--wait # for the defaulting webhook to install before creating a Provisioner
1818
```
1919

2020
You can follow the detailed installation instruction [here](https://karpenter.sh/docs/getting-started/#install).
@@ -23,4 +23,4 @@ You can follow the detailed installation instruction [here](https://karpenter.sh
2323

2424
{{ template "chart.valuesSection" . }}
2525

26-
{{ template "helm-docs.versionFooter" . }}
26+
{{ template "helm-docs.versionFooter" . }}

charts/karpenter/templates/_helpers.tpl

+30-32
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,53 @@
22
Expand the name of the chart.
33
*/}}
44
{{- define "karpenter.name" -}}
5-
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
6-
{{- end -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
77

88
{{/*
99
Create a default fully qualified app name.
1010
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
1111
If release name contains chart name it will be used as a full name.
1212
*/}}
1313
{{- define "karpenter.fullname" -}}
14-
{{- if .Values.fullnameOverride -}}
15-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
16-
{{- else -}}
17-
{{- $name := default .Chart.Name .Values.nameOverride -}}
18-
{{- if contains $name .Release.Name -}}
19-
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
20-
{{- else -}}
21-
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
22-
{{- end -}}
23-
{{- end -}}
24-
{{- end -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
2525

2626
{{/*
2727
Create chart name and version as used by the chart label.
2828
*/}}
2929
{{- define "karpenter.chart" -}}
30-
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
31-
{{- end -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
3232

3333
{{/*
34-
Generate basic labels
34+
Common labels
3535
*/}}
36-
{{- define "karpenter.labels" }}
36+
{{- define "karpenter.labels" -}}
3737
helm.sh/chart: {{ include "karpenter.chart" . }}
38-
app.kubernetes.io/managed-by: {{ .Release.Service }}
39-
app.kubernetes.io/component: karpenter
40-
app.kubernetes.io/part-of: {{ template "karpenter.name" . }}
41-
{{- include "karpenter.selectorLabels" . }}
42-
{{- if .Chart.Version }}
43-
app.kubernetes.io/version: {{ .Chart.Version | quote }}
38+
{{ include "karpenter.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4441
{{- end }}
45-
{{- if .Values.additionalLabels }}
46-
{{ toYaml .Values.additionalLabels }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- with .Values.additionalLabels }}
44+
{{ toYaml . }}
4745
{{- end }}
4846
{{- end }}
4947

5048
{{/*
5149
Selector labels
5250
*/}}
53-
{{- define "karpenter.selectorLabels" }}
51+
{{- define "karpenter.selectorLabels" -}}
5452
app.kubernetes.io/name: {{ include "karpenter.name" . }}
5553
app.kubernetes.io/instance: {{ .Release.Name }}
5654
{{- end }}
@@ -59,9 +57,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
5957
Create the name of the service account to use
6058
*/}}
6159
{{- define "karpenter.serviceAccountName" -}}
62-
{{- if .Values.serviceAccount.enabled -}}
63-
{{ default (include "karpenter.fullname" .) .Values.serviceAccount.name }}
64-
{{- else -}}
65-
{{ default "default" .Values.serviceAccount.name }}
66-
{{- end -}}
67-
{{- end -}}
60+
{{- if .Values.serviceAccount.create }}
61+
{{- default (include "karpenter.fullname" .) .Values.serviceAccount.name }}
62+
{{- else }}
63+
{{- default "default" .Values.serviceAccount.name }}
64+
{{- end }}
65+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ include "karpenter.fullname" . }}
5+
labels:
6+
{{- include "karpenter.labels" . | nindent 4 }}
7+
rules:
8+
- apiGroups: ["karpenter.sh"]
9+
resources: ["provisioners"]
10+
verbs: ["get", "list", "watch"]
11+
- apiGroups: ["karpenter.sh"]
12+
resources: ["provisioners/status"]
13+
verbs: ["create", "delete", "patch", "get", "list", "watch"]
14+
- apiGroups: [""]
15+
resources: ["persistentvolumes", "persistentvolumeclaims"]
16+
verbs: ["get", "list", "watch", "update"]
17+
- apiGroups: ["storage.k8s.io"]
18+
resources: ["storageclasses"]
19+
verbs: ["get", "list", "watch"]
20+
- apiGroups: [""]
21+
resources: ["nodes", "pods"]
22+
verbs: ["get", "list", "watch", "patch", "delete"]
23+
- apiGroups: [""]
24+
resources: ["configmaps"]
25+
verbs: ["get", "list", "watch"]
26+
- apiGroups: [""]
27+
resources: ["nodes"]
28+
verbs: ["create"]
29+
- apiGroups: [""]
30+
resources: ["pods/binding", "pods/eviction"]
31+
verbs: ["create"]
32+
- apiGroups: ["apps"]
33+
resources: ["daemonsets"]
34+
verbs: ["list", "watch"]
35+
- apiGroups: ["admissionregistration.k8s.io"]
36+
resources: ["validatingwebhookconfigurations", "mutatingwebhookconfigurations"]
37+
verbs: ["get", "watch", "list", "update"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: {{ include "karpenter.fullname" . }}
5+
labels:
6+
{{- include "karpenter.labels" . | nindent 4 }}
7+
roleRef:
8+
apiGroup: rbac.authorization.k8s.io
9+
kind: ClusterRole
10+
name: {{ include "karpenter.fullname" . }}
11+
subjects:
12+
- kind: ServiceAccount
13+
name: {{ template "karpenter.serviceAccountName" . }}
14+
namespace: {{ .Release.Namespace }}

charts/karpenter/templates/100-config-logging.yaml charts/karpenter/templates/configmap-logging.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: config-logging
5-
namespace: {{ .Release.Namespace }}
65
labels:
7-
{{- include "karpenter.labels" . | indent 4 }}
6+
{{- include "karpenter.labels" . | nindent 4 }}
87
data:
98
# https://github.com/uber-go/zap/blob/aa3e73ec0896f8b066ddf668597a02f89628ee50/config.go
109
zap-logger-config: |

0 commit comments

Comments
 (0)