Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/publish-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ jobs:
- name: Set container image repository and tag
run: |
IMAGE_TAG=sha-$(echo ${{ github.sha }} | cut -c1-7)
yq -i '.controllerManager.manager.image.repository = "ghcr.io/ironcore-dev/boot-operator"' dist/chart/values.yaml
yq -i '.controllerManager.manager.image.tag = "'$IMAGE_TAG'"' dist/chart/values.yaml
yq -i '.manager.image.repository = "ghcr.io/ironcore-dev/boot-operator"' dist/chart/values.yaml
yq -i '.manager.image.tag = "'$IMAGE_TAG'"' dist/chart/values.yaml
- name: Package Helm chart with crds folder in template
run: |
Expand Down
63 changes: 35 additions & 28 deletions .github/workflows/test-chart.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
name: Test Chart

permissions:
contents: read

on:
pull_request:
types: [labeled, opened, synchronize, reopened]

permissions: {}

jobs:
test-e2e:
permissions:
contents: read
name: Run on Ubuntu
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
env:
IMG: controller:latest
steps:
- name: Clone the code
uses: actions/checkout@v7
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v7
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod

- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Verify Helm installation
run: helm version

- name: Lint Helm Chart
run: |
helm lint ./dist/chart
- name: Install the latest version of kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-$(go env GOARCH)
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
Expand All @@ -47,25 +41,38 @@ jobs:
- name: Prepare boot-operator
run: |
go mod tidy
make docker-build IMG=boot-operator:v0.1.0
kind load docker-image boot-operator:v0.1.0
make docker-build
kind load docker-image $IMG
- name: Install Helm
run: make install-helm

- name: Lint Helm Chart
run: |
helm lint ./dist/chart
- name: Install cert-manager via Helm
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--set crds.enabled=true \
--wait \
--timeout 300s
- name: Wait for cert-manager to be ready
run: |
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
# TODO: Uncomment if Prometheus is enabled
# - name: Install Prometheus Operator CRDs
# run: |
# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
# helm repo update
# helm install prometheus-crds prometheus-community/prometheus-operator-crds

- name: Install Helm chart for project
- name: Deploy manager via Helm
run: |
helm install my-release ./dist/chart --create-namespace --namespace boot-operator-system
make helm-deploy
- name: Check Helm release status
run: |
helm status my-release --namespace boot-operator-system
make helm-status
51 changes: 49 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: helm
helm: manifests kubebuilder
$(KUBEBUILDER) edit --plugins=helm/v1-alpha
helm: manifests build-installer kubebuilder
$(KUBEBUILDER) edit --plugins=helm/v2-alpha

##@ Dependencies

Expand Down Expand Up @@ -298,3 +298,50 @@ mv $(1) $(1)-$(3) ;\
} ;\
ln -sf $(1)-$(3) $(1)
endef

##@ Helm Deployment

## Helm binary to use for deploying the chart
HELM ?= helm
## Namespace to deploy the Helm release
HELM_NAMESPACE ?= boot-operator-system
## Name of the Helm release
HELM_RELEASE ?= boot-operator
## Path to the Helm chart directory
HELM_CHART_DIR ?= dist/chart
## Additional arguments to pass to helm commands
HELM_EXTRA_ARGS ?=

.PHONY: install-helm
install-helm: ## Install the latest version of Helm.
@command -v $(HELM) >/dev/null 2>&1 || { \
echo "Installing Helm..." && \
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4 | bash; \
}

.PHONY: helm-deploy
helm-deploy: install-helm ## Deploy manager to the K8s cluster via Helm. Specify an image with IMG.
IMG="$(IMG)"; $(HELM) upgrade --install $(HELM_RELEASE) $(HELM_CHART_DIR) \
--namespace $(HELM_NAMESPACE) \
--create-namespace \
--set manager.image.repository=$${IMG%:*} \
--set manager.image.tag=$${IMG##*:} \
--wait \
--timeout 5m \
$(HELM_EXTRA_ARGS)

.PHONY: helm-uninstall
helm-uninstall: ## Uninstall the Helm release from the K8s cluster.
$(HELM) uninstall $(HELM_RELEASE) --namespace $(HELM_NAMESPACE)

.PHONY: helm-status
helm-status: ## Show Helm release status.
$(HELM) status $(HELM_RELEASE) --namespace $(HELM_NAMESPACE)

.PHONY: helm-history
helm-history: ## Show Helm release history.
$(HELM) history $(HELM_RELEASE) --namespace $(HELM_NAMESPACE)

.PHONY: helm-rollback
helm-rollback: ## Rollback to previous Helm release.
$(HELM) rollback $(HELM_RELEASE) --namespace $(HELM_NAMESPACE)
13 changes: 12 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ domain: ironcore.dev
layout:
- go.kubebuilder.io/v4
plugins:
helm.kubebuilder.io/v1-alpha: {}
helm.kubebuilder.io/v2-alpha:
manifests: dist/install.yaml
output: dist
projectName: boot-operator
repo: github.com/ironcore-dev/boot-operator
resources:
Expand All @@ -19,4 +21,13 @@ resources:
kind: HTTPBootConfig
path: github.com/ironcore-dev/boot-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: ironcore.dev
group: boot
kind: IPXEBootConfig
path: github.com/ironcore-dev/boot-operator/api/v1alpha1
version: v1alpha1
version: "3"
4 changes: 4 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
resources:
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
11 changes: 9 additions & 2 deletions dist/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
apiVersion: v2
name: boot-operator
description: A Helm chart to distribute the project boot-operator
description: A Helm chart to distribute boot-operator
type: application

version: 0.1.0
appVersion: "0.1.0"
icon: "https://example.com/icon.png"

keywords:
- kubernetes
- operator

annotations:
kubebuilder.io/generated-by: kubebuilder
15 changes: 15 additions & 0 deletions dist/chart/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

The controller and CRDs have been installed in namespace {{ .Release.Namespace }}.

To verify the installation:

kubectl get pods -n {{ .Release.Namespace }}
kubectl get customresourcedefinitions

To learn more about the release, try:

$ helm status {{ .Release.Name }} -n {{ .Release.Namespace }}
$ helm get all {{ .Release.Name }} -n {{ .Release.Namespace }}
93 changes: 53 additions & 40 deletions dist/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
{{- define "chart.name" -}}
{{- if .Chart }}
{{- if .Chart.Name }}
{{- .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- else if .Values.nameOverride }}
{{ .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
boot-operator
{{- end }}
{{/*
Expand the name of the chart.
*/}}
{{- define "boot-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
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 "boot-operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
boot-operator
{{- end }}
{{- end }}


{{- define "chart.labels" -}}
{{- if .Chart.AppVersion -}}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- if .Chart.Version }}
helm.sh/chart: {{ .Chart.Version | quote }}
{{- end }}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}


{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{/*
Namespace for generated references.
Always uses the Helm release namespace.
*/}}
{{- define "boot-operator.namespaceName" -}}
{{- .Release.Namespace }}
{{- end }}


{{- define "chart.hasMutatingWebhooks" -}}
{{- $hasMutating := false }}
{{- range . }}
{{- if eq .type "mutating" }}
$hasMutating = true }}{{- end }}
{{/*
Resource name with proper truncation for Kubernetes 63-character limit.
Takes a dict with:
- .suffix: Resource name suffix (e.g., "metrics", "webhook")
- .context: Template context (root context with .Values, .Release, etc.)
Dynamically calculates safe truncation to ensure total name length <= 63 chars.
*/}}
{{- define "boot-operator.resourceName" -}}
{{- $fullname := include "boot-operator.fullname" .context }}
{{- $suffix := .suffix }}
{{- $maxLen := sub 62 (len $suffix) | int }}
{{- if gt (len $fullname) $maxLen }}
{{- printf "%s-%s" (trunc $maxLen $fullname | trimSuffix "-") $suffix | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" $fullname $suffix | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{ $hasMutating }}}}{{- end }}


{{- define "chart.hasValidatingWebhooks" -}}
{{- $hasValidating := false }}
{{- range . }}
{{- if eq .type "validating" }}
$hasValidating = true }}{{- end }}
{{/*
ServiceAccount name to use.
When enabled, use the chart's ServiceAccount name.
When disabled, serviceAccount.name must be set; use "default" to pick the namespace default ServiceAccount.
*/}}
{{- define "boot-operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.enabled }}
{{- include "boot-operator.resourceName" (dict "suffix" "controller-manager" "context" .) }}
{{- else }}
{{- required "serviceAccount.name is required when serviceAccount.enabled=false (set name: default explicitly to use the namespace default ServiceAccount)" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{ $hasValidating }}}}{{- end }}
20 changes: 20 additions & 0 deletions dist/chart/templates/cert-manager/metrics-certs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if and .Values.certManager.enabled .Values.metrics.enabled .Values.metrics.secure }}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/name: {{ include "boot-operator.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
name: {{ include "boot-operator.resourceName" (dict "suffix" "metrics-certs" "context" $) }}
namespace: {{ .Release.Namespace }}
spec:
dnsNames:
- {{ include "boot-operator.resourceName" (dict "suffix" "controller-manager-metrics-service" "context" $) }}.{{ include "boot-operator.namespaceName" $ }}.svc
- {{ include "boot-operator.resourceName" (dict "suffix" "controller-manager-metrics-service" "context" $) }}.{{ include "boot-operator.namespaceName" $ }}.svc.cluster.local
issuerRef:
kind: Issuer
name: {{ include "boot-operator.resourceName" (dict "suffix" "selfsigned-issuer" "context" $) }}
secretName: metrics-server-cert
{{- end }}
14 changes: 14 additions & 0 deletions dist/chart/templates/cert-manager/selfsigned-issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.certManager.enabled }}
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/name: {{ include "boot-operator.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app.kubernetes.io/instance: {{ .Release.Name }}
name: {{ include "boot-operator.resourceName" (dict "suffix" "selfsigned-issuer" "context" $) }}
namespace: {{ .Release.Namespace }}
spec:
selfSigned: {}
{{- end }}
Loading
Loading