Skip to content

Commit

Permalink
Simplified adding labels and only use selector labels where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
ramondeklein committed Apr 16, 2024
1 parent bf5638d commit 9c2b261
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 41 deletions.
36 changes: 10 additions & 26 deletions helm/operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,17 @@ Create chart name and version as used by the chart label.
{{- end -}}

{{/*
Common labels for operator. Does not include selectorLabels.
Common labels for operator
*/}}
{{- define "minio-operator.labels-common" -}}
{{- define "minio-operator.labels" -}}
helm.sh/chart: {{ include "minio-operator.chart" . }}
{{- range $key, $val := .Values.operator.additionalLabels }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
All labels for operator. Includes selectorLabels.
*/}}
{{- define "minio-operator.labels-all" -}}
{{ include "minio-operator.labels-common" . }}
{{ include "minio-operator.selectorLabels" . }}
{{- range $key, $val := .Values.operator.additionalLabels }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end -}}

{{/*
Expand All @@ -67,25 +59,17 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Common labels for console. Does not include selectorLabels.
Common labels for console
*/}}
{{- define "minio-operator.console-labels-common" -}}
{{- define "minio-operator.console-labels" -}}
helm.sh/chart: {{ include "minio-operator.chart" . }}
{{- range $key, $val := .Values.console.additionalLabels }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
All labels for console. Combines minio-operator.console-labels-common and minio-operator.console-selectorLabels.
*/}}
{{- define "minio-operator.console-labels-all" -}}
{{ include "minio-operator.console-labels-common" . }}
{{ include "minio-operator.console-selectorLabels" . }}
{{- range $key, $val := .Values.console.additionalLabels }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end -}}

{{/*
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/console-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: console-sa-role
labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.console-labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/console-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: console-sa-binding
labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.console-labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/console-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ConfigMap
metadata:
name: console-env
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.console-labels" . | nindent 4 }}
data:
CONSOLE_PORT: "9090"
CONSOLE_TLS_PORT: "9443"
Expand Down
6 changes: 4 additions & 2 deletions helm/operator/templates/console-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ kind: Deployment
metadata:
name: console
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.console-labels-all" . | nindent 4 }}
labels: {{- include "minio-operator.console-labels" . | nindent 4 }}
spec:
replicas: {{ .Values.console.replicaCount }}
selector:
matchLabels: {{- include "minio-operator.console-selectorLabels" . | nindent 6 }}
template:
metadata:
labels: {{- include "minio-operator.console-labels-all" . | nindent 8 }}
labels:
{{- include "minio-operator.console-labels" . | nindent 8 }}
{{- include "minio-operator.console-selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.console.imagePullSecrets }}
imagePullSecrets: {{- toYaml . | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/console-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
namespace: {{ .Release.Namespace }}
annotations:
kubernetes.io/service-account.name: console-sa
labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.console-labels" . | nindent 4 }}
type: kubernetes.io/service-account-token
{{- end }}
2 changes: 1 addition & 1 deletion helm/operator/templates/console-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Service
metadata:
name: console
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.console-labels" . | nindent 4 }}
spec:
ports:
- name: http
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/console-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ kind: ServiceAccount
metadata:
name: console-sa
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.console-labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.console-labels" . | nindent 4 }}
{{- end }}
2 changes: 1 addition & 1 deletion helm/operator/templates/operator-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: minio-operator-role
labels: {{- include "minio-operator.labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.labels" . | nindent 4 }}
rules:
- apiGroups:
- "apiextensions.k8s.io"
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/operator-clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: minio-operator-binding
labels: {{- include "minio-operator.labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
6 changes: 4 additions & 2 deletions helm/operator/templates/operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ kind: Deployment
metadata:
name: minio-operator
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.labels-all" . | nindent 4 }}
labels: {{- include "minio-operator.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.operator.replicaCount }}
selector:
matchLabels: {{- include "minio-operator.selectorLabels" . | nindent 6 }}
template:
metadata:
labels: {{- include "minio-operator.labels-all" . | nindent 8 }}
labels:
{{- include "minio-operator.labels" . | nindent 8 }}
{{- include "minio-operator.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.operator.imagePullSecrets }}
imagePullSecrets: {{- toYaml . | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/operator-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Service
metadata:
name: operator
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/operator-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ServiceAccount
metadata:
name: minio-operator
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.labels" . | nindent 4 }}
{{- with .Values.operator.serviceAccountAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/operator/templates/sts-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Service
metadata:
name: sts
namespace: {{ .Release.Namespace }}
labels: {{- include "minio-operator.labels-common" . | nindent 4 }}
labels: {{- include "minio-operator.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
Expand Down

0 comments on commit 9c2b261

Please sign in to comment.