Skip to content

feat: create helm chart for zarf-agent #3678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/zarf-agent/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
description: Zarf agent
name: zarf-agent
version: 0.51.0

maintainers:
- name: The Zarf Authors
url: https://zarf.dev
12 changes: 12 additions & 0 deletions packages/zarf-agent/chart/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Values.clusterRole.name }}
rules:
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
12 changes: 12 additions & 0 deletions packages/zarf-agent/chart/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Values.clusterRoleBinding.name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Values.clusterRole.name }}
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount.name }}
namespace: {{ .Release.Namespace }}
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent-hook
namespace: zarf
name: {{ .Values.deployment.name }}
namespace: {{ .Release.Namespace }}
labels:
app: agent-hook
spec:
replicas: 2
replicas: {{ .Values.deployment.replicaCount }}
selector:
matchLabels:
app: agent-hook
template:
metadata:
labels:
app: agent-hook
# Don't mutate this pod, that would be sad times
zarf.dev/agent: ignore
spec:
imagePullSecrets:
- name: private-registry
- name: {{ .Values.image.pullSecret }}
priorityClassName: system-node-critical
serviceAccountName: zarf
# Security context to comply with restricted PSS
serviceAccountName: {{ .Values.serviceAccount.name }}
securityContext:
runAsUser: 65532
fsGroup: 65532
runAsGroup: 65532
seccompProfile:
type: "RuntimeDefault"
affinity: {{- toYaml .Values.affinity | nindent 8 }}
tolerations: {{- toYaml .Values.tolerations | nindent 8 }}
containers:
- name: server
image: "###ZARF_REGISTRY###/###ZARF_CONST_AGENT_IMAGE###:###ZARF_CONST_AGENT_IMAGE_TAG###"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
Expand All @@ -47,25 +47,23 @@ spec:
drop: ["ALL"]
resources:
requests:
memory: "32Mi"
cpu: "100m"
memory: {{ .Values.resources.requests.memory }}
cpu: {{ .Values.resources.requests.cpu }}
limits:
memory: "128Mi"
cpu: "500m"
memory: {{ .Values.resources.limits.memory }}
cpu: {{ .Values.resources.limits.cpu }}
volumeMounts:
- name: tls-certs
mountPath: /etc/certs
readOnly: true
# Required for OpenShift to mount k9s vendored directories
- name: config
mountPath: /.config
- name: xdg
mountPath: /etc/xdg
volumes:
- name: tls-certs
secret:
secretName: agent-hook-tls
# Required for OpenShift to mount k9s vendored directories
secretName: {{ .Values.secret.name }}
- name: config
emptyDir: {}
- name: xdg
Expand Down
12 changes: 12 additions & 0 deletions packages/zarf-agent/chart/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Values.role.name }}
namespace: {{ .Release.Namespace }}
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
13 changes: 13 additions & 0 deletions packages/zarf-agent/chart/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Values.roleBinding.name }}
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ .Values.role.name }}
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount.name }}
namespace: {{ .Release.Namespace }}
9 changes: 9 additions & 0 deletions packages/zarf-agent/chart/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.secret.name }}
namespace: {{ .Release.Namespace }}
type: kubernetes.io/tls
data:
tls.crt: {{ .Values.secret.tlsCrt | quote }}
tls.key: {{ .Values.secret.tlsKey | quote }}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
kind: Service
metadata:
name: agent-hook
namespace: zarf
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
spec:
selector:
app: agent-hook
Expand Down
5 changes: 5 additions & 0 deletions packages/zarf-agent/chart/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.serviceAccount.name }}
namespace: {{ .Release.Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ webhooks:
operator: DoesNotExist
clientConfig:
service:
name: agent-hook
namespace: zarf
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
path: "/mutate/pod"
caBundle: "###ZARF_AGENT_CA###"
rules:
Expand Down Expand Up @@ -73,8 +73,8 @@ webhooks:
- "ignore"
clientConfig:
service:
name: agent-hook
namespace: zarf
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
path: "/mutate/flux-ocirepository"
caBundle: "###ZARF_AGENT_CA###"
rules:
Expand Down Expand Up @@ -115,8 +115,8 @@ webhooks:
- "ignore"
clientConfig:
service:
name: agent-hook
namespace: zarf
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
path: "/mutate/flux-helmrepository"
caBundle: "###ZARF_AGENT_CA###"
rules:
Expand Down Expand Up @@ -159,8 +159,8 @@ webhooks:
- "ignore"
clientConfig:
service:
name: agent-hook
namespace: zarf
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
path: "/mutate/flux-gitrepository"
caBundle: "###ZARF_AGENT_CA###"
rules:
Expand Down Expand Up @@ -203,8 +203,8 @@ webhooks:
- "ignore"
clientConfig:
service:
name: agent-hook
namespace: zarf
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
path: "/mutate/argocd-application"
caBundle: "###ZARF_AGENT_CA###"
rules:
Expand Down Expand Up @@ -249,8 +249,8 @@ webhooks:
- repository
clientConfig:
service:
name: agent-hook
namespace: zarf
name: {{ .Values.service.name }}
namespace: {{ .Release.Namespace }}
path: "/mutate/argocd-repository"
caBundle: "###ZARF_AGENT_CA###"
rules:
Expand Down
42 changes: 42 additions & 0 deletions packages/zarf-agent/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
serviceAccount:
name: zarf

clusterRole:
name: service-viewer

clusterRoleBinding:
name: service-viewer-binding

role:
name: zarf-agent

roleBinding:
name: zarf-agent-binding

secret:
name: agent-hook-tls
tlsCrt: "###ZARF_AGENT_CRT###"
tlsKey: "###ZARF_AGENT_KEY###"

service:
name: agent-hook

deployment:
name: agent-hook
replicaCount: 2

image:
repository: "###ZARF_REGISTRY###/###ZARF_CONST_AGENT_IMAGE###"
tag: "###ZARF_CONST_AGENT_IMAGE_TAG###"
pullSecret: private-registry

resources:
requests:
memory: "32Mi"
cpu: "100m"
limits:
memory: "128Mi"
cpu: "500m"

affinity: {}
tolerations: []
12 changes: 0 additions & 12 deletions packages/zarf-agent/manifests/clusterrole.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions packages/zarf-agent/manifests/clusterrolebinding.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions packages/zarf-agent/manifests/role.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions packages/zarf-agent/manifests/rolebinding.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions packages/zarf-agent/manifests/secret.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions packages/zarf-agent/manifests/serviceaccount.yaml

This file was deleted.

15 changes: 4 additions & 11 deletions packages/zarf-agent/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ components:
required: true
images:
- "###ZARF_PKG_TMPL_AGENT_IMAGE_DOMAIN######ZARF_PKG_TMPL_AGENT_IMAGE###:###ZARF_PKG_TMPL_AGENT_IMAGE_TAG###"
manifests:
charts:
- name: zarf-agent
releaseName: zarf-agent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a hack - but if we modify this - given that the raw chart name has not changed since creation and that the hasher logic is quite old as well link then we should have quite substantial backwards compatibility AND it should function now.

Suggested change
releaseName: zarf-agent
releaseName: zarf-d2db14ef40305397791454e883b26fc94ad9615d

I say we start here to begin - test other E2E functionality while continuing to get feedback on this as the solution.

localPath: chart
version: 0.51.0
namespace: zarf
files:
- manifests/service.yaml
- manifests/secret.yaml
- manifests/deployment.yaml
- manifests/webhook.yaml
- manifests/role.yaml
- manifests/rolebinding.yaml
- manifests/clusterrole.yaml
- manifests/clusterrolebinding.yaml
- manifests/serviceaccount.yaml
actions:
onCreate:
before:
Expand Down