Skip to content

Commit 85ced0d

Browse files
fix(installer): harden cozy-system-labeler hook and add hosted variant
Address review feedback on PR #2508: - Pin alpine/k8s by digest (matches operator image pinning style). - Add resources requests/limits and a minimal securityContext to the labeler Job: capabilities drop ALL, allowPrivilegeEscalation: false, seccompProfile RuntimeDefault. - Include hook-failed in helm.sh/hook-delete-policy across all four hook resources so a failed install doesn't leave SA / ClusterRole / ClusterRoleBinding / Job objects behind. - Add explicit hosted variant case in the env block, mirroring the pattern in cozystack-operator.yaml. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 4527320 commit 85ced0d

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

‎packages/core/installer/templates/cozy-system-labels.yaml‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ metadata:
3131
annotations:
3232
helm.sh/hook: pre-install,pre-upgrade
3333
helm.sh/hook-weight: "-200"
34-
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
34+
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed
3535
---
3636
apiVersion: rbac.authorization.k8s.io/v1
3737
kind: ClusterRole
@@ -40,7 +40,7 @@ metadata:
4040
annotations:
4141
helm.sh/hook: pre-install,pre-upgrade
4242
helm.sh/hook-weight: "-180"
43-
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
43+
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed
4444
rules:
4545
- apiGroups: [""]
4646
resources: ["namespaces"]
@@ -54,7 +54,7 @@ metadata:
5454
annotations:
5555
helm.sh/hook: pre-install,pre-upgrade
5656
helm.sh/hook-weight: "-160"
57-
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
57+
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed
5858
subjects:
5959
- kind: ServiceAccount
6060
name: cozy-system-labeler
@@ -72,7 +72,7 @@ metadata:
7272
annotations:
7373
helm.sh/hook: pre-install,pre-upgrade
7474
helm.sh/hook-weight: "-100"
75-
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
75+
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed
7676
spec:
7777
backoffLimit: 6
7878
template:
@@ -93,10 +93,24 @@ spec:
9393
operator: "Exists"
9494
- key: "node.cloudprovider.kubernetes.io/uninitialized"
9595
operator: "Exists"
96+
securityContext:
97+
seccompProfile:
98+
type: RuntimeDefault
9699
containers:
97100
- name: kubectl
98-
image: alpine/k8s:1.32.0
101+
image: alpine/k8s:1.32.0@sha256:4c28b0f0c6accfa07fa449493ea936291e4ff1270500571d73f75bb406676c3b
99102
imagePullPolicy: IfNotPresent
103+
securityContext:
104+
allowPrivilegeEscalation: false
105+
capabilities:
106+
drop: ["ALL"]
107+
resources:
108+
requests:
109+
cpu: 10m
110+
memory: 32Mi
111+
limits:
112+
cpu: 100m
113+
memory: 128Mi
100114
{{- if eq .Values.cozystackOperator.variant "talos" }}
101115
env:
102116
# Talos KubePrism endpoint — same as cozystack-operator uses to reach
@@ -111,6 +125,9 @@ spec:
111125
value: {{ required "cozystack.apiServerHost is required in generic mode" .Values.cozystack.apiServerHost | quote }}
112126
- name: KUBERNETES_SERVICE_PORT
113127
value: {{ .Values.cozystack.apiServerPort | quote }}
128+
{{- else if eq .Values.cozystackOperator.variant "hosted" }}
129+
# Hosted: use in-cluster service account, no env override needed.
130+
env: []
114131
{{- end }}
115132
command:
116133
- kubectl

0 commit comments

Comments
 (0)