Skip to content

Commit 0449286

Browse files
authored
feat(chart): migrate k8s deployments to Bitnami guidelines (#1183)
Signed-off-by: Miguel <[email protected]>
1 parent 3fca016 commit 0449286

20 files changed

+894
-397
lines changed

deployment/chainloop/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Chainloop is an open source software supply chain control plane, a
77

88
type: application
99
# Bump the patch (not minor, not major) version on each change in the Chart Source code
10-
version: 1.86.7
10+
version: 1.86.8
1111
# Do not update appVersion, this is handled automatically by the release process
1212
appVersion: v0.95.3
1313

deployment/chainloop/README.md

Lines changed: 167 additions & 198 deletions
Large diffs are not rendered by default.
1 Byte
Binary file not shown.

deployment/chainloop/templates/_helpers.tpl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,17 @@ Chainloop Controlplane Chart fullname
144144
Common labels
145145
*/}}
146146
{{- define "chainloop.controlplane.labels" -}}
147-
{{- include "common.labels.standard" . }}
147+
{{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" .) }}
148+
app.kubernetes.io/part-of: chainloop
149+
app.kubernetes.io/component: controlplane
150+
{{- end }}
151+
152+
-{{/*
153+
-Selector labels
154+
-*/}}
155+
{{- define "chainloop.controlplane.selectorLabels" -}}
156+
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.controlplane.podLabels .Values.commonLabels) "context" .) }}
157+
{{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" . ) }}
148158
app.kubernetes.io/part-of: chainloop
149159
app.kubernetes.io/component: controlplane
150160
{{- end }}
@@ -162,13 +172,6 @@ app.kubernetes.io/part-of: chainloop
162172
app.kubernetes.io/component: controlplane-migration
163173
{{- end }}
164174

165-
{{/*
166-
Selector labels
167-
*/}}
168-
{{- define "chainloop.controlplane.selectorLabels" -}}
169-
{{- include "common.labels.matchLabels" .}}
170-
app.kubernetes.io/component: controlplane
171-
{{- end }}
172175

173176
{{/*
174177
OIDC settings, will fallback to development settings if needed
@@ -355,17 +358,19 @@ Chainloop CAS Chart fullname
355358
Common labels
356359
*/}}
357360
{{- define "chainloop.cas.labels" -}}
358-
{{- include "common.labels.standard" . }}
361+
{{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" .) }}
359362
app.kubernetes.io/part-of: chainloop
360363
app.kubernetes.io/component: cas
361364
{{- end }}
362365

363-
{{/*
364-
Selector labels
365-
*/}}
366+
-{{/*
367+
-Selector labels
368+
-*/}}
366369
{{- define "chainloop.cas.selectorLabels" -}}
367-
{{- include "common.labels.matchLabels" .}}
370+
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.cas.podLabels .Values.commonLabels) "context" .) }}
371+
{{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" . ) }}
368372
app.kubernetes.io/component: cas
373+
app.kubernetes.io/part-of: chainloop
369374
{{- end }}
370375

371376
{{/*

deployment/chainloop/templates/cas/configmap.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ kind: ConfigMap
88
metadata:
99
name: {{ include "chainloop.cas.fullname" . }}
1010
namespace: {{ include "common.names.namespace" . | quote }}
11-
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12-
app.kubernetes.io/component: cas
11+
labels: {{ include "chainloop.cas.labels" . | nindent 4 }}
1312
{{- if .Values.commonAnnotations }}
1413
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1514
{{- end }}

deployment/chainloop/templates/cas/deployment.yaml

Lines changed: 92 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,90 @@ Copyright Chainloop, Inc. All Rights Reserved.
33
SPDX-License-Identifier: APACHE-2.0
44
*/}}
55

6-
apiVersion: apps/v1
6+
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
77
kind: Deployment
88
metadata:
99
name: {{ include "chainloop.cas.fullname" . }}
10-
labels:
11-
{{- include "chainloop.cas.labels" . | nindent 4 }}
10+
namespace: {{ include "common.names.namespace" . | quote }}
11+
labels: {{ include "chainloop.cas.labels" . | nindent 4 }}
12+
{{- if or .Values.cas.deploymentAnnotations .Values.commonAnnotations }}
13+
{{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.cas.deploymentAnnotations .Values.commonAnnotations) "context" .) }}
14+
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
15+
{{- end }}
1216
spec:
13-
{{- if not .Values.cas.autoscaling.enabled }}
17+
{{- if not .Values.cas.autoscaling.hpa.enabled }}
1418
replicas: {{ .Values.cas.replicaCount }}
1519
{{- end }}
20+
{{- if .Values.cas.updateStrategy }}
21+
strategy: {{- toYaml .Values.cas.updateStrategy | nindent 4 }}
22+
{{- end }}
1623
selector:
17-
matchLabels:
18-
{{- include "chainloop.cas.selectorLabels" . | nindent 6 }}
24+
matchLabels: {{ include "chainloop.cas.selectorLabels" . | nindent 6 }}
1925
template:
2026
metadata:
2127
annotations:
2228
checksum/config: {{ include (print $.Template.BasePath "/cas" "/configmap.yaml") . | sha256sum }}
2329
checksum/config-secret: {{ include (print $.Template.BasePath "/cas" "/secret-config.yaml") . | sha256sum }}
2430
checksum/public-key-secret: {{ include (print $.Template.BasePath "/cas" "/secret-jwt-public-key.yaml") . | sha256sum }}
25-
labels:
26-
{{- include "chainloop.cas.selectorLabels" . | nindent 8 }}
31+
labels: {{ include "chainloop.cas.labels" . | nindent 8 }}
2732
spec:
2833
{{- include "common.images.renderPullSecrets" (dict "images" (list .Values.cas.image) "context" $) | nindent 6 }}
2934
serviceAccountName: {{ include "chainloop.cas.serviceAccountName" . }}
30-
securityContext:
31-
{{- toYaml .Values.cas.podSecurityContext | nindent 8 }}
35+
automountServiceAccountToken: {{ .Values.cas.automountServiceAccountToken }}
36+
{{- if .Values.cas.hostAliases }}
37+
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.cas.hostAliases "context" $) | nindent 8 }}
38+
{{- end }}
39+
{{- if .Values.cas.affinity }}
40+
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.cas.affinity "context" $) | nindent 8 }}
41+
{{- else }}
42+
affinity:
43+
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.cas.podLabels .Values.commonLabels) "context" .) }}
44+
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.cas.podAffinityPreset "component" "cas" "customLabels" $podLabels "context" $) | nindent 10 }}
45+
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.cas.podAntiAffinityPreset "component" "cas" "customLabels" $podLabels "context" $) | nindent 10 }}
46+
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.cas.nodeAffinityPreset.type "key" .Values.cas.nodeAffinityPreset.key "values" .Values.cas.nodeAffinityPreset.values) | nindent 10 }}
47+
{{- end }}
48+
{{- if .Values.cas.nodeSelector }}
49+
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.cas.nodeSelector "context" $) | nindent 8 }}
50+
{{- end }}
51+
{{- if .Values.cas.tolerations }}
52+
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.cas.tolerations "context" .) | nindent 8 }}
53+
{{- end }}
54+
{{- if .Values.cas.priorityClassName }}
55+
priorityClassName: {{ .Values.cas.priorityClassName | quote }}
56+
{{- end }}
57+
{{- if .Values.cas.schedulerName }}
58+
schedulerName: {{ .Values.cas.schedulerName | quote }}
59+
{{- end }}
60+
{{- if .Values.cas.topologySpreadConstraints }}
61+
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.cas.topologySpreadConstraints "context" .) | nindent 8 }}
62+
{{- end }}
63+
{{- if .Values.cas.podSecurityContext.enabled }}
64+
securityContext: {{- omit .Values.cas.podSecurityContext "enabled" | toYaml | nindent 8 }}
65+
{{- end }}
66+
{{- if .Values.cas.terminationGracePeriodSeconds }}
67+
terminationGracePeriodSeconds: {{ .Values.cas.terminationGracePeriodSeconds }}
68+
{{- end }}
69+
initContainers:
70+
{{- if .Values.cas.initContainers }}
71+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.initContainers "context" $) | nindent 8 }}
72+
{{- end }}
3273
containers:
3374
- name: {{ .Chart.Name }}
34-
securityContext:
35-
{{- toYaml .Values.cas.securityContext | nindent 12 }}
75+
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.cas.containerSecurityContext "context" $) | nindent 12 }}
3676
image: {{ include "chainloop.cas.image" . }}
3777
imagePullPolicy: {{ .Values.cas.image.pullPolicy }}
3878
ports:
3979
- name: http
40-
containerPort: 8000
41-
protocol: TCP
42-
- name: grpc
43-
containerPort: 9000
44-
protocol: TCP
80+
containerPort: {{ .Values.cas.containerPorts.http }}
4581
- name: metrics
46-
containerPort: 5000
47-
protocol: TCP
82+
containerPort: {{ .Values.cas.containerPorts.metrics }}
83+
- name: grpc
84+
containerPort: {{ .Values.cas.containerPorts.grpc }}
85+
startupProbe:
86+
httpGet:
87+
path: /statusz
88+
port: http
89+
periodSeconds: 5
4890
livenessProbe:
4991
httpGet:
5092
path: /statusz
@@ -53,8 +95,27 @@ spec:
5395
httpGet:
5496
path: /statusz?readiness=1
5597
port: http
56-
resources:
57-
{{- toYaml .Values.cas.resources | nindent 12 }}
98+
{{- if .Values.cas.resources }}
99+
resources: {{- toYaml .Values.cas.resources | nindent 12 }}
100+
{{- else if ne .Values.cas.resourcesPreset "none" }}
101+
resources: {{- include "common.resources.preset" (dict "type" .Values.cas.resourcesPreset) | nindent 12 }}
102+
{{- end }}
103+
{{- if .Values.cas.lifecycleHooks }}
104+
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.cas.lifecycleHooks "context" $) | nindent 12 }}
105+
{{- end }}
106+
env:
107+
{{- if .Values.cas.extraEnvVars }}
108+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.extraEnvVars "context" $) | nindent 12 }}
109+
{{- end }}
110+
envFrom:
111+
{{- if .Values.cas.extraEnvVarsCM }}
112+
- configMapRef:
113+
name: {{ include "common.tplvalues.render" (dict "value" .Values.cas.extraEnvVarsCM "context" $) }}
114+
{{- end }}
115+
{{- if .Values.cas.extraEnvVarsSecret }}
116+
- secretRef:
117+
name: {{ include "common.tplvalues.render" (dict "value" .Values.cas.extraEnvVarsSecret "context" $) }}
118+
{{- end }}
58119
volumeMounts:
59120
- name: config
60121
mountPath: "/data/conf"
@@ -75,6 +136,12 @@ spec:
75136
mountPath: /etc/pki/tls/certs
76137
readOnly: true
77138
{{- end }}
139+
{{- if .Values.cas.extraVolumeMounts }}
140+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.extraVolumeMounts "context" $) | nindent 12 }}
141+
{{- end }}
142+
{{- if .Values.cas.sidecars }}
143+
{{- include "common.tplvalues.render" ( dict "value" .Values.cas.sidecars "context" $) | nindent 8 }}
144+
{{- end }}
78145
volumes:
79146
- name: config
80147
projected:
@@ -94,7 +161,7 @@ spec:
94161
{{- if eq "gcpSecretManager" .Values.secretsBackend.backend }}
95162
- name: gcp-secretmanager-serviceaccountkey
96163
secret:
97-
secretName: {{ include "chainloop.controlplane.fullname" . }}-gcp-secretmanager-serviceaccountkey
164+
secretName: {{ include "chainloop.cas.fullname" . }}-gcp-secretmanager-serviceaccountkey
98165
{{- end }}
99166
{{- if (not (empty .Values.cas.customCAs)) }}
100167
- name: custom-cas
@@ -103,3 +170,6 @@ spec:
103170
- secret:
104171
name: {{ include "chainloop.cas.fullname" . }}-custom-cas
105172
{{- end }}
173+
{{- if .Values.cas.extraVolumes }}
174+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.extraVolumes "context" $) | nindent 8 }}
175+
{{- end }}
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
11
{{- /*
2-
Copyright Chainloop, Inc. All Rights Reserved.
2+
Copyright Broadcom, Inc. All Rights Reserved.
33
SPDX-License-Identifier: APACHE-2.0
44
*/}}
55

6-
{{- if .Values.cas.autoscaling.enabled }}
7-
apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ ) }}
6+
{{- if .Values.cas.autoscaling.hpa.enabled }}
7+
apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ )}}
88
kind: HorizontalPodAutoscaler
99
metadata:
10-
name: {{ include "chainloop.cas.fullname" . }}
11-
labels:
12-
{{- include "chainloop.cas.labels" . | nindent 4 }}
10+
name: {{ include "common.names.fullname" . }}
11+
namespace: {{ include "common.names.namespace" . | quote }}
12+
labels: {{ include "chainloop.cas.labels" . | nindent 4 }}
13+
{{- if .Values.commonAnnotations }}
14+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
15+
{{- end }}
1316
spec:
1417
scaleTargetRef:
1518
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
1619
kind: Deployment
17-
name: {{ include "chainloop.cas.fullname" . }}
18-
minReplicas: {{ .Values.cas.autoscaling.minReplicas }}
19-
maxReplicas: {{ .Values.cas.autoscaling.maxReplicas }}
20+
name: {{ include "common.names.fullname" . }}
21+
minReplicas: {{ .Values.cas.autoscaling.hpa.minReplicas }}
22+
maxReplicas: {{ .Values.cas.autoscaling.hpa.maxReplicas }}
2023
metrics:
21-
{{- if .Values.cas.autoscaling.targetCPUUtilizationPercentage }}
24+
{{- if .Values.cas.autoscaling.hpa.targetMemory }}
2225
- type: Resource
2326
resource:
24-
name: cpu
27+
name: memory
2528
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
26-
targetAverageUtilization: {{ .Values.cas.autoscaling.targetCPUUtilizationPercentage }}
29+
targetAverageUtilization: {{ .Values.cas.autoscaling.hpa.targetMemory }}
2730
{{- else }}
2831
target:
2932
type: Utilization
30-
averageUtilization: {{ .Values.cas.autoscaling.targetCPUUtilizationPercentage }}
33+
averageUtilization: {{ .Values.worker.autoscaling.hpa.targetMemory }}
3134
{{- end }}
3235
{{- end }}
33-
{{- if .Values.cas.autoscaling.targetMemoryUtilizationPercentage }}
36+
{{- if .Values.cas.autoscaling.hpa.targetCPU }}
3437
- type: Resource
3538
resource:
36-
name: memory
39+
name: cpu
3740
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
38-
targetAverageUtilization: {{ .Values.cas.autoscaling.targetMemoryUtilizationPercentage }}
41+
targetAverageUtilization: {{ .Values.cas.autoscaling.hpa.targetCPU }}
3942
{{- else }}
4043
target:
4144
type: Utilization
42-
averageUtilization: {{ .Values.cas.autoscaling.targetMemoryUtilizationPercentage }}
45+
averageUtilization: {{ .Values.worker.autoscaling.hpa.targetCPU }}
4346
{{- end }}
4447
{{- end }}
45-
{{- end }}
48+
{{- end }}

deployment/chainloop/templates/cas/secret-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ kind: Secret
88
metadata:
99
name: {{ include "chainloop.cas.fullname" . }}
1010
namespace: {{ include "common.names.namespace" . | quote }}
11-
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12-
app.kubernetes.io/component: cas
11+
labels: {{ include "chainloop.cas.labels" . | nindent 4 }}
1312
{{- if .Values.commonAnnotations }}
1413
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1514
{{- end }}

deployment/chainloop/templates/cas/service-account.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ kind: ServiceAccount
99
metadata:
1010
name: {{ include "chainloop.cas.serviceAccountName" . }}
1111
namespace: {{ include "common.names.namespace" . | quote }}
12-
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
13-
app.kubernetes.io/component: cas
12+
labels: {{ include "chainloop.cas.labels" . | nindent 4 }}
1413
{{- if or .Values.cas.serviceAccount.annotations .Values.commonAnnotations }}
1514
{{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.cas.serviceAccount.annotations .Values.commonAnnotations) "context" .) }}
1615
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}

deployment/chainloop/templates/cas/service-grpc.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ kind: Service
88
metadata:
99
name: {{ include "chainloop.cas.fullname" . }}-api
1010
namespace: {{ include "common.names.namespace" . | quote }}
11-
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12-
app.kubernetes.io/component: cas
11+
labels: {{ include "chainloop.cas.labels" . | nindent 4 }}
1312
{{- if or .Values.cas.serviceAPI.annotations .Values.commonAnnotations }}
1413
{{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.cas.serviceAPI.annotations .Values.commonAnnotations) "context" .) }}
1514
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
@@ -50,6 +49,4 @@ spec:
5049
{{- if .Values.cas.serviceAPI.extraPorts }}
5150
{{- include "common.tplvalues.render" (dict "value" .Values.cas.serviceAPI.extraPorts "context" $) | nindent 4 }}
5251
{{- end }}
53-
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.cas.podLabels .Values.commonLabels) "context" .) | fromYaml }}
54-
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
55-
app.kubernetes.io/component: cas
52+
selector: {{ include "chainloop.cas.selectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)