Skip to content

Commit

Permalink
refactor(chart): refactor implementation for adding extra labels to a…
Browse files Browse the repository at this point in the history
…ll chart resources

Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih committed Jul 4, 2024
1 parent e56c509 commit 4eb5a65
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions deploy/helm/charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ helm install openebs-localpv openebs-localpv/localpv-provisioner --namespace ope
| `release.version` | LocalPV Provisioner release version | `4.1.0` |
| `analytics.enabled` | Enable sending stats to Google Analytics | `true` |
| `analytics.pingInterval` | Duration(hours) between sending ping stat | `24h` |
| `extraLabels` | Additional labels to add to all chart resources | `{}` |
| `helperPod.image.registry` | Registry for helper image | `""` |
| `helperPod.image.repository` | Image for helper pod | `"openebs/linux-utils"` |
| `helperPod.image.pullPolicy` | Pull policy for helper pod | `"IfNotPresent"` |
Expand Down
5 changes: 0 additions & 5 deletions deploy/helm/charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ Common labels
{{ include "localpv.common.metaLabels" . }}
{{ include "localpv.selectorLabels" . }}
{{ include "localpv.componentLabels" . }}
{{- if (gt (len .Values.labels) 0) -}}
{{ printf "\n"}}
{{ .Values.labels | toYaml }}
{{- end -}}
{{- end -}}


{{/*
Create the name of the service account to use
Expand Down
8 changes: 7 additions & 1 deletion deploy/helm/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
{{- end }}
labels:
{{- include "localpv.labels" . | nindent 4 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.localpv.replicas }}
strategy:
Expand All @@ -23,8 +26,11 @@ spec:
{{- end }}
labels:
{{- include "localpv.labels" . | nindent 8 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 8 }}
{{- end }}
{{- with .Values.localpv.podLabels }}
{{ toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{ with .Values.priorityClassName }}
Expand Down
5 changes: 2 additions & 3 deletions deploy/helm/charts/templates/hostpath-class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ metadata:
{{- if .Values.hostpathClass.isDefaultClass }}
storageclass.kubernetes.io/is-default-class: "true"
{{- end }}
{{- if (gt (len .Values.labels) 0) }}
labels:
{{ toYaml .Values.labels | indent 4 }}
{{- if .Values.extraLabels }}
labels: {{- toYaml .Values.extraLabels | nindent 4 -}}
{{- end }}
provisioner: openebs.io/local
volumeBindingMode: WaitForFirstConsumer
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/charts/templates/psp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
{{- end }}
labels:
{{- include "localpv.labels" . | nindent 4 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 4 }}
{{- end }}
spec:
privileged: {{ .Values.localpv.privileged }}
allowPrivilegeEscalation: true
Expand Down
15 changes: 15 additions & 0 deletions deploy/helm/charts/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ metadata:
name: {{ include "localpv.serviceAccountName" . }}
labels:
{{- include "localpv.labels" . | nindent 4 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand All @@ -21,6 +24,9 @@ metadata:
{{- end }}
labels:
{{- include "localpv.labels" . | nindent 4 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 4 }}
{{- end }}
rules:
- apiGroups: ["*"]
resources: ["nodes"]
Expand Down Expand Up @@ -55,6 +61,9 @@ metadata:
{{- end }}
labels:
{{- include "localpv.labels" . | nindent 4 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -74,6 +83,9 @@ metadata:
{{- end }}
labels:
{{- include "localpv.labels" . | nindent 4 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 4 }}
{{- end }}
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
Expand All @@ -90,6 +102,9 @@ metadata:
{{- end }}
labels:
{{- include "localpv.labels" . | nindent 4 }}
{{- if .Values.extraLabels -}}
{{- toYaml .Values.extraLabels | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
6 changes: 3 additions & 3 deletions deploy/helm/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ helperPod:
# Overrides the image tag whose default is the chart appVersion.
tag: 4.1.0

# Additional labels to add to all chart resources
extraLabels: {}

analytics:
enabled: true
# Specify in hours the duration after which a ping event needs to be sent.
pingInterval: "24h"

# Additional labels to add to all chart resources
labels: {}

0 comments on commit 4eb5a65

Please sign in to comment.