Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CN-993] Common label and annotation parameters for all deployed objects #388

Merged
merged 7 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stable/hazelcast-enterprise/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: hazelcast-enterprise
version: 5.10.6
version: 5.10.7
appVersion: "5.3.2"
kubeVersion: ">=1.19.0-0"
description: Hazelcast is a streaming and memory-first application platform for fast, stateful, data-intensive workloads on-premises, at the edge or as a fully managed cloud service.
Expand Down
9 changes: 9 additions & 0 deletions stable/hazelcast-enterprise/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
Copy link
Contributor

@dzeromski-hazelcast dzeromski-hazelcast Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use template to avoid repeating loop in every template?

We do something similar in our operator helm chart:

  labels:
    {{- include "hazelcast-platform-operator.labels" . | nindent 4 }}

and define it in https://github.com/hazelcast/charts/blob/master/stable/hazelcast-platform-operator/templates/_helpers.tpl#L33

Copy link
Contributor Author

@semihbkgr semihbkgr Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning to refactor it in a separate PR. We are duplicating default labels in all templates as well.

{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
data:
{{- range $key, $val := .Values.hazelcast.configurationFiles }}
{{ $key }}: |-
Expand Down
9 changes: 9 additions & 0 deletions stable/hazelcast-enterprise/templates/mancenter-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
data:
hazelcast-client.yaml: |-
{{ toYaml .Values.mancenter.yaml | indent 4 }}
Expand Down
11 changes: 8 additions & 3 deletions stable/hazelcast-enterprise/templates/mancenter-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- with .Values.mancenter.ingress.annotations }}
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if or .Values.mancenter.ingress.annotations .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- range $key, $val := (merge nil .Values.mancenter.ingress.annotations .Values.commonAnnotations) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
ingressClassName: {{ .Values.mancenter.ingress.className }}
{{- if .Values.mancenter.ingress.tls }}
Expand Down
8 changes: 7 additions & 1 deletion stable/hazelcast-enterprise/templates/mancenter-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.mancenter.service.labels }}
{{- range $key, $value := (merge nil .Values.mancenter.service.labels .Values.commonLabels) }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.mancenter.service.type }}
{{- if .Values.mancenter.service.clusterIP }}
Expand Down
29 changes: 24 additions & 5 deletions stable/hazelcast-enterprise/templates/mancenter-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.mancenter.labels }}
{{- range $key, $value := (merge nil .Values.mancenter.labels .Values.commonLabels) }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
serviceName: {{ template "mancenter.fullname" . }}
replicas: 1
Expand All @@ -27,12 +33,16 @@ spec:
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
role: mancenter
{{- if .Values.mancenter.podLabels }}
{{ toYaml .Values.mancenter.podLabels | indent 8 }}
{{- if or .Values.mancenter.podLabels .Values.commonLabels }}
{{- range $key, $val := (merge nil .Values.mancenter.podLabels .Values.commonLabels) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- if .Values.mancenter.annotations }}
{{- if or .Values.mancenter.annotations .Values.commonAnnotations }}
annotations:
{{ toYaml .Values.mancenter.annotations | indent 8 }}
{{- range $key, $val := (merge nil .Values.mancenter.annotations .Values.commonAnnotations) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
{{- if .Values.mancenter.image.pullSecrets }}
Expand Down Expand Up @@ -229,6 +239,15 @@ spec:
app.kubernetes.io/name: {{ template "mancenter.name" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
accessModes:
{{- range .Values.mancenter.persistence.accessModes }}
Expand Down
9 changes: 8 additions & 1 deletion stable/hazelcast-enterprise/templates/metrics-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ metadata:
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
app.kubernetes.io/component: metrics
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if or .Values.metrics.service.annotations .Values.commonAnnotations }}
annotations:
{{ toYaml .Values.metrics.service.annotations | indent 4 }}
{{- range $key, $val := (merge nil .Values.metrics.service.annotations .Values.commonAnnotations) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.metrics.service.type }}
{{- if (and (eq .Values.metrics.service.type "LoadBalancer") (.Values.metrics.service.loadBalancerIP)) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
{{ toYaml .Values.podDisruptionBudget | indent 2 }}
selector:
Expand Down
8 changes: 7 additions & 1 deletion stable/hazelcast-enterprise/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $val := .Values.metrics.prometheusRule.labels }}
{{- range $key, $val := (merge nil .Values.metrics.prometheusRule.labels .Values.commonLabels) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
groups:
- name: {{ template "hazelcast.name" . }}
Expand Down
9 changes: 9 additions & 0 deletions stable/hazelcast-enterprise/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
rules:
- apiGroups:
- ""
Expand Down
9 changes: 9 additions & 0 deletions stable/hazelcast-enterprise/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
{{- if .Values.rbac.useClusterRole }}
Expand Down
10 changes: 6 additions & 4 deletions stable/hazelcast-enterprise/templates/service-external.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ metadata:
app.kubernetes.io/instance: "{{ $.Release.Name }}"
app.kubernetes.io/managed-by: "{{ $.Release.Service }}"
pod: {{ $targetPod }}
{{- range $key, $value := $.Values.externalAccess.service.labels }}
{{- range $key, $value := (merge nil .Values.externalAccess.service.labels .Values.commonLabels) }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- with $.Values.externalAccess.service.annotations }}
{{- if or .Values.externalAccess.service.annotations .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- range $key, $val := (merge nil .Values.externalAccess.service.annotations .Values.commonAnnotations) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
type: {{ $.Values.externalAccess.service.type }}
{{- if $.Values.externalAccess.service.loadBalancerIPs }}
Expand Down
8 changes: 7 additions & 1 deletion stable/hazelcast-enterprise/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.service.labels }}
{{- range $key, $value := (merge nil .Values.service.labels .Values.commonLabels) }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if (and (eq .Values.service.type "ClusterIP") (.Values.service.clusterIP)) }}
Expand Down
9 changes: 9 additions & 0 deletions stable/hazelcast-enterprise/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- end -}}
8 changes: 7 additions & 1 deletion stable/hazelcast-enterprise/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $val := .Values.metrics.serviceMonitor.labels }}
{{- range $key, $val := (merge nil .Values.metrics.serviceMonitor.labels .Values.commonLabels) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
endpoints:
- port: {{ .Values.metrics.service.portName }}
Expand Down
25 changes: 18 additions & 7 deletions stable/hazelcast-enterprise/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.labels }}
{{- range $key, $value := (merge nil .Values.labels .Values.commonLabels) }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.annotations }}
{{- if or .Values.annotations .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.annotations }}
{{- range $key, $val := (merge nil .Values.annotations .Values.commonAnnotations) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
Expand All @@ -33,12 +33,14 @@ spec:
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
role: hazelcast
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
{{- if or .Values.podLabels .Values.commonLabels }}
{{- range $key, $val := (merge nil .Values.podLabels .Values.commonLabels) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
annotations:
checksum/hazelcast-config: {{ toYaml .Values.hazelcast.yaml | sha256sum }}
{{- range $key, $val := .Values.annotations }}
{{- range $key, $val := (merge nil .Values.annotations .Values.commonAnnotations) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
spec:
Expand Down Expand Up @@ -241,6 +243,15 @@ spec:
app.kubernetes.io/name: {{ template "hazelcast.name" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
Expand Down
6 changes: 6 additions & 0 deletions stable/hazelcast-enterprise/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ cluster:
# memberCount is the number Hazelcast members
memberCount: 3

# Labels to add to all deployed objects
commonLabels: {}

# Annotations to add to all deployed objects
commonAnnotations: {}

# Hazelcast properties
hazelcast:
# enabled is a flag to enable Hazelcast application
Expand Down
2 changes: 1 addition & 1 deletion stable/hazelcast/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: hazelcast
version: 5.8.7
version: 5.8.8
appVersion: "5.3.2"
kubeVersion: ">=1.19.0-0"
description: Hazelcast is a streaming and memory-first application platform for fast, stateful, data-intensive workloads on-premises, at the edge or as a fully managed cloud service.
Expand Down
9 changes: 9 additions & 0 deletions stable/hazelcast/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
data:
{{- range $key, $val := .Values.hazelcast.configurationFiles }}
{{ $key }}: |-
Expand Down
9 changes: 9 additions & 0 deletions stable/hazelcast/templates/mancenter-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ metadata:
helm.sh/chart: {{ template "hazelcast.chart" . }}
app.kubernetes.io/instance: "{{ .Release.Name }}"
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
{{- range $key, $value := .Values.commonLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- range $key, $val := .Values.commonAnnotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
data:
hazelcast-client.yaml: |-
{{ toYaml .Values.mancenter.yaml | indent 4 }}
Expand Down
Loading
Loading