Add cilium chart

This commit is contained in:
Jonny Ervine
2024-07-15 18:18:16 +08:00
parent 9b2e417702
commit 221e0d5590
159 changed files with 37242 additions and 0 deletions
@@ -0,0 +1,73 @@
{{- define "clustermesh-apiserver-generate-certs.job.spec" }}
{{- $certValiditySecondsStr := printf "%ds" (mul .Values.clustermesh.apiserver.tls.auto.certValidityDuration 24 60 60) -}}
{{- $clustermeshServerSANs := concat (list "*.mesh.cilium.io" (printf "clustermesh-apiserver.%s.svc" .Release.Namespace))
.Values.clustermesh.apiserver.tls.server.extraDnsNames
.Values.clustermesh.apiserver.tls.server.extraIpAddresses
-}}
spec:
template:
metadata:
labels:
k8s-app: clustermesh-apiserver-generate-certs
{{- with .Values.clustermesh.apiserver.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: certgen
image: {{ include "cilium.image" .Values.certgen.image | quote }}
imagePullPolicy: {{ .Values.certgen.image.pullPolicy }}
command:
- "/usr/bin/cilium-certgen"
args:
- "--cilium-namespace={{ .Release.Namespace }}"
{{- if .Values.debug.enabled }}
- "--debug"
{{- end }}
- "--ca-generate"
- "--ca-reuse-secret"
{{- if and .Values.tls.ca.cert .Values.tls.ca.key }}
- "--ca-secret-name=cilium-ca"
{{- end }}
- "--clustermesh-apiserver-server-cert-generate"
- "--clustermesh-apiserver-server-cert-validity-duration={{ $certValiditySecondsStr }}"
- "--clustermesh-apiserver-server-cert-sans={{ join "," $clustermeshServerSANs }}"
- "--clustermesh-apiserver-admin-cert-generate"
- "--clustermesh-apiserver-admin-cert-validity-duration={{ $certValiditySecondsStr }}"
- "--clustermesh-apiserver-admin-cert-common-name={{ include "clustermesh-apiserver-generate-certs.admin-common-name" . }}"
{{- if .Values.externalWorkloads.enabled }}
- "--clustermesh-apiserver-client-cert-generate"
- "--clustermesh-apiserver-client-cert-validity-duration={{ $certValiditySecondsStr }}"
{{- end }}
{{- if .Values.clustermesh.useAPIServer }}
- "--clustermesh-apiserver-remote-cert-generate"
- "--clustermesh-apiserver-remote-cert-validity-duration={{ $certValiditySecondsStr }}"
- "--clustermesh-apiserver-remote-cert-common-name={{ include "clustermesh-apiserver-generate-certs.remote-common-name" . }}"
{{- end }}
{{- with .Values.certgen.extraVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 10 }}
{{- end }}
hostNetwork: true
{{- with .Values.certgen.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccount: {{ .Values.serviceAccounts.clustermeshcertgen.name | quote }}
serviceAccountName: {{ .Values.serviceAccounts.clustermeshcertgen.name | quote }}
automountServiceAccountToken: {{ .Values.serviceAccounts.clustermeshcertgen.automount }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: OnFailure
{{- with .Values.certgen.extraVolumes }}
volumes:
{{- toYaml . | nindent 6 }}
{{- end }}
affinity:
{{- with .Values.certgen.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
ttlSecondsAfterFinished: {{ .Values.certgen.ttlSecondsAfterFinished }}
{{- end }}
@@ -0,0 +1,19 @@
{{- if and (or .Values.externalWorkloads.enabled .Values.clustermesh.useAPIServer) .Values.clustermesh.apiserver.tls.auto.enabled (eq .Values.clustermesh.apiserver.tls.auto.method "cronJob") .Values.clustermesh.apiserver.tls.auto.schedule }}
apiVersion: {{ include "cronjob.apiVersion" . }}
kind: CronJob
metadata:
name: clustermesh-apiserver-generate-certs
namespace: {{ .Release.Namespace }}
{{- with .Values.clustermesh.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
k8s-app: clustermesh-apiserver-generate-certs
app.kubernetes.io/part-of: cilium
spec:
schedule: {{ .Values.clustermesh.apiserver.tls.auto.schedule | quote }}
concurrencyPolicy: Forbid
jobTemplate:
{{- include "clustermesh-apiserver-generate-certs.job.spec" . | nindent 4 }}
{{- end }}
@@ -0,0 +1,20 @@
{{- if and (or .Values.externalWorkloads.enabled .Values.clustermesh.useAPIServer) .Values.clustermesh.apiserver.tls.auto.enabled (eq .Values.clustermesh.apiserver.tls.auto.method "cronJob") }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: clustermesh-apiserver-generate-certs
namespace: {{ .Release.Namespace }}
labels:
k8s-app: clustermesh-apiserver-generate-certs
app.kubernetes.io/part-of: cilium
annotations:
"helm.sh/hook": post-install,post-upgrade
{{- with .Values.certgen.annotations.job }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.clustermesh.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{ include "clustermesh-apiserver-generate-certs.job.spec" . }}
{{- end }}
@@ -0,0 +1,40 @@
{{- if and (or .Values.externalWorkloads.enabled .Values.clustermesh.useAPIServer) .Values.clustermesh.apiserver.tls.auto.enabled (eq .Values.clustermesh.apiserver.tls.auto.method "cronJob") .Values.serviceAccounts.clustermeshcertgen.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: clustermesh-apiserver-generate-certs
namespace: {{ .Release.Namespace }}
{{- with .Values.clustermesh.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/part-of: cilium
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- cilium-ca
verbs:
- get
- update
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- clustermesh-apiserver-server-cert
- clustermesh-apiserver-admin-cert
- clustermesh-apiserver-remote-cert
- clustermesh-apiserver-client-cert
verbs:
- update
{{- end }}
@@ -0,0 +1,21 @@
{{- if and (or .Values.externalWorkloads.enabled .Values.clustermesh.useAPIServer) .Values.clustermesh.apiserver.tls.auto.enabled (eq .Values.clustermesh.apiserver.tls.auto.method "cronJob") .Values.serviceAccounts.clustermeshcertgen.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: clustermesh-apiserver-generate-certs
namespace: {{ .Release.Namespace }}
{{- with .Values.clustermesh.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/part-of: cilium
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: clustermesh-apiserver-generate-certs
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccounts.clustermeshcertgen.name | quote }}
namespace: {{ .Release.Namespace }}
{{- end }}
@@ -0,0 +1,16 @@
{{- if and (or .Values.externalWorkloads.enabled .Values.clustermesh.useAPIServer) .Values.clustermesh.apiserver.tls.auto.enabled (eq .Values.clustermesh.apiserver.tls.auto.method "cronJob") .Values.serviceAccounts.clustermeshcertgen.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.serviceAccounts.clustermeshcertgen.name | quote }}
namespace: {{ .Release.Namespace }}
{{- if or .Values.serviceAccounts.clustermeshcertgen.annotations .Values.clustermesh.annotations }}
annotations:
{{- with .Values.serviceAccounts.clustermeshcertgen.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.clustermesh.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}