Skip to content

Commit baf5f81

Browse files
authored
Merge pull request #89 from tolleiv/improve-chart
update chart to reflect current standards
2 parents f6b318f + 984b1eb commit baf5f81

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed

deployments/kubernetes-helm/templates/_helpers.tpl

+10
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,13 @@ app.kubernetes.io/name: {{ include "csp-collector.name" . }}
4848
app.kubernetes.io/instance: {{ .Release.Name }}
4949
{{- end -}}
5050

51+
{{/*
52+
Create the name of the service account to use
53+
*/}}
54+
{{- define "csp-collector.serviceAccountName" -}}
55+
{{- if .Values.serviceAccount.create }}
56+
{{- default (include "csp-collector.fullname" .) .Values.serviceAccount.name }}
57+
{{- else }}
58+
{{- default "default" .Values.serviceAccount.name }}
59+
{{- end }}
60+
{{- end }}

deployments/kubernetes-helm/templates/deployment.yaml

+16-1
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,35 @@ metadata:
66
{{- include "csp-collector.labels" . | nindent 4 }}
77
checksum/config: {{ include (print $.Template.BasePath "/configMap.yaml") . | sha256sum | trunc 63 }}
88
spec:
9+
{{- if not .Values.autoscaling.enabled }}
910
replicas: {{ .Values.replicaCount }}
11+
{{- end }}
1012
selector:
1113
matchLabels:
1214
{{- include "csp-collector.selectorLabels" . | nindent 6 }}
1315
template:
1416
metadata:
1517
annotations:
18+
{{- with .Values.podAnnotations }}
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
1621
checksum/config: {{ include (print $.Template.BasePath "/configMap.yaml") . | sha256sum | trunc 63 }}
1722
labels:
1823
{{- include "csp-collector.selectorLabels" . | nindent 8 }}
24+
{{- with .Values.podLabels }}
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
1927
spec:
28+
{{- with .Values.imagePullSecrets }}
29+
imagePullSecrets:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
serviceAccountName: {{ include "csp-collector.serviceAccountName" . }}
2033
containers:
2134
- name: {{ .Chart.Name }}
22-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
35+
securityContext:
36+
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
37+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
2338
imagePullPolicy: {{ .Values.image.pullPolicy }}
2439
volumeMounts:
2540
- name: config-volume
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "csp-collector.fullname" . }}
6+
labels:
7+
{{- include "csp-collector.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "csp-collector.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "csp-collector.serviceAccountName" . }}
6+
labels:
7+
{{- include "csp-collector.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}

deployments/kubernetes-helm/values.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ image:
99
tag: latest
1010
pullPolicy: Always
1111

12+
imagePullSecrets: []
13+
1214
service:
1315
type: ClusterIP
1416
port: 8080
@@ -36,6 +38,13 @@ ingress:
3638
# hosts:
3739
# - chart-example.local
3840

41+
autoscaling:
42+
enabled: false
43+
minReplicas: 1
44+
maxReplicas: 100
45+
targetCPUUtilizationPercentage: 80
46+
# targetMemoryUtilizationPercentage: 80
47+
3948
resources: {}
4049
# We usually recommend not to specify default resources and to leave this as a conscious
4150
# choice for the user. This also increases chances charts run on environments with little
@@ -53,3 +62,29 @@ nodeSelector: {}
5362
tolerations: []
5463

5564
affinity: {}
65+
66+
serviceAccount:
67+
# Specifies whether a service account should be created
68+
create: true
69+
# Automatically mount a ServiceAccount's API credentials?
70+
automount: true
71+
# Annotations to add to the service account
72+
annotations: {}
73+
# The name of the service account to use.
74+
# If not set and create is true, a name is generated using the fullname template
75+
name: ""
76+
77+
podAnnotations: {}
78+
podLabels: {}
79+
80+
containerSecurityContext: {}
81+
# capabilities:
82+
# drop:
83+
# - ALL
84+
# readOnlyRootFilesystem: true
85+
# runAsNonRoot: true
86+
# runAsUser: 1000
87+
88+
89+
securityContext: {}
90+
# fsGroup: 2000

0 commit comments

Comments
 (0)