Skip to content

Commit 95fa1d2

Browse files
committed
Add helm charts
1 parent 6a674a3 commit 95fa1d2

29 files changed

+1169
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release Helm Chart
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*.*.*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
helm-chart:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Helm
25+
uses: azure/setup-helm@v4
26+
with:
27+
version: v3.16.2
28+
29+
- name: Determine chart version
30+
id: chart_version
31+
run: |
32+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
33+
# Use SHA for main branch
34+
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
35+
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
36+
# Use tag version (strip 'v' prefix)
37+
CHART_VERSION="${GITHUB_REF#refs/tags/v}"
38+
else
39+
# Use PR SHA for dry run
40+
CHART_VERSION="0.0.0-$(echo ${{ github.sha }} | cut -c1-7)"
41+
fi
42+
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
43+
44+
- name: Install Kustomize
45+
run: |
46+
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
47+
mv kustomize /usr/local/bin
48+
49+
- name: Prepare CRDs folder
50+
run: |
51+
mkdir -p dist/chart/crds
52+
kustomize build config/default | yq ea 'select(.kind == "CustomResourceDefinition")' > dist/chart/crds/crds.yaml
53+
rm -rf dist/chart/templates/crd
54+
55+
- name: Package Helm chart
56+
run: |
57+
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}
58+
59+
- name: Log in to GitHub Container Registry
60+
run: |
61+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
62+
63+
- name: Push Helm chart to GHCR
64+
run: |
65+
helm push boot-operator-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts

.github/workflows/test-chart.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Test Chart
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
pull_request:
9+
10+
jobs:
11+
test-e2e:
12+
name: Run on Ubuntu
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Clone the code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- name: Install Helm
24+
run: |
25+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
26+
27+
- name: Verify Helm installation
28+
run: helm version
29+
30+
- name: Lint Helm Chart
31+
run: |
32+
helm lint ./dist/chart
33+
34+
- name: Install the latest version of kind
35+
run: |
36+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
37+
chmod +x ./kind
38+
sudo mv ./kind /usr/local/bin/kind
39+
40+
- name: Verify kind installation
41+
run: kind version
42+
43+
- name: Create kind cluster
44+
run: kind create cluster
45+
46+
- name: Prepare boot-operator
47+
run: |
48+
go mod tidy
49+
make docker-build IMG=boot-operator:v0.1.0
50+
kind load docker-image boot-operator:v0.1.0
51+
52+
- name: Install cert-manager via Helm
53+
run: |
54+
helm repo add jetstack https://charts.jetstack.io
55+
helm repo update
56+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
57+
58+
- name: Wait for cert-manager to be ready
59+
run: |
60+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
61+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
62+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
63+
64+
- name: Install Helm chart for project
65+
run: |
66+
helm install my-release ./dist/chart --create-namespace --namespace boot-operator-system
67+
68+
- name: Check Helm release status
69+
run: |
70+
helm status my-release --namespace boot-operator-system

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ e2e-deploy: manifests kustomize ## Deploy controller to the K8s cluster specifie
171171
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
172172
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
173173

174+
.PHONY: helm
175+
helm: manifests kubebuilder
176+
$(KUBEBUILDER) edit --plugins=helm/v1-alpha
177+
174178
##@ Dependencies
175179

176180
## Location to install dependencies to
@@ -187,6 +191,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
187191
ADDLICENSE ?= $(LOCALBIN)/addlicense
188192
GOIMPORTS ?= $(LOCALBIN)/goimports
189193
GEN_CRD_API_REFERENCE_DOCS ?= $(LOCALBIN)/gen-crd-api-reference-docs
194+
KUBEBUILDER ?= $(LOCALBIN)/kubebuilder-$(KUBEBUILDER_VERSION)
190195

191196
## Tool Versions
192197
KUSTOMIZE_VERSION ?= v5.5.0
@@ -199,6 +204,7 @@ GOLANGCI_LINT_VERSION ?= v2.1
199204
ADDLICENSE_VERSION ?= v1.1.1
200205
GOIMPORTS_VERSION ?= v0.31.0
201206
GEN_CRD_API_REFERENCE_DOCS_VERSION ?= v0.3.0
207+
KUBEBUILDER_VERSION ?= v4.5.1
202208

203209
.PHONY: kustomize
204210
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -257,6 +263,11 @@ gen-crd-api-reference-docs: $(GEN_CRD_API_REFERENCE_DOCS) ## Download gen-crd-ap
257263
$(GEN_CRD_API_REFERENCE_DOCS): $(LOCALBIN)
258264
$(call go-install-tool,$(GEN_CRD_API_REFERENCE_DOCS),github.com/ahmetb/gen-crd-api-reference-docs,$(GEN_CRD_API_REFERENCE_DOCS_VERSION))
259265

266+
.PHONY: kubebuilder
267+
kubebuilder: $(KUBEBUILDER) ## Download kubebuilder locally if necessary.
268+
$(KUBEBUILDER): $(LOCALBIN)
269+
$(call go-install-tool,$(KUBEBUILDER),sigs.k8s.io/kubebuilder/v4,$(KUBEBUILDER_VERSION))
270+
260271
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
261272
# $1 - target path with name of binary
262273
# $2 - package url which can be installed

PROJECT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
domain: ironcore.dev
66
layout:
77
- go.kubebuilder.io/v4
8+
plugins:
9+
helm.kubebuilder.io/v1-alpha: {}
810
projectName: boot-operator
911
repo: github.com/ironcore-dev/boot-operator
1012
resources:

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SPDX-PackageSupplier = "IronCore authors <[email protected]>"
44
SPDX-PackageDownloadLocation = "https://github.com/ironcore-dev/boot-operator"
55

66
[[annotations]]
7-
path = [".github/**", ".gitignore", "CODEOWNERS", "Dockerfile", "Makefile", "PROJECT", "config/**", "gen/**", "go.mod", "go.sum", "hack/**", "server/**", "templates/**", "internal/**", "cmd/**", "api/**", "config/**", "test/**", "CONTRIBUTING.md", "PROJECT", "mkdocs.yml", ".dockerignore", ".golangci.yml", "REUSE.toml"]
7+
path = [".github/**", ".gitignore", "CODEOWNERS", "Dockerfile", "Makefile", "PROJECT", "config/**", "dist/**", "dist/**", "gen/**", "go.mod", "go.sum", "hack/**", "server/**", "templates/**", "internal/**", "cmd/**", "api/**", "config/**", "test/**", "CONTRIBUTING.md", "PROJECT", "mkdocs.yml", ".dockerignore", ".golangci.yml", "REUSE.toml"]
88
precedence = "aggregate"
99
SPDX-FileCopyrightText = "2025 SAP SE or an SAP affiliate company and IronCore contributors"
1010
SPDX-License-Identifier = "Apache-2.0"

dist/chart/.helmignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Patterns to ignore when building Helm packages.
2+
# Operating system files
3+
.DS_Store
4+
5+
# Version control directories
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.hg/
10+
.hgignore
11+
.svn/
12+
13+
# Backup and temporary files
14+
*.swp
15+
*.tmp
16+
*.bak
17+
*.orig
18+
*~
19+
20+
# IDE and editor-related files
21+
.idea/
22+
.vscode/
23+
24+
# Helm chart artifacts
25+
dist/chart/*.tgz

dist/chart/Chart.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: boot-operator
3+
description: A Helm chart to distribute the project boot-operator
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
icon: "https://example.com/icon.png"

dist/chart/templates/_helpers.tpl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
boot-operator
9+
{{- end }}
10+
{{- else }}
11+
boot-operator
12+
{{- end }}
13+
{{- end }}
14+
15+
16+
{{- define "chart.labels" -}}
17+
{{- if .Chart.AppVersion -}}
18+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
19+
{{- end }}
20+
{{- if .Chart.Version }}
21+
helm.sh/chart: {{ .Chart.Version | quote }}
22+
{{- end }}
23+
app.kubernetes.io/name: {{ include "chart.name" . }}
24+
app.kubernetes.io/instance: {{ .Release.Name }}
25+
app.kubernetes.io/managed-by: {{ .Release.Service }}
26+
{{- end }}
27+
28+
29+
{{- define "chart.selectorLabels" -}}
30+
app.kubernetes.io/name: {{ include "chart.name" . }}
31+
app.kubernetes.io/instance: {{ .Release.Name }}
32+
{{- end }}
33+
34+
35+
{{- define "chart.hasMutatingWebhooks" -}}
36+
{{- $hasMutating := false }}
37+
{{- range . }}
38+
{{- if eq .type "mutating" }}
39+
$hasMutating = true }}{{- end }}
40+
{{- end }}
41+
{{ $hasMutating }}}}{{- end }}
42+
43+
44+
{{- define "chart.hasValidatingWebhooks" -}}
45+
{{- $hasValidating := false }}
46+
{{- range . }}
47+
{{- if eq .type "validating" }}
48+
$hasValidating = true }}{{- end }}
49+
{{- end }}
50+
{{ $hasValidating }}}}{{- end }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{- if .Values.certmanager.enable }}
2+
# Self-signed Issuer
3+
apiVersion: cert-manager.io/v1
4+
kind: Issuer
5+
metadata:
6+
labels:
7+
{{- include "chart.labels" . | nindent 4 }}
8+
name: selfsigned-issuer
9+
namespace: {{ .Release.Namespace }}
10+
spec:
11+
selfSigned: {}
12+
{{- if .Values.webhook.enable }}
13+
---
14+
# Certificate for the webhook
15+
apiVersion: cert-manager.io/v1
16+
kind: Certificate
17+
metadata:
18+
annotations:
19+
{{- if .Values.crd.keep }}
20+
"helm.sh/resource-policy": keep
21+
{{- end }}
22+
name: serving-cert
23+
namespace: {{ .Release.Namespace }}
24+
labels:
25+
{{- include "chart.labels" . | nindent 4 }}
26+
spec:
27+
dnsNames:
28+
- boot-operator.{{ .Release.Namespace }}.svc
29+
- boot-operator.{{ .Release.Namespace }}.svc.cluster.local
30+
- boot-operator-webhook-service.{{ .Release.Namespace }}.svc
31+
issuerRef:
32+
kind: Issuer
33+
name: selfsigned-issuer
34+
secretName: webhook-server-cert
35+
{{- end }}
36+
{{- if .Values.metrics.enable }}
37+
---
38+
# Certificate for the metrics
39+
apiVersion: cert-manager.io/v1
40+
kind: Certificate
41+
metadata:
42+
annotations:
43+
{{- if .Values.crd.keep }}
44+
"helm.sh/resource-policy": keep
45+
{{- end }}
46+
labels:
47+
{{- include "chart.labels" . | nindent 4 }}
48+
name: metrics-certs
49+
namespace: {{ .Release.Namespace }}
50+
spec:
51+
dnsNames:
52+
- boot-operator.{{ .Release.Namespace }}.svc
53+
- boot-operator.{{ .Release.Namespace }}.svc.cluster.local
54+
- boot-operator-metrics-service.{{ .Release.Namespace }}.svc
55+
issuerRef:
56+
kind: Issuer
57+
name: selfsigned-issuer
58+
secretName: metrics-server-cert
59+
{{- end }}
60+
{{- end }}

0 commit comments

Comments
 (0)