From 9d75e0d9c32729746fcbec3837c7cbb855a3ad0b Mon Sep 17 00:00:00 2001 From: Andrew Choo Date: Sun, 14 Jan 2024 13:44:15 -0500 Subject: [PATCH] feat(helm-chart): add annotations and labels to resources (#51) * feat: add default labels to ClusterRole and ClusterRoleBinding * feat: add ability to specify annotations for service * feat: add ability to specify labels for Ingress, Service & ServiceAccount * fix: add missing serviceAccount.annotations to values.yaml --- charts/komoplane/templates/ingress.yaml | 3 +++ charts/komoplane/templates/service.yaml | 7 +++++++ charts/komoplane/templates/serviceaccount.yaml | 7 +++++++ charts/komoplane/values.yaml | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/charts/komoplane/templates/ingress.yaml b/charts/komoplane/templates/ingress.yaml index ced20f9..ee50d1d 100644 --- a/charts/komoplane/templates/ingress.yaml +++ b/charts/komoplane/templates/ingress.yaml @@ -18,6 +18,9 @@ metadata: name: {{ $fullName }} labels: {{- include "app.labels" . | nindent 4 }} + {{- with .Values.ingress.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/komoplane/templates/service.yaml b/charts/komoplane/templates/service.yaml index a3164fc..4425b63 100644 --- a/charts/komoplane/templates/service.yaml +++ b/charts/komoplane/templates/service.yaml @@ -4,6 +4,13 @@ metadata: name: {{ include "app.fullname" . }} labels: {{- include "app.labels" . | nindent 4 }} + {{- with .Values.service.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: type: {{ .Values.service.type }} ports: diff --git a/charts/komoplane/templates/serviceaccount.yaml b/charts/komoplane/templates/serviceaccount.yaml index 8360696..f4bd2f0 100644 --- a/charts/komoplane/templates/serviceaccount.yaml +++ b/charts/komoplane/templates/serviceaccount.yaml @@ -5,6 +5,9 @@ metadata: name: {{ include "app.serviceAccountName" . }} labels: {{- include "app.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} @@ -15,6 +18,8 @@ kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ include "app.serviceAccountName" . }} + labels: + {{- include "app.labels" . | nindent 4 }} rules: - apiGroups: ["*"] resources: ["*"] @@ -24,6 +29,8 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: {{ include "app.serviceAccountName" . }} + labels: + {{- include "app.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/charts/komoplane/values.yaml b/charts/komoplane/values.yaml index 3e9d28b..3b8992e 100644 --- a/charts/komoplane/values.yaml +++ b/charts/komoplane/values.yaml @@ -22,6 +22,8 @@ serviceAccount: # The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name: "" + annotations: { } + labels: { } resources: requests: @@ -63,11 +65,14 @@ securityContext: service: type: ClusterIP port: 8090 + annotations: { } + labels: { } ingress: enabled: false className: "" annotations: { } + labels: { } hosts: - host: chart-example.local paths: