Skip to content

Commit 1f04bf0

Browse files
author
mark.lynch
committed
1 parent 28e2a98 commit 1f04bf0

File tree

12 files changed

+325
-0
lines changed

12 files changed

+325
-0
lines changed
Lines changed: 23 additions & 0 deletions
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/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: node-specific-sizing
3+
description: A Helm chart for Kubernetes
4+
type: application
5+
version: 0.1.0
6+
appVersion: "1.16.0"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "node-specific-sizing.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "node-specific-sizing.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 }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "node-specific-sizing.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "node-specific-sizing.labels" -}}
37+
helm.sh/chart: {{ include "node-specific-sizing.chart" . }}
38+
{{ include "node-specific-sizing.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "node-specific-sizing.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "node-specific-sizing.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "node-specific-sizing.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "node-specific-sizing.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
66+
*/}}
67+
{{- define "node-specific-sizing.namespace" -}}
68+
{{- if .Values.namespaceOverride }}
69+
{{- .Values.namespaceOverride }}
70+
{{- else }}
71+
{{- .Release.Namespace }}
72+
{{- end }}
73+
{{- 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 }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- define "node-specific-sizing.pod" -}}
2+
serviceAccountName: {{ include "node-specific-sizing.serviceAccountName" . }}
3+
terminationGracePeriodSeconds: 10
4+
containers:
5+
- name: {{ .Chart.Name }}
6+
image: {{ .Values.image.registry }}/{{ .Values.image.tag }}@sha256:{{ .Values.image.sha256 }}
7+
imagePullPolicy: {{ .Values.image.pullPolicy }}
8+
env:
9+
- name: POD_NAMESPACE
10+
valueFrom:
11+
fieldRef:
12+
fieldPath: metadata.namespace
13+
volumeMounts:
14+
- mountPath: /tmp/k8s-webhook-server/serving-certs
15+
name: cert
16+
readOnly: true
17+
securityContext:
18+
runAsNonRoot: true
19+
volumes:
20+
- name: cert
21+
secret:
22+
defaultMode: 420
23+
secretName: node-specific-sizing-cert
24+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if and .Values.rbac.create (or (not .Values.rbac.namespaced) .Values.rbac.extraClusterRoleRules) (not .Values.rbac.useExistingClusterRole) }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
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" . }}
12+
rules:
13+
- apiGroups:
14+
- ""
15+
resources:
16+
- nodes
17+
verbs:
18+
- get
19+
- list
20+
- watch
21+
{{- with .Values.rbac.extraClusterRoleRules }}
22+
{{- toYaml . | nindent 2 }}
23+
{{- end}}
24+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if and .Values.rbac.create (or (not .Values.rbac.namespaced) .Values.rbac.extraClusterRoleRules) }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
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 }}
12+
roleRef:
13+
apiGroup: rbac.authorization.k8s.io
14+
kind: ClusterRole
15+
{{- if .Values.rbac.useExistingClusterRole }}
16+
name: {{ .Values.rbac.useExistingClusterRole }}
17+
{{- else }}
18+
name: {{ include "node-specific-sizing.fullname" . }}
19+
{{- end }}
20+
subjects:
21+
- kind: ServiceAccount
22+
name: {{ include "node-specific-sizing.serviceAccountName" . }}
23+
namespace: {{ include "node-specific-sizing.namespace" . }}
24+
{{- end }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "node-specific-sizing.fullname" . }}
5+
labels:
6+
{{- include "node-specific-sizing.labels" . | nindent 4 }}
7+
{{- if .Values.deployment.annotations }}
8+
annotations:
9+
{{- toYaml .Values.deployment.annotations | nindent 4 }}
10+
spec:
11+
replicas: {{ .Values.deployment.replicas }}
12+
selector:
13+
matchLabels:
14+
app: {{- include "node-specific-sizing.selectorLabels" . | nindent 6 }}
15+
template:
16+
metadata:
17+
labels:
18+
{{- include "node-specific-sizing.labels" . | nindent 4 }}
19+
spec:
20+
{{- include "node-specific-sizing.pod" . | nindent 6 }}
21+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
kind: MutatingWebhookConfiguration
2+
apiVersion: admissionregistration.k8s.io/v1
3+
metadata:
4+
name: {{ include "node-specific-sizing.fullname" . }}
5+
annotations:
6+
cert-manager.io/inject-ca-from: kube-system/{{ include "node-specific-sizing.fullname" . }}
7+
webhooks:
8+
- name: {{ include "node-specific-sizing.fullname" . }}.svc.cluster.local
9+
objectSelector:
10+
matchLabels:
11+
node-specific-sizing.manomano.tech/enabled: "true"
12+
admissionReviewVersions: [ "v1" ]
13+
sideEffects: None
14+
failurePolicy: Ignore
15+
timeoutSeconds: 1
16+
clientConfig:
17+
service:
18+
namespace: kube-system
19+
name: {{ include "node-specific-sizing.fullname" . }}
20+
path: /mutate
21+
rules:
22+
- apiGroups: [""]
23+
apiVersions: ["v1"]
24+
resources: ["pods"]
25+
operations: ["CREATE"]
26+
scope: Namespaced
27+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- if .Values.service.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "node-specific-sizing.fullname" . }}
6+
namespace: {{ include "node-specific-sizing.namespace" . }}
7+
labels:
8+
{{- include "node-specific-sizing.labels" . | nindent 4 }}
9+
spec:
10+
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
11+
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 }}
30+
ports:
31+
- port: {{ .Values.service.port }}
32+
targetPort: {{ .Values.service.targetPort }}
33+
protocol: TCP
34+
name: {{ .Values.service.portName }}
35+
selector:
36+
{{- include "node-specific-sizing.selectorLabels" . | nindent 4 }}
37+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
automountServiceAccountToken: {{ .Values.serviceAccount.autoMount }}
5+
metadata:
6+
name: {{ include "node-specific-sizing.serviceAccountName" . }}
7+
labels:
8+
{{- include "node-specific-sizing.labels" . | nindent 4 }}
9+
{{- with .Values.serviceAccount.labels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- with .Values.serviceAccount.annotations }}
13+
annotations:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
{{- end }}

0 commit comments

Comments
 (0)