Skip to content

Commit bf376d3

Browse files
committed
feat(chart): added helm chart and updated some configs
1 parent 106c0e8 commit bf376d3

16 files changed

+645
-4
lines changed

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.0.1
6+
VERSION ?= 0.1.0
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
@@ -29,7 +29,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
2929
#
3030
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
3131
# devolutions.com/dvls-kubernetes-operator-bundle:$VERSION and devolutions.com/dvls-kubernetes-operator-catalog:$VERSION.
32-
IMAGE_TAG_BASE ?= devolutions.com/dvls-kubernetes-operator
32+
IMAGE_TAG_BASE ?= devolutions/dvls-kubernetes-operator
3333

3434
# BUNDLE_IMG defines the image:tag used for the bundle.
3535
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
@@ -47,7 +47,7 @@ ifeq ($(USE_IMAGE_DIGESTS), true)
4747
endif
4848

4949
# Image URL to use all building/pushing image targets
50-
IMG ?= controller:latest
50+
IMG ?= devolutions/dvls-kubernetes-operator:latest
5151
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5252
ENVTEST_K8S_VERSION = 1.25.0
5353

@@ -93,6 +93,18 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
9393
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
9494
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
9595

96+
97+
HELMIFY ?= $(LOCALBIN)/helmify
98+
99+
.PHONY: helmify
100+
helmify: $(HELMIFY) ## Download helmify locally if necessary.
101+
$(HELMIFY): $(LOCALBIN)
102+
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest
103+
104+
helm: manifests kustomize helmify ## Generate helm chart using helmify.
105+
$(KUSTOMIZE) build config/default | $(HELMIFY)
106+
107+
96108
.PHONY: fmt
97109
fmt: ## Run go fmt against code.
98110
go fmt ./...

chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

chart/Chart.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v2
2+
name: dvls-kubernetes-operator
3+
description: Devolutions Server Kubernetes Operator
4+
# A chart can be either an 'application' or a 'library' chart.
5+
#
6+
# Application charts are a collection of templates that can be packaged into versioned archives
7+
# to be deployed.
8+
#
9+
# Library charts provide useful utilities or functions for the chart developer. They're included as
10+
# a dependency of application charts to inject those utilities and functions into the rendering
11+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
12+
type: application
13+
# This is the chart version. This version number should be incremented each time you make changes
14+
# to the chart and its templates, including the app version.
15+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16+
version: 0.1.0
17+
# This is the version number of the application being deployed. This version number should be
18+
# incremented each time you make changes to the application. Versions are not expected to
19+
# follow Semantic Versioning. They should reflect the version the application is using.
20+
# It is recommended to use it with quotes.
21+
appVersion: "0.1.0"

chart/templates/_helpers.tpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "chart.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "chart.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "chart.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "chart.labels" -}}
37+
helm.sh/chart: {{ include "chart.chart" . }}
38+
{{ include "chart.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "chart.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "chart.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "chart.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "chart.fullname" . }}-ctrl-mgr-metrics-service
5+
labels:
6+
app.kubernetes.io/component: kube-rbac-proxy
7+
app.kubernetes.io/created-by: dvls-kubernetes-operator
8+
app.kubernetes.io/part-of: dvls-kubernetes-operator
9+
control-plane: controller-manager
10+
{{- include "chart.labels" . | nindent 4 }}
11+
spec:
12+
type: {{ .Values.ctrlMgrMetricsService.type }}
13+
selector:
14+
control-plane: controller-manager
15+
{{- include "chart.selectorLabels" . | nindent 4 }}
16+
ports:
17+
{{- .Values.ctrlMgrMetricsService.ports | toYaml | nindent 2 -}}

chart/templates/deployment.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ include "chart.fullname" . }}-controller-manager
5+
labels:
6+
app.kubernetes.io/component: rbac
7+
app.kubernetes.io/created-by: dvls-kubernetes-operator
8+
app.kubernetes.io/part-of: dvls-kubernetes-operator
9+
{{- include "chart.labels" . | nindent 4 }}
10+
---
11+
apiVersion: apps/v1
12+
kind: Deployment
13+
metadata:
14+
name: {{ include "chart.fullname" . }}-controller-manager
15+
labels:
16+
app.kubernetes.io/component: manager
17+
app.kubernetes.io/created-by: dvls-kubernetes-operator
18+
app.kubernetes.io/part-of: dvls-kubernetes-operator
19+
control-plane: controller-manager
20+
{{- include "chart.labels" . | nindent 4 }}
21+
spec:
22+
replicas: {{ .Values.controllerManager.replicas }}
23+
selector:
24+
matchLabels:
25+
control-plane: controller-manager
26+
{{- include "chart.selectorLabels" . | nindent 6 }}
27+
template:
28+
metadata:
29+
labels:
30+
control-plane: controller-manager
31+
{{- include "chart.selectorLabels" . | nindent 8 }}
32+
annotations:
33+
kubectl.kubernetes.io/default-container: manager
34+
spec:
35+
affinity:
36+
nodeAffinity:
37+
requiredDuringSchedulingIgnoredDuringExecution:
38+
nodeSelectorTerms:
39+
- matchExpressions:
40+
- key: kubernetes.io/arch
41+
operator: In
42+
values:
43+
- amd64
44+
- arm64
45+
- ppc64le
46+
- s390x
47+
- key: kubernetes.io/os
48+
operator: In
49+
values:
50+
- linux
51+
containers:
52+
- args:
53+
- --secure-listen-address=0.0.0.0:8443
54+
- --upstream=http://127.0.0.1:8080/
55+
- --logtostderr=true
56+
- --v=0
57+
env:
58+
- name: KUBERNETES_CLUSTER_DOMAIN
59+
value: {{ .Values.kubernetesClusterDomain }}
60+
image: {{ .Values.controllerManager.kubeRbacProxy.image.repository }}:{{ .Values.controllerManager.kubeRbacProxy.image.tag | default .Chart.AppVersion }}
61+
name: kube-rbac-proxy
62+
ports:
63+
- containerPort: 8443
64+
name: https
65+
protocol: TCP
66+
resources: {{- toYaml .Values.controllerManager.kubeRbacProxy.resources | nindent 10 }}
67+
securityContext:
68+
allowPrivilegeEscalation: false
69+
capabilities:
70+
drop:
71+
- ALL
72+
- args:
73+
- --health-probe-bind-address=:8081
74+
- --metrics-bind-address=127.0.0.1:8080
75+
- --leader-elect
76+
command:
77+
- /manager
78+
env:
79+
- name: DEVO_OPERATOR_DVLS_APPID
80+
value: {{ required "controllerManager.manager.env.devoOperatorDvlsAppid is required" .Values.controllerManager.manager.env.devoOperatorDvlsAppid }}
81+
- name: DEVO_OPERATOR_DVLS_BASEURI
82+
value: {{ required "controllerManager.manager.env.devoOperatorDvlsBaseuri is required" .Values.controllerManager.manager.env.devoOperatorDvlsBaseuri | quote }}
83+
- name: DEVO_OPERATOR_REQUEUE_DURATION
84+
value: {{ .Values.controllerManager.manager.env.devoOperatorRequeueDuration }}
85+
- name: DEVO_OPERATOR_DVLS_APPSECRET
86+
valueFrom:
87+
secretKeyRef:
88+
key: secret
89+
name: {{ include "chart.fullname" . }}-instance-secret
90+
- name: KUBERNETES_CLUSTER_DOMAIN
91+
value: {{ .Values.kubernetesClusterDomain }}
92+
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag | default .Chart.AppVersion }}
93+
livenessProbe:
94+
httpGet:
95+
path: /healthz
96+
port: 8081
97+
initialDelaySeconds: 15
98+
periodSeconds: 20
99+
name: manager
100+
readinessProbe:
101+
httpGet:
102+
path: /readyz
103+
port: 8081
104+
initialDelaySeconds: 5
105+
periodSeconds: 10
106+
resources: {{- toYaml .Values.controllerManager.manager.resources | nindent 10 }}
107+
securityContext:
108+
allowPrivilegeEscalation: false
109+
capabilities:
110+
drop:
111+
- ALL
112+
securityContext:
113+
runAsNonRoot: true
114+
seccompProfile:
115+
type: RuntimeDefault
116+
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
117+
terminationGracePeriodSeconds: 10

0 commit comments

Comments
 (0)