Skip to content

Commit c737fa2

Browse files
committed
feat(operator chart): add core templates (namespace, serviceaccount, deployment, helpers)
1 parent 85600e4 commit c737fa2

File tree

4 files changed

+244
-0
lines changed

4 files changed

+244
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "feast-operator.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Generate a DNS-1123 compatible name with a suffix, ensuring total length <= 63
10+
Usage: {{ include "feast-operator.fullnameWithSuffix" (dict "root" . "suffix" "metrics") }}
11+
*/}}
12+
{{- define "feast-operator.fullnameWithSuffix" -}}
13+
{{- $root := .root -}}
14+
{{- $suffix := .suffix -}}
15+
{{- $base := include "feast-operator.fullname" $root -}}
16+
{{- $max := 63 -}}
17+
{{- $needed := add (len $suffix) 1 -}}
18+
{{- $trim := sub $max $needed -}}
19+
{{- printf "%s-%s" (trunc (int $trim) $base) $suffix | trimSuffix "-" -}}
20+
{{- end }}
21+
22+
{{/*
23+
Create a default fully qualified app name.
24+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
25+
If release name contains chart name it will be used as a full name.
26+
*/}}
27+
{{- define "feast-operator.fullname" -}}
28+
{{- $name := "" }}
29+
{{- if .Values.fullnameOverride }}
30+
{{- $name = .Values.fullnameOverride }}
31+
{{- else }}
32+
{{- $chartName := default .Chart.Name .Values.nameOverride }}
33+
{{- if contains $chartName .Release.Name }}
34+
{{- $name = .Release.Name }}
35+
{{- else }}
36+
{{- $name = printf "%s-%s" .Release.Name $chartName }}
37+
{{- end }}
38+
{{- end }}
39+
{{- $prefix := .Values.namePrefix | default "" }}
40+
{{- printf "%s%s" $prefix $name | trunc 63 | trimSuffix "-" }}
41+
{{- end }}
42+
43+
{{/*
44+
Create chart name and version as used by the chart label.
45+
*/}}
46+
{{- define "feast-operator.chart" -}}
47+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
48+
{{- end }}
49+
50+
{{/*
51+
Common labels
52+
*/}}
53+
{{- define "feast-operator.labels" -}}
54+
helm.sh/chart: {{ include "feast-operator.chart" . }}
55+
{{ include "feast-operator.selectorLabels" . }}
56+
{{- if .Chart.AppVersion }}
57+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
58+
{{- end }}
59+
app.kubernetes.io/managed-by: {{ .Release.Service }}
60+
app.kubernetes.io/name: feast-operator
61+
{{- with .Values.commonLabels }}
62+
{{ toYaml . }}
63+
{{- end }}
64+
{{- end }}
65+
66+
{{/*
67+
Selector labels
68+
*/}}
69+
{{- define "feast-operator.selectorLabels" -}}
70+
app.kubernetes.io/name: {{ include "feast-operator.name" . }}
71+
app.kubernetes.io/instance: {{ .Release.Name }}
72+
control-plane: controller-manager
73+
{{- end }}
74+
75+
{{/*
76+
Create the name of the service account to use
77+
*/}}
78+
{{- define "feast-operator.serviceAccountName" -}}
79+
{{- if .Values.serviceAccount.create }}
80+
{{- default (printf "%s-controller-manager" (include "feast-operator.fullname" .)) .Values.serviceAccount.name }}
81+
{{- else }}
82+
{{- default "default" .Values.serviceAccount.name }}
83+
{{- end }}
84+
{{- end }}
85+
86+
{{/*
87+
Create the namespace
88+
*/}}
89+
{{- define "feast-operator.namespace" -}}
90+
{{- if .Values.namespace.name }}
91+
{{- .Values.namespace.name }}
92+
{{- else }}
93+
{{- .Release.Namespace }}
94+
{{- end }}
95+
{{- end }}
96+
97+
{{/*
98+
Create image reference
99+
*/}}
100+
{{- define "feast-operator.image" -}}
101+
{{- if .Values.global.imageRegistry }}
102+
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.operator.image.repository .Values.operator.image.tag }}
103+
{{- else }}
104+
{{- printf "%s:%s" .Values.operator.image.repository .Values.operator.image.tag }}
105+
{{- end }}
106+
{{- end }}
107+
108+
{{/*
109+
Common annotations
110+
*/}}
111+
{{- define "feast-operator.annotations" -}}
112+
{{- with .Values.commonAnnotations }}
113+
{{ toYaml . }}
114+
{{- end }}
115+
{{- end }}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "feast-operator.fullname" . }}-controller-manager
5+
namespace: {{ include "feast-operator.namespace" . }}
6+
labels:
7+
{{- include "feast-operator.labels" . | nindent 4 }}
8+
{{- with (include "feast-operator.annotations" .) }}
9+
annotations:
10+
{{- . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
replicas: {{ .Values.operator.replicaCount }}
14+
selector:
15+
matchLabels:
16+
{{- include "feast-operator.selectorLabels" . | nindent 6 }}
17+
template:
18+
metadata:
19+
annotations:
20+
{{- with .Values.operator.podAnnotations }}
21+
{{- toYaml . | nindent 8 }}
22+
{{- end }}
23+
{{- with (include "feast-operator.annotations" .) }}
24+
{{- . | nindent 8 }}
25+
{{- end }}
26+
labels:
27+
{{- include "feast-operator.selectorLabels" . | nindent 8 }}
28+
{{- with .Values.operator.podLabels }}
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
spec:
32+
{{- with .Values.global.imagePullSecrets }}
33+
imagePullSecrets:
34+
{{- toYaml . | nindent 8 }}
35+
{{- end }}
36+
serviceAccountName: {{ include "feast-operator.serviceAccountName" . }}
37+
{{- with .Values.operator.securityContext }}
38+
securityContext:
39+
{{- toYaml . | nindent 8 }}
40+
{{- end }}
41+
{{- with .Values.operator.affinity }}
42+
affinity:
43+
{{- toYaml . | nindent 8 }}
44+
{{- end }}
45+
{{- with .Values.operator.nodeSelector }}
46+
nodeSelector:
47+
{{- toYaml . | nindent 8 }}
48+
{{- end }}
49+
{{- with .Values.operator.tolerations }}
50+
tolerations:
51+
{{- toYaml . | nindent 8 }}
52+
{{- end }}
53+
containers:
54+
- name: manager
55+
image: {{ include "feast-operator.image" . }}
56+
imagePullPolicy: {{ .Values.operator.image.pullPolicy }}
57+
command:
58+
- /manager
59+
args:
60+
{{- if .Values.advanced.leaderElection }}
61+
- --leader-elect
62+
{{- end }}
63+
- --health-probe-bind-address={{ .Values.advanced.healthProbeBindAddress }}
64+
- --metrics-bind-address={{ .Values.advanced.metricsBindAddress }}
65+
{{- with .Values.operator.args }}
66+
{{- toYaml . | nindent 8 }}
67+
{{- end }}
68+
{{- with .Values.operator.containerSecurityContext }}
69+
securityContext:
70+
{{- toYaml . | nindent 10 }}
71+
{{- end }}
72+
env:
73+
- name: RELATED_IMAGE_FEATURE_SERVER
74+
value: {{ .Values.operator.env.relatedImageFeatureServer | quote }}
75+
- name: RELATED_IMAGE_CRON_JOB
76+
value: {{ .Values.operator.env.relatedImageCronJob | quote }}
77+
ports:
78+
- name: health
79+
containerPort: {{ .Values.operator.healthcheck.port }}
80+
protocol: TCP
81+
livenessProbe:
82+
httpGet:
83+
path: /healthz
84+
port: health
85+
initialDelaySeconds: {{ .Values.operator.healthcheck.livenessProbe.initialDelaySeconds }}
86+
periodSeconds: {{ .Values.operator.healthcheck.livenessProbe.periodSeconds }}
87+
readinessProbe:
88+
httpGet:
89+
path: /readyz
90+
port: health
91+
initialDelaySeconds: {{ .Values.operator.healthcheck.readinessProbe.initialDelaySeconds }}
92+
periodSeconds: {{ .Values.operator.healthcheck.readinessProbe.periodSeconds }}
93+
{{- with .Values.operator.resources }}
94+
resources:
95+
{{- toYaml . | nindent 10 }}
96+
{{- end }}
97+
terminationGracePeriodSeconds: {{ .Values.advanced.terminationGracePeriodSeconds }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.namespace.create }}
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: {{ include "feast-operator.namespace" . }}
6+
labels:
7+
{{- include "feast-operator.labels" . | nindent 4 }}
8+
{{- with .Values.namespace.labels }}
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
app.kubernetes.io/managed-by: Helm
12+
{{- with (include "feast-operator.annotations" .) }}
13+
annotations:
14+
{{- . | nindent 4 }}
15+
{{- end }}
16+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "feast-operator.serviceAccountName" . }}
6+
namespace: {{ include "feast-operator.namespace" . }}
7+
labels:
8+
{{- include "feast-operator.labels" . | nindent 4 }}
9+
{{- with .Values.serviceAccount.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- with (include "feast-operator.annotations" .) }}
14+
{{- . | nindent 4 }}
15+
{{- end }}
16+
{{- end }}

0 commit comments

Comments
 (0)