Skip to content

Commit 7d8688b

Browse files
committed
feat(helm): add various parameters
- common labels - pod selector labels - pod and container security context - container resources limits/requests Signed-off-by: Fatih Acar <[email protected]>
1 parent 37cebfd commit 7d8688b

File tree

8 files changed

+66
-8
lines changed

8 files changed

+66
-8
lines changed

helm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type: application
1414
# This is the chart version. This version number should be incremented each time you make changes
1515
# to the chart and its templates, including the app version.
1616
# Versions are expected to follow Semantic Versioning (https://semver.org/)
17-
version: 2.5.0
17+
version: 2.6.0
1818
# This is the version number of the application being deployed. This version number should be
1919
# incremented each time you make changes to the application. Versions are not expected to
2020
# follow Semantic Versioning. They should reflect the version the application is using.

helm/templates/_helpers.tpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ helm.sh/chart: {{ include "infrahub-helm.chart" . }}
4040
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4141
{{- end }}
4242
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- if gt (len .Values.global.commonLabels) 0 }}
44+
{{ .Values.global.commonLabels | toYaml }}
45+
{{- end }}
46+
{{- end }}
47+
48+
{{/*
49+
Common annotations
50+
*/}}
51+
{{- define "infrahub-helm.annotations" -}}
52+
{{- if gt (len .Values.global.commonAnnotations) 0 -}}
53+
{{ .Values.global.commonAnnotations | toYaml }}
54+
{{- end }}
4355
{{- end }}
4456

4557
{{/*
@@ -48,6 +60,9 @@ Selector labels
4860
{{- define "infrahub-helm.selectorLabels" -}}
4961
app.kubernetes.io/name: {{ include "infrahub-helm.name" . }}
5062
app.kubernetes.io/instance: {{ .Release.Name }}
63+
{{- if gt (len .Values.global.podLabels) 0 }}
64+
{{ .Values.global.podLabels | toYaml }}
65+
{{- end }}
5166
{{- end }}
5267

5368
{{/*

helm/templates/infrahub-demo-data-job.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ apiVersion: batch/v1
44
kind: Job
55
metadata:
66
name: {{ include "infrahub-helm.fullname" . }}-infrahub-demo-data-job
7+
namespace: "{{ .Release.Namespace }}"
78
labels:
89
{{- include "infrahub-helm.labels" . | nindent 4 }}
10+
annotations:
11+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
912
spec:
1013
backoffLimit: {{ .Values.infrahubDemoData.backoffLimit }}
1114
template:

helm/templates/infrahub-git.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ apiVersion: apps/v1
33
kind: Deployment
44
metadata:
55
name: {{ include "infrahub-helm.fullname" . }}-infrahub-git
6+
namespace: "{{ .Release.Namespace }}"
67
labels:
78
service: infrahub-git
89
{{- include "infrahub-helm.labels" . | nindent 4 }}
10+
annotations:
11+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
912
spec:
1013
replicas: {{ .Values.infrahubGit.replicas | default 1 }}
1114
selector:
@@ -27,6 +30,9 @@ spec:
2730
{{- with .Values.infrahubGit.runtimeClassName }}
2831
runtimeClassName: {{ . }}
2932
{{- end }}
33+
{{- with .Values.infrahubGit.podSecurityContext }}
34+
securityContext: {{- toYaml . | nindent 8 }}
35+
{{- end }}
3036
containers:
3137
- args: {{- toYaml .Values.infrahubGit.infrahubGit.args | nindent 12 }}
3238
env:
@@ -43,7 +49,12 @@ spec:
4349
image: {{ default .Values.global.imageRegistry .Values.infrahubGit.infrahubGit.imageRegistry }}/{{ .Values.global.infrahubRepository }}:{{ .Values.global.infrahubTag | default .Chart.AppVersion }}
4450
imagePullPolicy: {{ default .Values.global.imagePullPolicy .Values.infrahubGit.infrahubGit.imagePullPolicy }}
4551
name: infrahub-git
46-
resources: {}
52+
{{- with .Values.infrahubGit.resources }}
53+
resources: {{- toYaml . | nindent 12 }}
54+
{{- end }}
55+
{{- with .Values.infrahubGit.infrahubGit.securityContext }}
56+
securityContext: {{- toYaml . | nindent 12 }}
57+
{{- end }}
4758
tty: true
4859
volumeMounts:
4960
- name: git-data
@@ -65,9 +76,12 @@ apiVersion: v1
6576
kind: PersistentVolumeClaim
6677
metadata:
6778
name: {{ include "infrahub-helm.fullname" . }}-git-data
79+
namespace: "{{ .Release.Namespace }}"
6880
labels:
6981
service: git-data
7082
{{- include "infrahub-helm.labels" . | nindent 4 }}
83+
annotations:
84+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
7185
spec:
7286
accessModes:
7387
- {{ .Values.infrahubGit.persistence.accessMode }}

helm/templates/infrahub-server-db-init-job.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ apiVersion: batch/v1
44
kind: Job
55
metadata:
66
name: {{ include "infrahub-helm.fullname" . }}-infrahub-server-db-init-job
7+
namespace: "{{ .Release.Namespace }}"
78
labels:
89
{{- include "infrahub-helm.labels" . | nindent 4 }}
10+
annotations:
11+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
912
spec:
1013
backoffLimit: {{ .Values.infrahubServerDbInitJob.backoffLimit }}
1114
template:

helm/templates/infrahub-server-ingress.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ apiVersion: networking.k8s.io/v1
44
kind: Ingress
55
metadata:
66
name: {{ include "infrahub-helm.fullname" . }}-ingress
7+
namespace: "{{ .Release.Namespace }}"
78
labels:
8-
{{- include "infrahub-helm.labels" . | nindent 4 }}
9-
{{- with .Values.infrahubServer.ingress.annotations }}
9+
{{- include "infrahub-helm.labels" . | nindent 4 }}
1010
annotations:
11-
{{- range $key, $value := . }}
12-
{{ $key }}: {{ $value | quote }}
13-
{{- end }}
11+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
12+
{{- with .Values.infrahubServer.ingress.annotations }}
13+
{{- . | toYaml | nindent 4 }}
1414
{{- end }}
1515
spec:
1616
{{- with .Values.infrahubServer.ingress.ingressClassName }}

helm/templates/infrahub-server.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ apiVersion: apps/v1
33
kind: Deployment
44
metadata:
55
name: {{ include "infrahub-helm.fullname" . }}-infrahub-server
6+
namespace: "{{ .Release.Namespace }}"
67
labels:
78
service: infrahub-server
89
{{- include "infrahub-helm.labels" . | nindent 4 }}
10+
annotations:
11+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
912
spec:
1013
replicas: {{ .Values.infrahubServer.replicas | default 1 }}
1114
selector:
@@ -27,6 +30,9 @@ spec:
2730
{{- with .Values.infrahubServer.runtimeClassName }}
2831
runtimeClassName: {{ . }}
2932
{{- end }}
33+
{{- with .Values.infrahubServer.podSecurityContext }}
34+
securityContext: {{- toYaml . | nindent 8 }}
35+
{{- end }}
3036
containers:
3137
- args: {{- toYaml .Values.infrahubServer.infrahubServer.args | nindent 12 }}
3238
env:
@@ -61,7 +67,12 @@ spec:
6167
name: {{ quote .name }}
6268
{{- end }}
6369
{{- end }}
64-
resources: {}
70+
{{- with .Values.infrahubServer.resources }}
71+
resources: {{- toYaml . | nindent 12 }}
72+
{{- end }}
73+
{{- with .Values.infrahubServer.infrahubServer.securityContext }}
74+
securityContext: {{- toYaml . | nindent 12 }}
75+
{{- end }}
6576
tty: true
6677
volumeMounts:
6778
- mountPath: /opt/infrahub/storage
@@ -82,9 +93,12 @@ apiVersion: v1
8293
kind: Service
8394
metadata:
8495
name: {{ include "infrahub-helm.fullname" . }}-infrahub-server
96+
namespace: "{{ .Release.Namespace }}"
8597
labels:
8698
service: infrahub-server
8799
{{- include "infrahub-helm.labels" . | nindent 4 }}
100+
annotations:
101+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
88102
spec:
89103
type: {{ .Values.infrahubServer.type }}
90104
selector:
@@ -99,9 +113,12 @@ apiVersion: v1
99113
kind: PersistentVolumeClaim
100114
metadata:
101115
name: {{ include "infrahub-helm.fullname" . }}-infrahub-server-storage-data
116+
namespace: "{{ .Release.Namespace }}"
102117
labels:
103118
service: infrahub-server-storage-data
104119
{{- include "infrahub-helm.labels" . | nindent 4 }}
120+
annotations:
121+
{{- include "infrahub-helm.annotations" . | nindent 4 }}
105122
spec:
106123
accessModes:
107124
- {{ .Values.infrahubServer.persistence.accessMode }}

helm/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ global:
33
kubernetesClusterDomain: cluster.local
44
infrahubRepository: opsmill/infrahub
55
imagePullPolicy: IfNotPresent
6+
commonLabels: {}
7+
commonAnnotations: {}
8+
podLabels: {}
69

710
# ----------- Cache -----------
811
redis:
@@ -57,6 +60,7 @@ infrahubGit:
5760
size: 100Mi
5861
accessMode: ReadWriteMany
5962
storageClassName: nfs
63+
resources: {}
6064
infrahubGit:
6165
args:
6266
- infrahub
@@ -80,11 +84,13 @@ infrahubServer:
8084
ingress:
8185
enabled: true
8286
hostname: infrahub-cluster.local
87+
annotations:
8388
persistence:
8489
enabled: true
8590
size: 100Mi
8691
accessMode: ReadWriteMany
8792
storageClassName: nfs
93+
resources: {}
8894
infrahubServer:
8995
args:
9096
- gunicorn

0 commit comments

Comments
 (0)