Skip to content

Commit

Permalink
Adding helm values to set common labels and annotations (#153)
Browse files Browse the repository at this point in the history
* Adding helm values to set common labels and annotations

* Updated changelog

* Migrating helm labels/annotation setup to named templates

* Renaming helm fields to annotations and labels

Co-authored-by: Alexandre Guitton <[email protected]>
  • Loading branch information
r65535 and erdrix authored Aug 26, 2022
1 parent 5c8a349 commit 4224e53
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [PR #138](https://github.com/konpyutaika/nifikop/pull/138) - **[Operator/NifiCluster]** Add ability to configure the NiFi Load Balance port.
- [PR #144](https://github.com/konpyutaika/nifikop/pull/144) - **[Operator]** Add automatic detection of k8s prior 1.21.
- [PR #153](https://github.com/konpyutaika/nifikop/pull/153) - **[Helm Chart]** Added helm values to set common labels and annotations.

### Changed

Expand Down
2 changes: 2 additions & 0 deletions helm/nifikop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The following tables lists the configurable parameters of the NiFi Operator Helm
| `image.imagePullSecrets.name` | Name of the secret to connect to docker registry | - |
| `certManager.enabled` | Enable cert-manager integration | `true` |
| `rbacEnable` | If true, create & use RBAC resources | `true` |
| `labels` | Labels to add to all deployed resources | `{}` |
| `annotations` | Annotations to add to all deployed resources | `{}` |
| `resources` | Pod resource requests & limits | `{}` |
| `metrics.enabled` | deploy service for metrics | `false` |
| `metrics.port` | Set port for operator metrics | `8081` |
Expand Down
15 changes: 15 additions & 0 deletions helm/nifikop/templates/_functions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,18 @@ Return the appropriate apiVersion value to use for the capi-operator managed k8s
{{- printf "%s" "nificlusters.nifi.konpyutaika.com/v1alpha1" -}}
{{- end -}}

{{- define "userdefined.labels" }}
{{ if .Values.labels }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end}}
{{- end}}
{{- end }}

{{- define "userdefined.annotations" }}
{{ if .Values.annotations }}
{{- with .Values.annotations }}
{{- toYaml . | nindent 4 }}
{{- end}}
{{- end}}
{{- end }}
6 changes: 6 additions & 0 deletions helm/nifikop/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
operator: nifi
release: {{ .Release.Name }}
control-plane: nifikop
{{- include "userdefined.labels" . }}
annotations:
{{- include "userdefined.annotations" . }}
spec:
selector:
matchLabels:
Expand All @@ -24,6 +27,9 @@ spec:
app: {{ template "nifikop.name" . }}
operator: nifi
release: {{ .Release.Name }}
{{- include "userdefined.labels" . | indent 4 }}
annotations:
{{- include "userdefined.annotations" . | indent 4 }}
spec:
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
3 changes: 3 additions & 0 deletions helm/nifikop/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ metadata:
chart: {{ $.Chart.Name }}-{{ $.Chart.Version }}
heritage: {{ $.Release.Service }}
release: {{ $.Release.Name }}
{{- include "userdefined.labels" $_ }}
annotations:
{{- include "userdefined.annotations" $_ }}
name: {{ template "nifikop.name" $_ }}
namespace: {{$namespace}}
rules:
Expand Down
3 changes: 3 additions & 0 deletions helm/nifikop/templates/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
chart: {{ $.Chart.Name }}-{{ $.Chart.Version }}
heritage: {{ $.Release.Service }}
release: {{ $.Release.Name }}
{{- include "userdefined.labels" $_ }}
annotations:
{{- include "userdefined.annotations" $_ }}
name: {{ template "nifikop.name" $ }}
namespace: {{ $namespace }}
subjects:
Expand Down
3 changes: 3 additions & 0 deletions helm/nifikop/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "userdefined.labels" . }}
annotations:
{{- include "userdefined.annotations" . }}
spec:
selector:
app: {{ template "nifikop.name" . }}
Expand Down
3 changes: 3 additions & 0 deletions helm/nifikop/templates/service_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- include "userdefined.labels" . }}
annotations:
{{- include "userdefined.annotations" . }}
{{- if and .Values.serviceAccount .Values.serviceAccount.name}}
name: {{ .Values.serviceAccount.name }}
{{- else }}
Expand Down
6 changes: 6 additions & 0 deletions helm/nifikop/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ vaultSecret: ""
# set of namespaces where the operator watches resources
namespaces: []

# Optional labels to add to all deployed resources
labels: {}

# Optional annotations to add to all deployed resources
annotations: {}

## Prometheus-operator resource limits & requests
## Ref: https://kubernetes.io/docs/user-guide/compute-resources/
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ The following tables lists the configurable parameters of the NiFi Operator Helm
| `image.imagePullSecrets.name` | Name of the secret to connect to docker registry | - |
| `certManager.enabled` | Enable cert-manager integration | `true` |
| `rbacEnable` | If true, create & use RBAC resources | `true` |
| `labels` | Labels to add to all deployed resources | `{}` |
| `annotations` | Annotations to add to all deployed resources | `{}` |
| `resources` | Pod resource requests & limits | `{}` |
| `metrics.enabled` | deploy service for metrics | `false` |
| `metrics.port` | Set port for operator metrics | `8081` |
Expand Down

0 comments on commit 4224e53

Please sign in to comment.