Skip to content

Commit daec1d6

Browse files
committed
add helm deployment
Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt> On-behalf-of: @SAP mangirdas.judeikis@sap.com
1 parent 21d91e9 commit daec1d6

5 files changed

Lines changed: 203 additions & 49 deletions

File tree

.github/workflows/image.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
- uses: sigstore/cosign-installer@v3.7.0
2727
- name: Install ko
2828
run: go install github.com/google/ko@latest
29+
30+
- name: Install Helm
31+
uses: azure/setup-helm@v3
32+
with:
33+
version: 'v3.12.0'
2934

3035
- name: Set LDFLAGS
3136
run: echo LDFLAGS="$(make ldflags)" | tee -a >> $GITHUB_ENV
@@ -62,6 +67,42 @@ jobs:
6267
-a run_id=${{ github.run_id }} \
6368
-a run_attempt=${{ github.run_attempt }}
6469
70+
- name: Package and push Helm charts as OCI
71+
env:
72+
HELM_EXPERIMENTAL_OCI: 1
73+
run: |
74+
# Login to GitHub Container Registry for Helm
75+
echo "${{ github.token }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
76+
77+
# Set chart version - use tag name if available, otherwise use semver format
78+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
79+
CHART_VERSION="${{ github.ref_name }}"
80+
# Remove 'v' prefix if present
81+
CHART_VERSION="${CHART_VERSION#v}"
82+
else
83+
CHART_VERSION="0.0.0-${{ github.sha }}"
84+
fi
85+
86+
# Package and push each chart in deploy/charts/
87+
for chart_dir in deploy/charts/*/; do
88+
if [ -f "${chart_dir}Chart.yaml" ]; then
89+
chart_name=$(basename "$chart_dir")
90+
echo "Processing chart: $chart_name"
91+
92+
# Update chart version and appVersion in Chart.yaml
93+
sed -i "s/^version:.*/version: ${CHART_VERSION}/" "${chart_dir}Chart.yaml"
94+
sed -i "s/^appVersion:.*/appVersion: ${CHART_VERSION}/" "${chart_dir}Chart.yaml"
95+
96+
# Package the chart
97+
helm package "$chart_dir" --version "${CHART_VERSION}"
98+
99+
# Push to GitHub Container Registry
100+
helm push "${chart_name}-${CHART_VERSION}.tgz" "oci://ghcr.io/${{ github.repository_owner }}/charts"
101+
102+
echo "Helm chart pushed to oci://ghcr.io/${{ github.repository_owner }}/charts/${chart_name}:${CHART_VERSION}"
103+
fi
104+
done
105+
65106
- uses: actions/delete-package-versions@v3
66107
with:
67108
package-name: 'kube-bind'

Makefile

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ GOBIN_DIR=$(abspath ./bin )
2424
PATH := $(GOBIN_DIR):$(TOOLS_GOBIN_DIR):$(PATH)
2525
TMPDIR := $(shell mktemp -d)
2626

27+
# Image build configuration
28+
# REV is the short git sha of latest commit.
29+
REV=$(shell git rev-parse --short HEAD)
30+
IMAGE_REPO ?= kube-bind
31+
2732
# Detect the path used for the install target
2833
ifeq (,$(shell go env GOBIN))
2934
INSTALL_GOBIN=$(shell go env GOPATH)/bin
@@ -296,20 +301,6 @@ test-e2e-contrib-kcp: $(DEX) $(KCP)
296301
$(CONTRIBS_E2E):
297302
cd contrib/$(patsubst test-e2e-contrib-%,%,$@) && $(GO_TEST) -race -count $(COUNT) $(E2E_PARALLELISM_FLAG) ./test/e2e/...
298303

299-
DESTROY_KIND_CLUSTER ?= true
300-
REUSE_KIND_CLUSTER_SUFFIX ?= ""
301-
KIND_CLUSTER_NAME ?= kube-bind
302-
303-
.PHONY: test-e2e-kind
304-
test-e2e-kind: build image-local
305-
echo "Running kube-bind e2e tests"
306-
KUBE_BIND_BACKEND_IMAGE=$(KO_DOCKER_REPO)/backend:$(REV) \
307-
KUBE_BIND_KONNECTOR_IMAGE=$(KO_DOCKER_REPO)/konnector:$(REV) \
308-
$(GO_TEST) -v ./test/e2e-kind/... \
309-
-destroy-kind-cluster=$(DESTROY_KIND_CLUSTER) \
310-
-collect-logs=true
311-
echo "Kube-bind e2e tests completed"
312-
313304
.PHONY: test
314305
ifdef USE_GOTESTSUM
315306
test: $(GOTESTSUM)
@@ -385,38 +376,91 @@ deploy-docs: venv ## Deploy docs
385376
. $(VENV)/activate; \
386377
REMOTE=$(REMOTE) BRANCH=$(BRANCH) docs/scripts/deploy-docs.sh
387378

388-
# Image build configuration
389-
# REV is the short git sha of latest commit.
390-
REV=$(shell git rev-parse --short HEAD)
391-
KIND_CLUSTER ?= backend
392-
KO_DOCKER_REPO ?= kube-bind
393-
379+
# Example: make IMAGE_REPO=ghcr.io/<username> image-local
394380
.PHONY: image-local
395381
image-local:
396382
@echo "Building images locally with tag $(REV)"
397383
@command -v ko >/dev/null 2>&1 || { echo "ko not found. Install with: go install github.com/google/ko@latest"; exit 1; }
398384

399385
@echo "Building konnector image locally..."
400-
KO_DOCKER_REPO=$(KO_DOCKER_REPO) ko build \
386+
KO_DOCKER_REPO=$(IMAGE_REPO) ko build \
401387
--local \
402388
-B \
403389
-t $(REV) \
404390
./cmd/konnector
405391

406392
@echo "Building backend image locally..."
407-
KO_DOCKER_REPO=$(KO_DOCKER_REPO) ko build \
393+
KO_DOCKER_REPO=$(IMAGE_REPO) ko build \
408394
--local \
409395
-B \
410396
-t $(REV) \
411397
./cmd/backend
412398

413-
@echo "Successfully built local images with tag $(REV)"
399+
@echo "Successfully built local images:"
400+
@echo " $(IMAGE_REPO)/konnector:$(REV)"
401+
@echo " $(IMAGE_REPO)/backend:$(REV)"
402+
403+
.PHONY: helm-build-local
404+
helm-build-local: ## Build and package Helm charts locally for testing
405+
@echo "Building Helm charts locally..."
406+
@command -v helm >/dev/null 2>&1 || { echo "helm not found. Install from: https://helm.sh/docs/intro/install/"; exit 1; }
407+
408+
@# Set chart version to semver format for local builds (0.0.0-<git-sha>)
409+
CHART_VERSION="0.0.0-$(REV)"; \
410+
for chart_dir in deploy/charts/*/; do \
411+
if [ -f "$${chart_dir}Chart.yaml" ]; then \
412+
chart_name=$$(basename "$$chart_dir"); \
413+
echo "Processing chart: $$chart_name"; \
414+
\
415+
cp "$${chart_dir}Chart.yaml" "$${chart_dir}Chart.yaml.bak"; \
416+
sed -i.tmp "s/^version:.*/version: $$CHART_VERSION/" "$${chart_dir}Chart.yaml"; \
417+
sed -i.tmp "s/^appVersion:.*/appVersion: $$CHART_VERSION/" "$${chart_dir}Chart.yaml"; \
418+
rm -f "$${chart_dir}Chart.yaml.tmp"; \
419+
\
420+
helm package "$$chart_dir" --version "$$CHART_VERSION" --destination ./bin/; \
421+
echo "Packaged: ./bin/$$chart_name-$$CHART_VERSION.tgz"; \
422+
\
423+
mv "$${chart_dir}Chart.yaml.bak" "$${chart_dir}Chart.yaml"; \
424+
fi; \
425+
done
426+
@echo "Helm charts built successfully in ./bin/"
427+
428+
.PHONY: helm-clean
429+
helm-clean: ## Clean up built helm charts
430+
rm -f ./bin/*.tgz
431+
432+
.PHONY: helm-push-local
433+
helm-push-local: ## Push Helm charts to IMAGE_REPO registry
434+
@echo "Pushing Helm charts to registry: $(IMAGE_REPO)"
435+
@command -v helm >/dev/null 2>&1 || { echo "helm not found. Install from: https://helm.sh/docs/intro/install/"; exit 1; }
436+
437+
CHART_VERSION="0.0.0-$(REV)"; \
438+
export HELM_EXPERIMENTAL_OCI=1; \
439+
for chart_file in ./bin/*-$$CHART_VERSION.tgz; do \
440+
if [ -f "$$chart_file" ]; then \
441+
chart_filename=$$(basename "$$chart_file"); \
442+
chart_name=$${chart_filename%-$$CHART_VERSION.tgz}; \
443+
if [[ "$$chart_name" =~ [[:space:]] ]]; then \
444+
echo "Skipping chart with invalid name: '$$chart_name' (contains spaces)"; \
445+
continue; \
446+
fi; \
447+
echo "Pushing $$chart_name to $(IMAGE_REPO)"; \
448+
helm push "$$chart_file" "oci://$(IMAGE_REPO)/charts"; \
449+
echo "Chart available at: oci://$(IMAGE_REPO)/charts/$$chart_name:$$CHART_VERSION"; \
450+
fi; \
451+
done
414452

415-
.PHONY: kind-load
416-
kind-load:
417-
@echo "Loading images into kind cluster '$(KIND_CLUSTER)'"
418-
kind load docker-image $(KO_DOCKER_REPO)/konnector:$(REV) --name $(KIND_CLUSTER)
419-
kind load docker-image $(KO_DOCKER_REPO)/backend:$(REV) --name $(KIND_CLUSTER)
420-
@echo "Successfully loaded images into kind cluster '$(KIND_CLUSTER)'"
453+
.PHONY: helm-test
454+
helm-test: helm-build-local ## Test Helm chart installation (dry-run)
455+
@echo "Testing Helm chart installation..."
456+
CHART_VERSION="0.0.0-$(REV)"; \
457+
for chart_dir in deploy/charts/*/; do \
458+
if [ -f "$${chart_dir}Chart.yaml" ]; then \
459+
chart_name=$$(basename "$$chart_dir"); \
460+
echo "Testing chart: $$chart_name"; \
461+
helm install test-$$chart_name "./bin/$$chart_name-$$CHART_VERSION.tgz" --dry-run --debug; \
462+
echo "✓ Chart $$chart_name passes dry-run test"; \
463+
fi; \
464+
done
421465

422466
include Makefile.venv

backend/controllers/rbac.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ package controllers
2727
// These permissions allow the backend to grant RBAC permissions for exported resources
2828
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=*
2929
//+kubebuilder:rbac:groups="",resources=secrets,verbs=*
30+
31+
// Wildcard permissions to allow granting RBAC permissions for any API group/resource
32+
// This is needed for kube-bind to create ClusterRoles with permissions for bound resources
33+
// In a way this makes all the above specific permissions redundant, but they are left for clarity and traceability.
34+
//+kubebuilder:rbac:groups=*,resources=*,verbs=*

deploy/charts/backend/templates/role.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ rules:
2424
- patch
2525
- update
2626
- watch
27+
- apiGroups:
28+
- '*'
29+
resources:
30+
- '*'
31+
verbs:
32+
- '*'
2733
- apiGroups:
2834
- apiextensions.k8s.io
2935
resources:

docs/content/setup/helm.md

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description: >
55

66
# Installation with Helm
77

8-
Kube-bind can be installed on an existing Kubernetes cluster using the official Helm chart.
9-
There are 2 helm charts available: `kube-bind/backend` for service providers and `kube-bind/konnectors` for service consumers.
8+
Kube-bind can be installed on an existing Kubernetes cluster using the official Helm OCI charts.
9+
The backend chart is available as an OCI image for service providers, with konnector charts coming soon for service consumers.
1010

1111
## Quick Start
1212

@@ -23,25 +23,39 @@ The following prerequisites are required. Click the links below for detailed set
2323

2424
### Install Kube-Bind Backend
2525

26-
1. **Add the Helm repository:**
27-
```bash
28-
helm repo add kube-bind https://kube-bind.github.io/helm-charts
29-
helm repo update
30-
```
26+
1. **Get the latest chart version:**
27+
28+
Visit the [releases page](https://github.com/kube-bind/kube-bind/releases) or check available versions:
29+
```bash
30+
# For latest tag version (recommended for production):
31+
VERSION=$(curl -s https://api.github.com/repos/kube-bind/kube-bind/releases/latest | grep '"tag_name"' | cut -d'"' -f4 | sed 's/v//')
32+
33+
# Or use a specific development version:
34+
# VERSION=0.0.0-<git-sha>
35+
```
3136

3237
2. **Configure your values:**
33-
Edit `deploy/charts/backend/examples/values-local-development.yaml` and replace the placeholder values:
34-
- `### REPLACE ME ###` with your actual OIDC credentials
35-
- Update hostnames to match your setup
36-
37-
3. **Install the backend:**
38-
```bash
39-
helm upgrade --install \
40-
--namespace kube-bind \
41-
--create-namespace \
42-
--values ./deploy/charts/backend/examples/values-local-development.yaml \
43-
kube-bind kube-bind/backend
44-
```
38+
39+
Edit `deploy/charts/backend/examples/values-local-development.yaml` and replace the placeholder values:
40+
- `### REPLACE ME ###` with your actual OIDC credentials
41+
- Update hostnames to match your setup
42+
43+
3. **Install the backend using OCI chart:**
44+
```bash
45+
# Using latest release version
46+
helm upgrade --install \
47+
--namespace kube-bind \
48+
--create-namespace \
49+
--values ./deploy/charts/backend/examples/values-local-development.yaml \
50+
kube-bind oci://ghcr.io/kube-bind/charts/backend --version ${VERSION}
51+
52+
# Or install a specific development version
53+
# helm upgrade --install \
54+
# --namespace kube-bind \
55+
# --create-namespace \
56+
# --values ./deploy/charts/backend/examples/values-local-development.yaml \
57+
# kube-bind oci://ghcr.io/kube-bind/charts/backend --version 0.0.0-21d91e9
58+
```
4559

4660
4. **Seed with example resources (optional):**
4761
```bash
@@ -66,6 +80,11 @@ kind create cluster --name kube-bind-test
6680
### Helm
6781
Install Helm 3.x from [https://helm.sh/docs/intro/install/](https://helm.sh/docs/intro/install/)
6882

83+
**Note**: Helm 3.8+ is required for OCI chart support. Enable experimental OCI support if needed:
84+
```bash
85+
export HELM_EXPERIMENTAL_OCI=1
86+
```
87+
6988
### cert-manager Setup
7089

7190
Install cert-manager for automatic TLS certificate management:
@@ -239,4 +258,43 @@ The example values file at `deploy/charts/backend/examples/values-local-developm
239258
- **Cookie keys**: Generate with `openssl rand -base64 32`
240259
- **Hostnames**: Update to match your actual domains
241260

242-
For production deployments, create your own values file based on the example.
261+
For production deployments, create your own values file based on the example.
262+
263+
---
264+
265+
## Available OCI Charts
266+
267+
Kube-bind Helm charts are published as OCI images to GitHub Container Registry:
268+
269+
### Backend Chart
270+
- **Registry**: `oci://ghcr.io/kube-bind/charts/backend`
271+
- **Latest Release**: Use the latest tag version (e.g., `1.0.0`)
272+
- **Development Builds**: Available as `0.0.0-<git-sha>` format for each commit to main
273+
274+
### Finding Available Versions
275+
276+
**Release versions:**
277+
```bash
278+
# List all releases
279+
curl -s https://api.github.com/repos/kube-bind/kube-bind/releases | grep '"tag_name"' | head -5
280+
281+
# Get latest release version
282+
VERSION=$(curl -s https://api.github.com/repos/kube-bind/kube-bind/releases/latest | grep '"tag_name"' | cut -d'"' -f4 | sed 's/v//')
283+
echo "Latest version: ${VERSION}"
284+
```
285+
286+
**Development versions:**
287+
Development charts are built from every commit to the main branch with the format `0.0.0-<short-git-sha>`.
288+
289+
### Installing Different Versions
290+
291+
```bash
292+
# Install latest stable release (recommended for production)
293+
helm upgrade --install kube-bind oci://ghcr.io/kube-bind/charts/backend --version ${VERSION}
294+
295+
# Install specific release version
296+
helm upgrade --install kube-bind oci://ghcr.io/kube-bind/charts/backend --version 1.0.0
297+
298+
# Install development build (for testing)
299+
helm upgrade --install kube-bind oci://ghcr.io/kube-bind/charts/backend --version 0.0.0-a1b2c3d
300+
```

0 commit comments

Comments
 (0)