Skip to content

Commit

Permalink
feat: helm chart podLabels (#1126)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdolce committed Feb 12, 2021
1 parent f27a73e commit 4270b0b
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 18 deletions.
4 changes: 4 additions & 0 deletions cmd/build/helmify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (ks *kindSet) Write() error {
obj = "{{- if .Values.createNamespace }}\n" + obj + "{{- end }}\n"
}

if kind == "Deployment" {
obj = strings.Replace(obj, " labels:", " labels:\n{{- include \"gatekeeper.podLabels\" . }}", 1)
}

if err := ioutil.WriteFile(destFile, []byte(obj), 0644); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions cmd/build/helmify/static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| audit.hostNetwork | Enables audit to be deployed on hostNetwork | `false` |
| replicas | The number of Gatekeeper replicas to deploy for the webhook | `1` |
| podAnnotations | The annotations to add to the Gatekeeper pods | `container.seccomp.security.alpha.kubernetes.io/manager: runtime/default` |
| podLabels | The labels to add to the Gatekeeper pods | `{}` |
| secretAnnotations | The annotations to add to the Gatekeeper secrets | `{}` |
| customResourceDefinitions.create | Whether the release should install CRDs. Regardless of this value, Helm v3+ will install the CRDs if those are not present already. Use --skip-crds with helm install if you want to skip CRD creation | `true` |

Expand Down
14 changes: 5 additions & 9 deletions cmd/build/helmify/static/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ Create chart name and version as used by the chart label.
{{- end -}}

{{/*
Common labels
Adds additional pod labels to the common ones
*/}}
{{- define "gatekeeper.labels" -}}
app.kubernetes.io/name: {{ include "gatekeeper.name" . }}
helm.sh/chart: {{ include "gatekeeper.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- define "gatekeeper.podLabels" -}}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- end -}}
1 change: 1 addition & 0 deletions cmd/build/helmify/static/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ image:
pullSecrets: []
podAnnotations:
{ container.seccomp.security.alpha.kubernetes.io/manager: runtime/default }
podLabels: {}
secretAnnotations: {}
controllerManager:
hostNetwork: false
Expand Down
1 change: 1 addition & 0 deletions manifest_staging/charts/gatekeeper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| audit.hostNetwork | Enables audit to be deployed on hostNetwork | `false` |
| replicas | The number of Gatekeeper replicas to deploy for the webhook | `1` |
| podAnnotations | The annotations to add to the Gatekeeper pods | `container.seccomp.security.alpha.kubernetes.io/manager: runtime/default` |
| podLabels | The labels to add to the Gatekeeper pods | `{}` |
| secretAnnotations | The annotations to add to the Gatekeeper secrets | `{}` |
| customResourceDefinitions.create | Whether the release should install CRDs. Regardless of this value, Helm v3+ will install the CRDs if those are not present already. Use --skip-crds with helm install if you want to skip CRD creation | `true` |

Expand Down
14 changes: 5 additions & 9 deletions manifest_staging/charts/gatekeeper/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ Create chart name and version as used by the chart label.
{{- end -}}

{{/*
Common labels
Adds additional pod labels to the common ones
*/}}
{{- define "gatekeeper.labels" -}}
app.kubernetes.io/name: {{ include "gatekeeper.name" . }}
helm.sh/chart: {{ include "gatekeeper.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- define "gatekeeper.podLabels" -}}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
annotations:
{{- toYaml .Values.podAnnotations | trim | nindent 8 }}
labels:
{{- include "gatekeeper.podLabels" . }}
app: '{{ template "gatekeeper.name" . }}'
chart: '{{ template "gatekeeper.name" . }}'
control-plane: audit-controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
annotations:
{{- toYaml .Values.podAnnotations | trim | nindent 8 }}
labels:
{{- include "gatekeeper.podLabels" . }}
app: '{{ template "gatekeeper.name" . }}'
chart: '{{ template "gatekeeper.name" . }}'
control-plane: controller-manager
Expand Down
1 change: 1 addition & 0 deletions manifest_staging/charts/gatekeeper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ image:
pullSecrets: []
podAnnotations:
{ container.seccomp.security.alpha.kubernetes.io/manager: runtime/default }
podLabels: {}
secretAnnotations: {}
controllerManager:
hostNetwork: false
Expand Down

0 comments on commit 4270b0b

Please sign in to comment.