Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "operator.name" -}}
{{- define "{[ operator.name }].name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-operator" }}
{{- end }}

{{/*
Expand the name of the chart.
*/}}
{{- define "operator.appname" -}}
{{- define "{[ operator.name }].appname" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -17,7 +17,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "operator.fullname" -}}
{{- define "{[ operator.name }].fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -33,16 +33,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "operator.chart" -}}
{{- define "{[ operator.name }].chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "operator.labels" -}}
helm.sh/chart: {{ include "operator.chart" . }}
{{ include "operator.selectorLabels" . }}
{{- define "{[ operator.name }].labels" -}}
helm.sh/chart: {{ include "{[ operator.name }].chart" . }}
{{ include "{[ operator.name }].selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -52,8 +52,8 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "operator.appname" . }}
{{- define "{[ operator.name }].selectorLabels" -}}
app.kubernetes.io/name: {{ include "{[ operator.name }].appname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.labels }}
{{ toYaml . }}
Expand All @@ -63,9 +63,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{/*
Create the name of the service account to use
*/}}
{{- define "operator.serviceAccountName" -}}
{{- define "{[ operator.name }].serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (printf "%s-serviceaccount" (include "operator.fullname" .)) .Values.serviceAccount.name }}
{{- default (printf "%s-serviceaccount" (include "{[ operator.name }].fullname" .)) .Values.serviceAccount.name }}
{{- else }}
{{- required "serviceAccount.name is required when serviceAccount.create is false, because the chart then does not create a ServiceAccount for the operator to run as." .Values.serviceAccount.name }}
{{- end }}
Expand All @@ -74,13 +74,13 @@ Create the name of the service account to use
{{/*
Labels for Kubernetes objects created by helm test
*/}}
{{- define "operator.testLabels" -}}
helm.sh/test: {{ include "operator.chart" . }}
{{- define "{[ operator.name }].testLabels" -}}
helm.sh/test: {{ include "{[ operator.name }].chart" . }}
{{- end }}

{{/*
Build the full operator container image reference.
*/}}
{{- define "operator.image" -}}
{{- define "{[ operator.name }].image" -}}
{{- printf "%s/%s:%s" .Values.image.repository .Chart.Name (.Values.image.tag | default .Chart.AppVersion) -}}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Create a list of maintenance related env vars.
*/}}
{{- define "maintenance.envVars" -}}
{{- define "{[ operator.name }].maintenance.envVars" -}}
{{- with .Values.maintenance }}
{{- if not .endOfSupportCheck.enabled }}
- name: EOS_DISABLED
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Create a list of telemetry related env vars.
*/}}
{{- define "telemetry.envVars" -}}
{{- define "{[ operator.name }].telemetry.envVars" -}}
{{- with .Values.telemetry }}
{{- if not .consoleLog.enabled }}
- name: CONSOLE_LOG_DISABLED
Expand All @@ -17,7 +17,7 @@ Create a list of telemetry related env vars.
{{ end }}
{{- if .fileLog.enabled }}
- name: FILE_LOG_DIRECTORY
value: /stackable/logs/{{ include "operator.appname" $ }}
value: /stackable/logs/{{ include "{[ operator.name }].appname" $ }}
{{- end }}
{{- if and .fileLog.enabled .fileLog.level }}
- name: FILE_LOG_LEVEL
Expand Down
24 changes: 12 additions & 12 deletions template/deploy/helm/[[operator]]/templates/deployment.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "operator.fullname" . }}-deployment
name: {{ include "{[ operator.name }].fullname" . }}-deployment
labels:
{{- include "operator.labels" . | nindent 4 }}
{{- include "{[ operator.name }].labels" . | nindent 4 }}
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
{{- include "operator.selectorLabels" . | nindent 6 }}
{{- include "{[ operator.name }].selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
internal.stackable.tech/image: {{ include "operator.image" . }}
internal.stackable.tech/image: {{ include "{[ operator.name }].image" . }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
webhook.stackable.tech/conversion: enabled
{{- end }}
{{- include "operator.selectorLabels" . | nindent 8 }}
{{- include "{[ operator.name }].selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.image.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "operator.serviceAccountName" . }}
serviceAccountName: {{ include "{[ operator.name }].serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ include "operator.appname" . }}
- name: {{ include "{[ operator.name }].appname" . }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ include "operator.image" . }}
image: {{ include "{[ operator.name }].image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand Down Expand Up @@ -65,7 +65,7 @@ spec:
# The name of the Kubernetes Service that point to the operator Pod, e.g. used to
# construct the conversion webhook endpoint.
- name: OPERATOR_SERVICE_NAME
value: {{ include "operator.fullname" . }}
value: {{ include "{[ operator.name }].fullname" . }}

{[% if operator.config.has_product | default(true) %}]
# The product image repository, like "oci.stackable.tech/sdp".
Expand All @@ -89,11 +89,11 @@ spec:
value: {{ .Values.kubernetesClusterDomain | quote }}
{{- end }}

{{- include "telemetry.envVars" . | nindent 12 }}
{{- include "maintenance.envVars" . | nindent 12 }}
{{- include "{[ operator.name }].telemetry.envVars" . | nindent 12 }}
{{- include "{[ operator.name }].maintenance.envVars" . | nindent 12 }}
{[% if operator.product_string in ['opa'] %}]
- name: OPA_BUNDLE_BUILDER_CLUSTERROLE
value: {{ include "operator.fullname" . }}-opa-bundle-builder-clusterrole
value: {{ include "{[ operator.name }].fullname" . }}-opa-bundle-builder-clusterrole
{[% endif %}]
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ metadata:
# Note(@sbernauer): We could also call the Service something like
# "product-operator-conversion-webhook". However, in the future we will have more webhooks, and
# it seems like an overkill to have a dedicated Service per webhook.
name: {{ include "operator.fullname" . }}
name: {{ include "{[ operator.name }].fullname" . }}
labels:
{{- include "operator.labels" . | nindent 4 }}
{{- include "{[ operator.name }].labels" . | nindent 4 }}
spec:
selector:
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
webhook.stackable.tech/conversion: enabled
{{- end }}
{{- include "operator.selectorLabels" . | nindent 4 }}
{{- include "{[ operator.name }].selectorLabels" . | nindent 4 }}
ports:
- name: conversion-webhook
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "operator.serviceAccountName" . }}
name: {{ include "{[ operator.name }].serviceAccountName" . }}
labels:
{{- include "operator.labels" . | nindent 4 }}
{{- include "{[ operator.name }].labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand All @@ -17,14 +17,14 @@ apiVersion: rbac.authorization.k8s.io/v1
# operator watch and manage its custom resources across the cluster.
kind: ClusterRoleBinding
metadata:
name: {{ include "operator.fullname" . }}-clusterrolebinding
name: {{ include "{[ operator.name }].fullname" . }}-clusterrolebinding
labels:
{{- include "operator.labels" . | nindent 4 }}
{{- include "{[ operator.name }].labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ include "operator.serviceAccountName" . }}
name: {{ include "{[ operator.name }].serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ include "operator.fullname" . }}-clusterrole
name: {{ include "{[ operator.name }].fullname" . }}-clusterrole
apiGroup: rbac.authorization.k8s.io