diff --git a/charts/capsule/README.md b/charts/capsule/README.md index 12c6e92f..373f0025 100644 --- a/charts/capsule/README.md +++ b/charts/capsule/README.md @@ -94,7 +94,8 @@ Parameter | Description | Default `serviceMonitor.enabled` | Specify if a Service Monitor must be created. | `false` `serviceMonitor.serviceAccount.name` | Specify Service Account name for metrics scrape. | `capsule` `serviceMonitor.serviceAccount.namespace` | Specify Service Account namespace for metrics scrape. | `capsule-system` - +`customLabels` | Additional labels which will be added to all resources created by Capsule helm chart . | `{}` +`customAnnotations` | Additional annotations which will be added to all resources created by Capsule helm chart . | `{}` ## Created resources This Helm Chart cretes the following Kubernetes resources in the release namespace: diff --git a/charts/capsule/templates/_helpers.tpl b/charts/capsule/templates/_helpers.tpl index 2d1e7fee..010315ff 100644 --- a/charts/capsule/templates/_helpers.tpl +++ b/charts/capsule/templates/_helpers.tpl @@ -40,6 +40,9 @@ helm.sh/chart: {{ include "capsule.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.customLabels }} +{{ toYaml .Values.customLabels }} +{{- end }} {{- end }} {{/* @@ -50,6 +53,19 @@ app.kubernetes.io/name: {{ include "capsule.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} +{{/* +ServiceAccount annotations +*/}} +{{- define "capsule.serviceAccountAnnotations" -}} +{{- if .Values.serviceAccount.annotations }} +{{- toYaml .Values.serviceAccount.annotations }} +{{- end }} +{{- if .Values.customAnnotations }} +{{ toYaml .Values.customAnnotations }} +{{- end }} +{{- end }} + + {{/* Create the name of the service account to use */}} diff --git a/charts/capsule/templates/ca.yaml b/charts/capsule/templates/ca.yaml index 56dc794e..898da946 100644 --- a/charts/capsule/templates/ca.yaml +++ b/charts/capsule/templates/ca.yaml @@ -3,5 +3,9 @@ kind: Secret metadata: labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} name: {{ include "capsule.secretCaName" . }} data: diff --git a/charts/capsule/templates/certs.yaml b/charts/capsule/templates/certs.yaml index 8ed9d91b..2b8a9113 100644 --- a/charts/capsule/templates/certs.yaml +++ b/charts/capsule/templates/certs.yaml @@ -3,5 +3,9 @@ kind: Secret metadata: labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} name: {{ include "capsule.secretTlsName" . }} data: diff --git a/charts/capsule/templates/configuration-default.yaml b/charts/capsule/templates/configuration-default.yaml index a9614954..7506c24c 100644 --- a/charts/capsule/templates/configuration-default.yaml +++ b/charts/capsule/templates/configuration-default.yaml @@ -2,6 +2,12 @@ apiVersion: capsule.clastix.io/v1alpha1 kind: CapsuleConfiguration metadata: name: default + labels: + {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: forceTenantPrefix: {{ .Values.manager.options.forceTenantPrefix }} userGroups: diff --git a/charts/capsule/templates/deployment.yaml b/charts/capsule/templates/deployment.yaml index 75ac96ba..414a4d9a 100644 --- a/charts/capsule/templates/deployment.yaml +++ b/charts/capsule/templates/deployment.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "capsule.deploymentName" . }} labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: replicas: {{ .Values.replicaCount }} selector: @@ -11,12 +15,12 @@ spec: {{- include "capsule.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} + {{- with .Values.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} labels: - {{- include "capsule.selectorLabels" . | nindent 8 }} + {{- include "capsule.labels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/charts/capsule/templates/metrics-rbac.yaml b/charts/capsule/templates/metrics-rbac.yaml index 7b4c69bc..3e694358 100644 --- a/charts/capsule/templates/metrics-rbac.yaml +++ b/charts/capsule/templates/metrics-rbac.yaml @@ -4,9 +4,13 @@ kind: Role metadata: labels: {{- include "capsule.labels" . | nindent 4 }} - {{- if .Values.serviceMonitor.labels }} + {{- if .Values.serviceMonitor.labels }} {{- toYaml .Values.serviceMonitor.labels | nindent 4 }} - {{- end }} + {{- end }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} name: {{ include "capsule.fullname" . }}-metrics-role namespace: {{ .Values.serviceMonitor.namespace | default .Release.Namespace }} rules: diff --git a/charts/capsule/templates/metrics-service.yaml b/charts/capsule/templates/metrics-service.yaml index 5eabc07a..56db020a 100644 --- a/charts/capsule/templates/metrics-service.yaml +++ b/charts/capsule/templates/metrics-service.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "capsule.fullname" . }}-controller-manager-metrics-service labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: ports: - port: 8080 diff --git a/charts/capsule/templates/mutatingwebhookconfiguration.yaml b/charts/capsule/templates/mutatingwebhookconfiguration.yaml index 60dc4030..42f4f7bc 100644 --- a/charts/capsule/templates/mutatingwebhookconfiguration.yaml +++ b/charts/capsule/templates/mutatingwebhookconfiguration.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "capsule.fullname" . }}-mutating-webhook-configuration labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} webhooks: - admissionReviewVersions: - v1 diff --git a/charts/capsule/templates/podsecuritypolicy.yaml b/charts/capsule/templates/podsecuritypolicy.yaml index 6e511727..114d9302 100644 --- a/charts/capsule/templates/podsecuritypolicy.yaml +++ b/charts/capsule/templates/podsecuritypolicy.yaml @@ -5,6 +5,10 @@ metadata: name: {{ include "capsule.fullname" . }} labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: fsGroup: rule: RunAsAny diff --git a/charts/capsule/templates/post-install-job.yaml b/charts/capsule/templates/post-install-job.yaml index 2016d0c9..8cc08140 100644 --- a/charts/capsule/templates/post-install-job.yaml +++ b/charts/capsule/templates/post-install-job.yaml @@ -6,16 +6,16 @@ kind: Job metadata: name: "{{ .Release.Name }}-waiting-certs" labels: - app.kubernetes.io/managed-by: {{ .Release.Service | quote }} - app.kubernetes.io/instance: {{ .Release.Name | quote }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} - helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + {{- include "capsule.labels" . | nindent 4 }} annotations: # This is what defines this resource as a hook. Without this line, the # job is considered part of the release. "helm.sh/hook": post-install "helm.sh/hook-weight": "-5" "helm.sh/hook-delete-policy": hook-succeeded + {{- with .Values.customAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: template: metadata: diff --git a/charts/capsule/templates/pre-delete-job.yaml b/charts/capsule/templates/pre-delete-job.yaml index 8529e195..041b8ddd 100644 --- a/charts/capsule/templates/pre-delete-job.yaml +++ b/charts/capsule/templates/pre-delete-job.yaml @@ -7,16 +7,16 @@ kind: Job metadata: name: "{{ .Release.Name }}-rbac-cleaner" labels: - app.kubernetes.io/managed-by: {{ .Release.Service | quote }} - app.kubernetes.io/instance: {{ .Release.Name | quote }} - app.kubernetes.io/version: {{ .Chart.AppVersion }} - helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + {{- include "capsule.labels" . | nindent 4 }} annotations: # This is what defines this resource as a hook. Without this line, the # job is considered part of the release. "helm.sh/hook": pre-delete "helm.sh/hook-weight": "-5" "helm.sh/hook-delete-policy": hook-succeeded + {{- with .Values.customAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: template: metadata: diff --git a/charts/capsule/templates/rbac.yaml b/charts/capsule/templates/rbac.yaml index 4619bb7c..1f317487 100644 --- a/charts/capsule/templates/rbac.yaml +++ b/charts/capsule/templates/rbac.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "capsule.fullname" . }}-proxy-role labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} rules: - apiGroups: - authentication.k8s.io @@ -24,6 +28,10 @@ metadata: name: {{ include "capsule.fullname" . }}-metrics-reader labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} rules: - nonResourceURLs: - /metrics @@ -36,6 +44,10 @@ metadata: name: {{ include "capsule.fullname" . }}-proxy-rolebinding labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -51,6 +63,10 @@ metadata: name: {{ include "capsule.fullname" . }}-manager-rolebinding labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/charts/capsule/templates/serviceaccount.yaml b/charts/capsule/templates/serviceaccount.yaml index a43a5781..cba29a83 100644 --- a/charts/capsule/templates/serviceaccount.yaml +++ b/charts/capsule/templates/serviceaccount.yaml @@ -5,8 +5,8 @@ metadata: name: {{ include "capsule.serviceAccountName" . }} labels: {{- include "capsule.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} + {{- if or (.Values.serviceAccount.annotations) (.Values.customAnnotations) }} annotations: - {{- toYaml . | nindent 4 }} + {{- include "capsule.serviceAccountAnnotations" . | nindent 4 }} {{- end }} {{- end }} diff --git a/charts/capsule/templates/validatingwebhookconfiguration.yaml b/charts/capsule/templates/validatingwebhookconfiguration.yaml index e8b80a44..ac8109b4 100644 --- a/charts/capsule/templates/validatingwebhookconfiguration.yaml +++ b/charts/capsule/templates/validatingwebhookconfiguration.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "capsule.fullname" . }}-validating-webhook-configuration labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} webhooks: - admissionReviewVersions: - v1 diff --git a/charts/capsule/templates/webhook-service.yaml b/charts/capsule/templates/webhook-service.yaml index 8616a80a..3fceef91 100644 --- a/charts/capsule/templates/webhook-service.yaml +++ b/charts/capsule/templates/webhook-service.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "capsule.fullname" . }}-webhook-service labels: {{- include "capsule.labels" . | nindent 4 }} + {{- with .Values.customAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: ports: - port: 443 diff --git a/charts/capsule/values.yaml b/charts/capsule/values.yaml index f7734b70..7024c7be 100644 --- a/charts/capsule/values.yaml +++ b/charts/capsule/values.yaml @@ -74,3 +74,9 @@ serviceMonitor: serviceAccount: name: capsule namespace: capsule-system + +# Additional labels +customLabels: {} + +# Additional annotations +customAnnotations: {}