Skip to content

Commit d6b1c60

Browse files
Migrate Helm plugin from v1-alpha to v2-alpha
Replace the deprecated helm/v1-alpha Kubebuilder plugin with the newer helm/v2-alpha plugin. This brings bug fixes, improvements, and better alignment with Helm best practices. Additionally the kustomize setup was extended to now include a Service for the provisioning http server. Closes #187
1 parent e694141 commit d6b1c60

278 files changed

Lines changed: 10910 additions & 10914 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Dockerfile.cross
1717
go.work
1818
go.work.sum
1919

20+
# Generated build-installer
21+
dist/*
22+
2023
# Kubernetes Generated files - skip generated files, except for vendored files
2124
!vendor/**/zz_generated.*
2225

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,11 @@ docker-push: FORCE
8080
# Generate a consolidated YAML with CRDs and deployment.
8181
build-installer: FORCE generate install-kustomize
8282
@printf "\e[1;36m>> kustomize build config/default > dist/install.yaml\e[0m\n"
83-
@cd config/manager && kustomize edit set image controller=$(IMG)
84-
@mkdir -p build; kustomize build config/default > dist/install.yaml
83+
@mkdir -p dist; kustomize build config/default > dist/install.yaml
8584

8685
# Deploy controller to the k8s cluster
8786
deploy: FORCE generate install-kustomize
8887
@printf "\e[1;36m>> kustomize build config/default | kubectl apply -f -\e[0m\n"
89-
@cd config/manager && kustomize edit set image controller=$(IMG)
9088
@kustomize build config/default | kubectl apply -f -
9189

9290
# Undeploy controller from the k8s cluster
@@ -132,12 +130,14 @@ tilt-up: FORCE kind-create
132130
@printf "\e[1;36m>> tilt up --context kind-$(KIND_CLUSTER)\e[0m\n"
133131
@tilt up --context kind-$(KIND_CLUSTER)
134132

133+
manifests: generate
134+
135135
# Generate manifests e.g. CRD, RBAC etc.
136136
charts: FORCE generate
137-
@printf "\e[1;36m>> kubebuilder edit --plugins=helm/v1-alpha\e[0m\n"
138-
@mkdir dist && mv charts/network-operator dist/chart
139-
@kubebuilder edit --plugins=helm/v1-alpha
140-
@mv dist/chart charts/network-operator && rm -rf dist
137+
@printf "\e[1;36m>> kubebuilder edit --plugins=helm/v2-alpha\e[0m\n"
138+
@mv charts/network-operator charts/chart
139+
@kubebuilder edit --plugins=helm/v2-alpha --output-dir=charts
140+
@mv charts/chart charts/network-operator && rm -rf dist
141141

142142
netop-provider:
143143
@printf "\e[1;36m>> go build -o build/netop-provider ./hack/provider\e[0m\n"

Makefile.maker.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,11 @@ verbatim: |
124124
# Generate a consolidated YAML with CRDs and deployment.
125125
build-installer: FORCE generate install-kustomize
126126
@printf "\e[1;36m>> kustomize build config/default > dist/install.yaml\e[0m\n"
127-
@cd config/manager && kustomize edit set image controller=$(IMG)
128-
@mkdir -p build; kustomize build config/default > dist/install.yaml
127+
@mkdir -p dist; kustomize build config/default > dist/install.yaml
129128
130129
# Deploy controller to the k8s cluster
131130
deploy: FORCE generate install-kustomize
132131
@printf "\e[1;36m>> kustomize build config/default | kubectl apply -f -\e[0m\n"
133-
@cd config/manager && kustomize edit set image controller=$(IMG)
134132
@kustomize build config/default | kubectl apply -f -
135133
136134
# Undeploy controller from the k8s cluster
@@ -176,12 +174,14 @@ verbatim: |
176174
@printf "\e[1;36m>> tilt up --context kind-$(KIND_CLUSTER)\e[0m\n"
177175
@tilt up --context kind-$(KIND_CLUSTER)
178176
177+
manifests: generate
178+
179179
# Generate manifests e.g. CRD, RBAC etc.
180180
charts: FORCE generate
181-
@printf "\e[1;36m>> kubebuilder edit --plugins=helm/v1-alpha\e[0m\n"
182-
@mkdir dist && mv charts/network-operator dist/chart
183-
@kubebuilder edit --plugins=helm/v1-alpha
184-
@mv dist/chart charts/network-operator && rm -rf dist
181+
@printf "\e[1;36m>> kubebuilder edit --plugins=helm/v2-alpha\e[0m\n"
182+
@mv charts/network-operator charts/chart
183+
@kubebuilder edit --plugins=helm/v2-alpha --output-dir=charts
184+
@mv charts/chart charts/network-operator && rm -rf dist
185185
186186
netop-provider:
187187
@printf "\e[1;36m>> go build -o build/netop-provider ./hack/provider\e[0m\n"

PROJECT

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ layout:
77
- go.kubebuilder.io/v4
88
multigroup: true
99
plugins:
10-
helm.kubebuilder.io/v1-alpha: {}
10+
helm.kubebuilder.io/v2-alpha:
11+
manifests: dist/install.yaml
12+
output: charts
1113
projectName: network-operator
1214
repo: github.com/ironcore-dev/network-operator
1315
resources:

charts/network-operator/Chart.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dependencies:
33
repository: oci://ghcr.io/sapcc/helm-charts
44
version: 1.0.0
55
digest: sha256:7643f231cc4ebda347fd12ec62fe4445c280e2b71d27eec555f3025290f5038f
6-
generated: "2025-08-07T13:01:53.383695+02:00"
6+
generated: "2026-02-17T17:07:50.077747+01:00"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Thank you for installing {{ .Chart.Name }}.
2+
3+
Your release is named {{ .Release.Name }}.
4+
5+
The controller and CRDs have been installed in namespace {{ .Release.Namespace }}.
6+
7+
To verify the installation:
8+
9+
kubectl get pods -n {{ .Release.Namespace }}
10+
kubectl get customresourcedefinitions
11+
12+
To learn more about the release, try:
13+
14+
$ helm status {{ .Release.Name }} -n {{ .Release.Namespace }}
15+
$ helm get all {{ .Release.Name }} -n {{ .Release.Namespace }}
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
{{- define "chart.name" -}}
2-
{{- if .Chart }}
3-
{{- if .Chart.Name }}
4-
{{- .Chart.Name | trunc 63 | trimSuffix "-" }}
5-
{{- else if .Values.nameOverride }}
6-
{{ .Values.nameOverride | trunc 63 | trimSuffix "-" }}
7-
{{- else }}
8-
network-operator
9-
{{- end }}
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "network-operator.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 "network-operator.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
1016
{{- else }}
11-
network-operator
12-
{{- end }}
13-
{{- end }}
14-
15-
16-
{{- define "chart.labels" -}}
17-
{{- if .Chart.AppVersion -}}
18-
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
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 "-" }}
1922
{{- end }}
20-
{{- if .Chart.Version }}
21-
helm.sh/chart: {{ .Chart.Version | quote }}
2223
{{- end }}
23-
app.kubernetes.io/name: {{ include "chart.name" . }}
24-
app.kubernetes.io/instance: {{ .Release.Name }}
25-
app.kubernetes.io/managed-by: {{ .Release.Service }}
2624
{{- end }}
2725

28-
29-
{{- define "chart.selectorLabels" -}}
30-
app.kubernetes.io/name: {{ include "chart.name" . }}
31-
app.kubernetes.io/instance: {{ .Release.Name }}
26+
{{/*
27+
Namespace for generated references.
28+
Always uses the Helm release namespace.
29+
*/}}
30+
{{- define "network-operator.namespaceName" -}}
31+
{{- .Release.Namespace }}
3232
{{- end }}
3333

34-
35-
{{- define "chart.hasMutatingWebhooks" -}}
36-
{{- $hasMutating := false }}
37-
{{- range . }}
38-
{{- if eq .type "mutating" }}
39-
$hasMutating = true }}{{- end }}
34+
{{/*
35+
Resource name with proper truncation for Kubernetes 63-character limit.
36+
Takes a dict with:
37+
- .suffix: Resource name suffix (e.g., "metrics", "webhook")
38+
- .context: Template context (root context with .Values, .Release, etc.)
39+
Dynamically calculates safe truncation to ensure total name length <= 63 chars.
40+
*/}}
41+
{{- define "network-operator.resourceName" -}}
42+
{{- $fullname := include "network-operator.fullname" .context }}
43+
{{- $suffix := .suffix }}
44+
{{- $maxLen := sub 62 (len $suffix) | int }}
45+
{{- if gt (len $fullname) $maxLen }}
46+
{{- printf "%s-%s" (trunc $maxLen $fullname | trimSuffix "-") $suffix | trunc 63 | trimSuffix "-" }}
47+
{{- else }}
48+
{{- printf "%s-%s" $fullname $suffix | trunc 63 | trimSuffix "-" }}
4049
{{- end }}
41-
{{ $hasMutating }}}}{{- end }}
42-
43-
44-
{{- define "chart.hasValidatingWebhooks" -}}
45-
{{- $hasValidating := false }}
46-
{{- range . }}
47-
{{- if eq .type "validating" }}
48-
$hasValidating = true }}{{- end }}
4950
{{- end }}
50-
{{ $hasValidating }}}}{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if and .Values.certManager.enable .Values.metrics.enable }}
2+
apiVersion: cert-manager.io/v1
3+
kind: Certificate
4+
metadata:
5+
labels:
6+
app.kubernetes.io/managed-by: {{ .Release.Service }}
7+
app.kubernetes.io/name: {{ include "network-operator.name" . }}
8+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
name: {{ include "network-operator.resourceName" (dict "suffix" "metrics-certs" "context" $) }}
11+
namespace: {{ .Release.Namespace }}
12+
spec:
13+
dnsNames:
14+
- {{ include "network-operator.resourceName" (dict "suffix" "controller-manager-metrics-service" "context" $) }}.{{ include "network-operator.namespaceName" $ }}.svc
15+
- {{ include "network-operator.resourceName" (dict "suffix" "controller-manager-metrics-service" "context" $) }}.{{ include "network-operator.namespaceName" $ }}.svc.cluster.local
16+
issuerRef:
17+
kind: Issuer
18+
name: {{ include "network-operator.resourceName" (dict "suffix" "selfsigned-issuer" "context" $) }}
19+
secretName: metrics-server-cert
20+
{{- end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- if .Values.certManager.enable }}
2+
apiVersion: cert-manager.io/v1
3+
kind: Issuer
4+
metadata:
5+
labels:
6+
app.kubernetes.io/managed-by: {{ .Release.Service }}
7+
app.kubernetes.io/name: {{ include "network-operator.name" . }}
8+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
name: {{ include "network-operator.resourceName" (dict "suffix" "selfsigned-issuer" "context" $) }}
11+
namespace: {{ .Release.Namespace }}
12+
spec:
13+
selfSigned: {}
14+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if .Values.certManager.enable }}
2+
apiVersion: cert-manager.io/v1
3+
kind: Certificate
4+
metadata:
5+
labels:
6+
app.kubernetes.io/managed-by: {{ .Release.Service }}
7+
app.kubernetes.io/name: {{ include "network-operator.name" . }}
8+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
name: {{ include "network-operator.resourceName" (dict "suffix" "serving-cert" "context" $) }}
11+
namespace: {{ .Release.Namespace }}
12+
spec:
13+
dnsNames:
14+
- {{ include "network-operator.resourceName" (dict "suffix" "webhook-service" "context" $) }}.{{ .Release.Namespace }}.svc
15+
- {{ include "network-operator.resourceName" (dict "suffix" "webhook-service" "context" $) }}.{{ .Release.Namespace }}.svc.cluster.local
16+
issuerRef:
17+
kind: Issuer
18+
name: {{ include "network-operator.resourceName" (dict "suffix" "selfsigned-issuer" "context" $) }}
19+
secretName: webhook-server-cert
20+
{{- end }}

0 commit comments

Comments
 (0)