Skip to content

Commit a5f2e17

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

31 files changed

+688
-459
lines changed

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ WITH_RELEASE_REPO = KO_DOCKER_REPO=$(RELEASE_REPO)
1414
## Extra helm options
1515
CLUSTER_NAME ?= $(shell kubectl config view --minify -o jsonpath='{.clusters[].name}' | rev | cut -d"/" -f1 | rev)
1616
CLUSTER_ENDPOINT ?= $(shell kubectl config view --minify -o jsonpath='{.clusters[].cluster.server}')
17-
HELM_OPTS ?= --set controller.clusterName=${CLUSTER_NAME} --set controller.clusterEndpoint=${CLUSTER_ENDPOINT}
17+
HELM_OPTS ?= --set clusterName=${CLUSTER_NAME} --set clusterEndpoint=${CLUSTER_ENDPOINT}
1818

1919
help: ## Display help
2020
@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)
@@ -54,7 +54,7 @@ licenses: ## Verifies dependency licenses and requires GITHUB_TOKEN to be set
5454
golicense hack/license-config.hcl karpenter
5555

5656
apply: ## Deploy the controller into your ~/.kube/config cluster
57-
helm template --include-crds karpenter charts/karpenter --namespace karpenter \
57+
helm template --include-crds karpenter charts/karpenter --namespace karpenter \
5858
$(HELM_OPTS) \
5959
--set controller.image=ko://github.com/aws/karpenter/cmd/controller \
6060
--set webhook.image=ko://github.com/aws/karpenter/cmd/webhook \
@@ -63,7 +63,6 @@ apply: ## Deploy the controller into your ~/.kube/config cluster
6363
delete: ## Delete the controller from your ~/.kube/config cluster
6464
helm template karpenter charts/karpenter --namespace karpenter \
6565
$(HELM_OPTS) \
66-
--set serviceAccount.create=false \
6766
| kubectl delete -f -
6867

6968
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

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
apiVersion: v2
2-
appVersion: 0.5.4
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.4
6+
appVersion: 0.5.4
7+
keywords:
8+
- fluent
9+
- fluentd
10+
- logging
11+
home: https://karpenter.sh/
12+
icon: https://repository-images.githubusercontent.com/278480393/dab059c8-caa1-4b55-aaa7-3d30e47a5616
13+
sources:
14+
- https://github.com/aws/karpenter/

charts/karpenter/README.md

+47-32
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.4](https://img.shields.io/badge/Version-0.5.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.5.4](https://img.shields.io/badge/AppVersion-0.5.4-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.4 \
15+
--create-namespace --version 0.5.4 \
1616
--set controller.clusterName=${CLUSTER_NAME} \
1717
--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
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,34 +24,49 @@ 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 |
28-
| controller.affinity | object | `{}` | Affinity rules for scheduling |
29-
| controller.clusterEndpoint | string | `""` | Cluster endpoint |
30-
| controller.clusterName | string | `""` | Cluster name |
31-
| controller.env | list | `[]` | Additional environment variables to run with |
32-
| controller.image | string | `"public.ecr.aws/karpenter/controller:v0.5.4@sha256:19ebf83d64fa41d75fb19ae5047f54b1c66423b4ab5ceef36ae99a0daaad1895"` | Image to use for the Karpenter controller |
33-
| controller.nodeSelector | object | `{}` | Node selectors to schedule to nodes with labels. |
34-
| controller.replicas | int | `1` | |
35-
| controller.resources.limits.cpu | int | `1` | |
36-
| controller.resources.limits.memory | string | `"1Gi"` | |
37-
| controller.resources.requests.cpu | int | `1` | |
38-
| controller.resources.requests.memory | string | `"1Gi"` | |
39-
| controller.tolerations | list | `[]` | Tolerations to schedule to nodes with taints. |
40-
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account (like the ARN of the IRSA role) |
41-
| serviceAccount.create | bool | `true` | Create a service account for the application controller |
42-
| serviceAccount.name | string | `"karpenter"` | Service account name |
43-
| webhook.affinity | object | `{}` | Affinity rules for scheduling |
44-
| webhook.env | list | `[]` | List of environment items to add to the webhook |
45-
| webhook.hostNetwork | bool | `false` | Set to true if using custom CNI on EKS |
46-
| webhook.image | string | `"public.ecr.aws/karpenter/webhook:v0.5.4@sha256:fd7dd0a3e155cb08a1c1def31258c654ac6c61b2fa8d8d25b7483688664c7de2"` | Image to use for the webhook |
47-
| webhook.nodeSelector | object | `{}` | Node selectors to schedule to nodes with labels. |
48-
| webhook.port | int | `8443` | |
49-
| webhook.replicas | int | `1` | |
50-
| webhook.resources.limits.cpu | string | `"100m"` | |
51-
| webhook.resources.limits.memory | string | `"50Mi"` | |
52-
| webhook.resources.requests.cpu | string | `"100m"` | |
53-
| webhook.resources.requests.memory | string | `"50Mi"` | |
54-
| webhook.tolerations | list | `[]` | Tolerations to schedule to nodes with taints. |
27+
| additionalLabels | object | `{}` | Additional labels to add into metadata. |
28+
| clusterEndpoint | string | `""` | Cluster endpoint. |
29+
| clusterName | string | `""` | Cluster name. |
30+
| controller.affinity | object | `{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"key":"karpenter.sh/provisioner-name","operator":"DoesNotExist"}]}}}` | Affinity rules for scheduling the controller pod. |
31+
| controller.env | list | `[]` | Additional environment variables for the controller pod. |
32+
| controller.image | string | `"public.ecr.aws/karpenter/controller:v0.5.4@sha256:19ebf83d64fa41d75fb19ae5047f54b1c66423b4ab5ceef36ae99a0daaad1895"` | Controller image. |
33+
| controller.nodeSelector | object | `{"kubernetes.io/os":"linux"}` | Node selectors to schedule the controller pod to nodes with labels. |
34+
| controller.podAnnotations | object | `{}` | Additional annotations for the controller pod. |
35+
| controller.podLabels | object | `{}` | Additional labels for the controller pod. |
36+
| controller.podSecurityContext | object | `{"fsGroup":1000}` | SecurityContext for the controller pod. |
37+
| controller.priorityClassName | string | `"system-cluster-critical"` | PriorityClass name for the controller pod. |
38+
| controller.replicas | int | `1` | Number of replicas for the controller pod. |
39+
| controller.resources | object | `{"limits":{"cpu":1,"memory":"1Gi"},"requests":{"cpu":1,"memory":"1Gi"}}` | Resources for the controller pod. |
40+
| controller.securityContext | object | `{}` | SecurityContext for the controller containers. |
41+
| controller.serviceAccount.annotations | object | `{}` | Additional annotations for the controller ServiceAccount. |
42+
| controller.serviceAccount.create | bool | `true` | Specifies whether a ServiceAccount should be created for the controller. |
43+
| controller.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. |
44+
| controller.strategy | object | `{"type":"Recreate"}` | Strategy for updating the controller pod. |
45+
| controller.terminationGracePeriodSeconds | string | `nil` | Override the default termination grace period for the controller pod. |
46+
| controller.tolerations | list | `[]` | Tolerations to allow the controller pod to be scheduled to nodes with taints. |
47+
| fullnameOverride | string | `""` | Overrides the chart's computed fullname. |
48+
| imagePullPolicy | string | `"IfNotPresent"` | Image pull policy for Docker images. |
49+
| imagePullSecrets | list | `[]` | Image pull secrets for Docker images. |
50+
| nameOverride | string | `""` | Overrides the chart's name. |
51+
| webhook.affinity | object | `{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"key":"karpenter.sh/provisioner-name","operator":"DoesNotExist"}]}}}` | Affinity rules for scheduling the webhook pod. |
52+
| webhook.env | list | `[]` | Additional environment variables for the webhook pod. |
53+
| webhook.hostNetwork | bool | `false` | Bind the webhook pod to the host network. This is required when using a custom CNI. |
54+
| webhook.image | string | `"public.ecr.aws/karpenter/webhook:v0.5.4@sha256:fd7dd0a3e155cb08a1c1def31258c654ac6c61b2fa8d8d25b7483688664c7de2"` | Webhook image. |
55+
| webhook.nodeSelector | object | `{"kubernetes.io/os":"linux"}` | Node selectors to schedule the webhook pod to nodes with labels. |
56+
| webhook.podAnnotations | object | `{}` | Additional annotations for the webhook pod. |
57+
| webhook.podLabels | object | `{}` | Additional labels for the webhook pod. |
58+
| webhook.podSecurityContext | object | `{"fsGroup":1000}` | SecurityContext for the webhook pod. |
59+
| webhook.port | int | `8443` | The container port to use for the webhook. |
60+
| webhook.priorityClassName | string | `"system-cluster-critical"` | PriorityClass name for the webhook pod. |
61+
| webhook.replicas | int | `1` | Number of replicas for the webhook pod. |
62+
| webhook.resources | object | `{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}}` | Resources for the webhook pod. |
63+
| webhook.securityContext | object | `{}` | SecurityContext for the webhook containers. |
64+
| webhook.serviceAccount.annotations | object | `{}` | Additional annotations for the webhook ServiceAccount. |
65+
| webhook.serviceAccount.create | bool | `true` | Specifies whether a ServiceAccount should be created for the webhook. |
66+
| webhook.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. |
67+
| webhook.strategy | object | `{"type":"Recreate"}` | Strategy for updating the webhook pod. |
68+
| webhook.terminationGracePeriodSeconds | string | `nil` | Override the default termination grace period for the webhook pod. |
69+
| webhook.tolerations | list | `[]` | Tolerations to allow the webhook pod to be scheduled to nodes with taints. |
5570

5671
----------------------------------------------
57-
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)
72+
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)

charts/karpenter/README.md.gotmpl

+3-3
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" . }} \
14+
--create-namespace --version {{ template "chart.version" . }} \
1515
--set controller.clusterName=${CLUSTER_NAME} \
1616
--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
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

+22-34
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,45 @@
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
38+
{{ include "karpenter.selectorLabels" . }}
4039
app.kubernetes.io/part-of: {{ template "karpenter.name" . }}
41-
{{- include "karpenter.selectorLabels" . }}
42-
{{- if .Chart.Version }}
43-
app.kubernetes.io/version: {{ .Chart.Version | quote }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4442
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
4544
{{- if .Values.additionalLabels }}
4645
{{ toYaml .Values.additionalLabels }}
4746
{{- end }}
@@ -50,18 +49,7 @@ app.kubernetes.io/version: {{ .Chart.Version | quote }}
5049
{{/*
5150
Selector labels
5251
*/}}
53-
{{- define "karpenter.selectorLabels" }}
52+
{{- define "karpenter.selectorLabels" -}}
5453
app.kubernetes.io/name: {{ include "karpenter.name" . }}
5554
app.kubernetes.io/instance: {{ .Release.Name }}
5655
{{- end }}
57-
58-
{{/*
59-
Create the name of the service account to use
60-
*/}}
61-
{{- 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 -}}

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: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{/*
2+
Fullname
3+
*/}}
4+
{{- define "karpenter.controllerFullname" -}}
5+
{{ include "karpenter.fullname" . }}-controller
6+
{{- end }}
7+
8+
{{/*
9+
Common labels
10+
*/}}
11+
{{- define "karpenter.controllerLabels" -}}
12+
{{ include "karpenter.labels" . }}
13+
app.kubernetes.io/component: controller
14+
{{- end }}
15+
16+
{{/*
17+
Selector labels
18+
*/}}
19+
{{- define "karpenter.controllerSelectorLabels" -}}
20+
{{ include "karpenter.selectorLabels" . }}
21+
app.kubernetes.io/component: controller
22+
{{- end }}
23+
24+
{{/*
25+
Create the name of the service account to use
26+
*/}}
27+
{{- define "karpenter.controllerServiceAccountName" -}}
28+
{{- if .Values.controller.serviceAccount.create -}}
29+
{{- default (printf "%s-controller" (include "karpenter.fullname" .)) .Values.controller.serviceAccount.name }}
30+
{{- else -}}
31+
{{- default "default" .Values.controller.serviceAccount.name }}
32+
{{- end -}}
33+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ include "karpenter.controllerFullname" . }}
5+
labels:
6+
{{- include "karpenter.controllerLabels" . | 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"]
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.controllerFullname" . }}
5+
labels:
6+
{{- include "karpenter.controllerLabels" . | nindent 4 }}
7+
roleRef:
8+
apiGroup: rbac.authorization.k8s.io
9+
kind: ClusterRole
10+
name: {{ include "karpenter.controllerFullname" . }}
11+
subjects:
12+
- kind: ServiceAccount
13+
name: {{ template "karpenter.controllerServiceAccountName" . }}
14+
namespace: {{ .Release.Namespace }}

0 commit comments

Comments
 (0)