Skip to content

Commit ab855cd

Browse files
author
mark.lynch
committed
helm chart stuff
1 parent 1f04bf0 commit ab855cd

19 files changed

+265
-187
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ build/_output
2020
bin/kustomize
2121
bin/node-specific-sizing
2222
deploy.yaml
23+
build.yaml
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
apiVersion: v2
22
name: node-specific-sizing
3-
description: A Helm chart for Kubernetes
3+
description: A Kubernetes controller that helps resize pods created by a DaemonSet depending on the amount of allocatable resources present on the node.
44
type: application
55
version: 0.1.0
6-
appVersion: "1.16.0"
6+
appVersion: "0.1.0"
7+
8+
dependencies:
9+
- name: cert-manager
10+
repository: https://charts.jetstack.io
11+
condition: certmanager.enabled
12+
alias: certmanager
13+
version: "v1.15.3"
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{/*
22
Expand the name of the chart.
33
*/}}
4-
{{- define "node-specific-sizing.name" -}}
4+
{{- define "chart.name" -}}
55
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
66
{{- end }}
77

@@ -10,7 +10,7 @@ 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
*/}}
13-
{{- define "node-specific-sizing.fullname" -}}
13+
{{- define "chart.fullname" -}}
1414
{{- if .Values.fullnameOverride }}
1515
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
1616
{{- else }}
@@ -23,19 +23,21 @@ If release name contains chart name it will be used as a full name.
2323
{{- end }}
2424
{{- end }}
2525

26+
2627
{{/*
2728
Create chart name and version as used by the chart label.
2829
*/}}
29-
{{- define "node-specific-sizing.chart" -}}
30+
{{- define "chart.chart" -}}
3031
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
3132
{{- end }}
3233

34+
3335
{{/*
3436
Common labels
3537
*/}}
36-
{{- define "node-specific-sizing.labels" -}}
37-
helm.sh/chart: {{ include "node-specific-sizing.chart" . }}
38-
{{ include "node-specific-sizing.selectorLabels" . }}
38+
{{- define "chart.labels" -}}
39+
helm.sh/chart: {{ include "chart.chart" . }}
40+
{{ include "chart.selectorLabels" . }}
3941
{{- if .Chart.AppVersion }}
4042
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4143
{{- end }}
@@ -45,17 +47,18 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
4547
{{/*
4648
Selector labels
4749
*/}}
48-
{{- define "node-specific-sizing.selectorLabels" -}}
49-
app.kubernetes.io/name: {{ include "node-specific-sizing.name" . }}
50+
{{- define "chart.selectorLabels" -}}
51+
app.kubernetes.io/name: {{ include "chart.name" . }}
5052
app.kubernetes.io/instance: {{ .Release.Name }}
53+
app.kubernetes.io/part-of: "node-specific-sizing"
5154
{{- end }}
5255

5356
{{/*
5457
Create the name of the service account to use
5558
*/}}
56-
{{- define "node-specific-sizing.serviceAccountName" -}}
59+
{{- define "chart.serviceAccountName" -}}
5760
{{- if .Values.serviceAccount.create }}
58-
{{- default (include "node-specific-sizing.fullname" .) .Values.serviceAccount.name }}
61+
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
5962
{{- else }}
6063
{{- default "default" .Values.serviceAccount.name }}
6164
{{- end }}
@@ -64,18 +67,10 @@ Create the name of the service account to use
6467
{{/*
6568
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
6669
*/}}
67-
{{- define "node-specific-sizing.namespace" -}}
70+
{{- define "chart.namespace" -}}
6871
{{- if .Values.namespaceOverride }}
6972
{{- .Values.namespaceOverride }}
7073
{{- else }}
7174
{{- .Release.Namespace }}
7275
{{- end }}
7376
{{- end }}
74-
75-
{{/*
76-
Selector labels
77-
*/}}
78-
{{- define "node-specific-sizing.selectorLabels" -}}
79-
app.kubernetes.io/name: {{ include "node-specific-sizing.name" . }}
80-
app.kubernetes.io/instance: {{ .Release.Name }}
81-
{{- end }}

charts/node-specific-sizing/templates/_pod.tpl

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
{{- if and .Values.rbac.create (or (not .Values.rbac.namespaced) .Values.rbac.extraClusterRoleRules) (not .Values.rbac.useExistingClusterRole) }}
21
apiVersion: rbac.authorization.k8s.io/v1
32
kind: ClusterRole
43
metadata:
5-
labels:
6-
{{ - include "node-specific-sizing.labels" . | nindent 4 }}
7-
{{- with .Values.annotations }}
8-
annotations:
9-
{{- toYaml . | nindent 4 }}
10-
{{- end }}
11-
name: {{ include "node-specific-sizing.fullname" . }}
4+
name: {{ include "chart.fullname" . }}-role
5+
labels:
6+
app.kubernetes.io/component: rbac
7+
{{- include "chart.labels" . | nindent 4 }}
128
rules:
139
- apiGroups:
1410
- ""
@@ -17,8 +13,4 @@ rules:
1713
verbs:
1814
- get
1915
- list
20-
- watch
21-
{{- with .Values.rbac.extraClusterRoleRules }}
22-
{{- toYaml . | nindent 2 }}
23-
{{- end}}
24-
{{- end }}
16+
- watch
Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
{{- if and .Values.rbac.create (or (not .Values.rbac.namespaced) .Values.rbac.extraClusterRoleRules) }}
21
apiVersion: rbac.authorization.k8s.io/v1
32
kind: ClusterRoleBinding
43
metadata:
5-
name: {{ include "node-specific-sizing.fullname" . }}
6-
labels:
7-
{{ - include "node-specific-sizing.labels" . | nindent 4 }}
8-
{{- with .Values.annotations }}
9-
annotations:
10-
{{- toYaml . | nindent 4 }}
11-
{{- end }}
4+
name: {{ include "chart.fullname" . }}-rolebinding
5+
labels:
6+
app.kubernetes.io/component: rbac
7+
{{- include "chart.labels" . | nindent 4 }}
128
roleRef:
139
apiGroup: rbac.authorization.k8s.io
1410
kind: ClusterRole
15-
{{- if .Values.rbac.useExistingClusterRole }}
16-
name: {{ .Values.rbac.useExistingClusterRole }}
17-
{{- else }}
18-
name: {{ include "node-specific-sizing.fullname" . }}
19-
{{- end }}
11+
name: {{ include "chart.name" . }}-role
2012
subjects:
2113
- kind: ServiceAccount
22-
name: {{ include "node-specific-sizing.serviceAccountName" . }}
23-
namespace: {{ include "node-specific-sizing.namespace" . }}
24-
{{- end }}
14+
name: {{ include "chart.name" . }}
15+
namespace: {{ include "chart.namespace" . }}
Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: {{ include "node-specific-sizing.fullname" . }}
4+
name: {{ include "chart.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
56
labels:
6-
{{- include "node-specific-sizing.labels" . | nindent 4 }}
7-
{{- if .Values.deployment.annotations }}
8-
annotations:
9-
{{- toYaml .Values.deployment.annotations | nindent 4 }}
7+
app.kubernetes.io/component: controller
8+
{{- include "chart.labels" . | nindent 4 }}
109
spec:
11-
replicas: {{ .Values.deployment.replicas }}
10+
replicas: {{ .Values.replicas }}
1211
selector:
1312
matchLabels:
14-
app: {{- include "node-specific-sizing.selectorLabels" . | nindent 6 }}
13+
app.kubernetes.io/component: controller
14+
{{- include "chart.selectorLabels" . | nindent 6 }}
1515
template:
1616
metadata:
1717
labels:
18-
{{- include "node-specific-sizing.labels" . | nindent 4 }}
18+
app.kubernetes.io/component: controller
19+
{{- include "chart.selectorLabels" . | nindent 8 }}
1920
spec:
20-
{{- include "node-specific-sizing.pod" . | nindent 6 }}
21-
21+
serviceAccountName: {{ include "chart.serviceAccountName" . }}
22+
terminationGracePeriodSeconds: 10
23+
containers:
24+
- name: {{ .Chart.Name }}
25+
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
26+
imagePullPolicy: {{ .Values.image.pullPolicy }}
27+
resources: {{- toYaml .Values.resources | nindent 10 }}
28+
env:
29+
- name: POD_NAMESPACE
30+
valueFrom:
31+
fieldRef:
32+
fieldPath: metadata.namespace
33+
volumeMounts:
34+
- mountPath: /tmp/k8s-webhook-server/serving-certs
35+
name: node-specific-sizing-serving-cert
36+
readOnly: true
37+
securityContext:
38+
runAsNonRoot: true
39+
volumes:
40+
- name: serving-certs
41+
secret:
42+
defaultMode: 420
43+
secretName: {{ include "chart.fullname" . }}-server-cert

charts/node-specific-sizing/templates/mutatingadmissionwebhook.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
kind: MutatingWebhookConfiguration
21
apiVersion: admissionregistration.k8s.io/v1
2+
kind: MutatingWebhookConfiguration
33
metadata:
4-
name: {{ include "node-specific-sizing.fullname" . }}
4+
name: {{ include "chart.fullname" . }}-mutating-webhook-configuration
55
annotations:
6-
cert-manager.io/inject-ca-from: kube-system/{{ include "node-specific-sizing.fullname" . }}
6+
cert-manager.io/inject-ca-from: '{{ .Release.Namespace }}/{{ include "chart.fullname" . }}-serving-cert'
7+
labels:
8+
{{- include "chart.labels" . | nindent 4 }}
79
webhooks:
8-
- name: {{ include "node-specific-sizing.fullname" . }}.svc.cluster.local
10+
- name: {{ include "chart.fullname" . }}.svc.cluster.local
911
objectSelector:
1012
matchLabels:
1113
node-specific-sizing.manomano.tech/enabled: "true"
@@ -15,8 +17,8 @@ webhooks:
1517
timeoutSeconds: 1
1618
clientConfig:
1719
service:
18-
namespace: kube-system
19-
name: {{ include "node-specific-sizing.fullname" . }}
20+
namespace: node-specific-sizing
21+
name: {{ include "chart.fullname" . }}
2022
path: /mutate
2123
rules:
2224
- apiGroups: [""]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Issuer
3+
metadata:
4+
name: {{ include "chart.fullname" . }}-selfsigned-issuer
5+
namespace: {{ .Release.Namespace }}
6+
annotations:
7+
{{- if .Values.certmanager.enabled }}
8+
helm.sh/hook: post-install,post-upgrade
9+
{{- else }}
10+
helm.sh/hook: pre-install,pre-upgrade
11+
{{- end }}
12+
helm.sh/hook-weight: "1"
13+
labels:
14+
{{- include "chart.labels" . | nindent 4 }}
15+
spec:
16+
selfSigned: {}
Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,17 @@
1-
{{- if .Values.service.enabled }}
21
apiVersion: v1
32
kind: Service
43
metadata:
5-
name: {{ include "node-specific-sizing.fullname" . }}
6-
namespace: {{ include "node-specific-sizing.namespace" . }}
4+
name: {{ include "chart.fullname" . }}-webhook-service
5+
namespace: {{ .Release.Namespace }}
76
labels:
8-
{{- include "node-specific-sizing.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: webhook
8+
{{- include "chart.labels" . | nindent 4 }}
99
spec:
10-
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
1110
type: ClusterIP
12-
{{- with .Values.service.clusterIP }}
13-
clusterIP: {{ . }}
14-
{{- end }}
15-
{{- else if eq .Values.service.type "LoadBalancer" }}
16-
type: LoadBalancer
17-
{{- with .Values.service.loadBalancerIP }}
18-
loadBalancerIP: {{ . }}
19-
{{- end }}
20-
{{- with .Values.service.loadBalancerClass }}
21-
loadBalancerClass: {{ . }}
22-
{{- end }}
23-
{{- with .Values.service.loadBalancerSourceRanges }}
24-
loadBalancerSourceRanges:
25-
{{- toYaml . | nindent 4 }}
26-
{{- end }}
27-
{{- else }}
28-
type: {{ .Values.service.type }}
29-
{{- end }}
11+
selector:
12+
{{- include "chart.selectorLabels" . | nindent 4 }}
3013
ports:
31-
- port: {{ .Values.service.port }}
32-
targetPort: {{ .Values.service.targetPort }}
14+
- port: {{ default "443" .Values.service.port }}
15+
targetPort: {{ default "8443" .Values.service.targetPort }}
3316
protocol: TCP
34-
name: {{ .Values.service.portName }}
35-
selector:
36-
{{- include "node-specific-sizing.selectorLabels" . | nindent 4 }}
37-
{{- end }}
17+
name: {{default (include "chart.fullname" .) .Values.service.portName }}

0 commit comments

Comments
 (0)