Skip to content

Commit f1a3cd0

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 f1a3cd0

5 files changed

Lines changed: 206 additions & 46 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: 74 additions & 24 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
@@ -291,25 +296,10 @@ CONTRIBS_E2E := $(patsubst %,test-e2e-contrib-%,$(CONTRIBS))
291296
.PHONY: test-e2e-contribs $(CONTRIBS_E2E)
292297
test-e2e-contribs: $(CONTRIBS_E2E) ## Run e2e tests for external integrations
293298

294-
.PHONY: test-e2e-contrib-kcp
295299
test-e2e-contrib-kcp: $(DEX) $(KCP)
296300
$(CONTRIBS_E2E):
297301
cd contrib/$(patsubst test-e2e-contrib-%,%,$@) && $(GO_TEST) -race -count $(COUNT) $(E2E_PARALLELISM_FLAG) ./test/e2e/...
298302

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-
313303
.PHONY: test
314304
ifdef USE_GOTESTSUM
315305
test: $(GOTESTSUM)
@@ -385,32 +375,29 @@ deploy-docs: venv ## Deploy docs
385375
. $(VENV)/activate; \
386376
REMOTE=$(REMOTE) BRANCH=$(BRANCH) docs/scripts/deploy-docs.sh
387377

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-
378+
# Example: make IMAGE_REPO=ghcr.io/<username> image-local
394379
.PHONY: image-local
395380
image-local:
396381
@echo "Building images locally with tag $(REV)"
397382
@command -v ko >/dev/null 2>&1 || { echo "ko not found. Install with: go install github.com/google/ko@latest"; exit 1; }
398383

399384
@echo "Building konnector image locally..."
400-
KO_DOCKER_REPO=$(KO_DOCKER_REPO) ko build \
385+
KO_DOCKER_REPO=$(IMAGE_REPO) ko build \
401386
--local \
402387
-B \
403388
-t $(REV) \
404389
./cmd/konnector
405390

406391
@echo "Building backend image locally..."
407-
KO_DOCKER_REPO=$(KO_DOCKER_REPO) ko build \
392+
KO_DOCKER_REPO=$(IMAGE_REPO) ko build \
408393
--local \
409394
-B \
410395
-t $(REV) \
411396
./cmd/backend
412397

413-
@echo "Successfully built local images with tag $(REV)"
398+
@echo "Successfully built local images:"
399+
@echo " $(IMAGE_REPO)/konnector:$(REV)"
400+
@echo " $(IMAGE_REPO)/backend:$(REV)"
414401

415402
.PHONY: kind-load
416403
kind-load:
@@ -419,4 +406,67 @@ kind-load:
419406
kind load docker-image $(KO_DOCKER_REPO)/backend:$(REV) --name $(KIND_CLUSTER)
420407
@echo "Successfully loaded images into kind cluster '$(KIND_CLUSTER)'"
421408

409+
.PHONY: helm-build-local
410+
helm-build-local: ## Build and package Helm charts locally for testing
411+
@echo "Building Helm charts locally..."
412+
@command -v helm >/dev/null 2>&1 || { echo "helm not found. Install from: https://helm.sh/docs/intro/install/"; exit 1; }
413+
414+
@# Set chart version to semver format for local builds (0.0.0-<git-sha>)
415+
CHART_VERSION="0.0.0-$(REV)"; \
416+
for chart_dir in deploy/charts/*/; do \
417+
if [ -f "$${chart_dir}Chart.yaml" ]; then \
418+
chart_name=$$(basename "$$chart_dir"); \
419+
echo "Processing chart: $$chart_name"; \
420+
\
421+
cp "$${chart_dir}Chart.yaml" "$${chart_dir}Chart.yaml.bak"; \
422+
sed -i.tmp "s/^version:.*/version: $$CHART_VERSION/" "$${chart_dir}Chart.yaml"; \
423+
sed -i.tmp "s/^appVersion:.*/appVersion: $$CHART_VERSION/" "$${chart_dir}Chart.yaml"; \
424+
rm -f "$${chart_dir}Chart.yaml.tmp"; \
425+
\
426+
helm package "$$chart_dir" --version "$$CHART_VERSION" --destination ./bin/; \
427+
echo "Packaged: ./bin/$$chart_name-$$CHART_VERSION.tgz"; \
428+
\
429+
mv "$${chart_dir}Chart.yaml.bak" "$${chart_dir}Chart.yaml"; \
430+
fi; \
431+
done
432+
@echo "Helm charts built successfully in ./bin/"
433+
434+
.PHONY: helm-clean
435+
helm-clean: ## Clean up built helm charts
436+
rm -f ./bin/*.tgz
437+
438+
.PHONY: helm-push-local
439+
helm-push-local: ## Push Helm charts to IMAGE_REPO registry
440+
@echo "Pushing Helm charts to registry: $(IMAGE_REPO)"
441+
@command -v helm >/dev/null 2>&1 || { echo "helm not found. Install from: https://helm.sh/docs/intro/install/"; exit 1; }
442+
443+
CHART_VERSION="0.0.0-$(REV)"; \
444+
export HELM_EXPERIMENTAL_OCI=1; \
445+
for chart_file in ./bin/*-$$CHART_VERSION.tgz; do \
446+
if [ -f "$$chart_file" ]; then \
447+
chart_filename=$$(basename "$$chart_file"); \
448+
chart_name=$${chart_filename%-$$CHART_VERSION.tgz}; \
449+
if [[ "$$chart_name" =~ [[:space:]] ]]; then \
450+
echo "Skipping chart with invalid name: '$$chart_name' (contains spaces)"; \
451+
continue; \
452+
fi; \
453+
echo "Pushing $$chart_name to $(IMAGE_REPO)"; \
454+
helm push "$$chart_file" "oci://$(IMAGE_REPO)/charts"; \
455+
echo "Chart available at: oci://$(IMAGE_REPO)/charts/$$chart_name:$$CHART_VERSION"; \
456+
fi; \
457+
done
458+
459+
.PHONY: helm-test
460+
helm-test: helm-build-local ## Test Helm chart installation (dry-run)
461+
@echo "Testing Helm chart installation..."
462+
CHART_VERSION="0.0.0-$(REV)"; \
463+
for chart_dir in deploy/charts/*/; do \
464+
if [ -f "$${chart_dir}Chart.yaml" ]; then \
465+
chart_name=$$(basename "$$chart_dir"); \
466+
echo "Testing chart: $$chart_name"; \
467+
helm install test-$$chart_name "./bin/$$chart_name-$$CHART_VERSION.tgz" --dry-run --debug; \
468+
echo "✓ Chart $$chart_name passes dry-run test"; \
469+
fi; \
470+
done
471+
422472
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: 80 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
<---
1+
---
22
description: >
33
Install kube-bind on an existing Kubernetes cluster via the official Helm chart.
44
---
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

13-
**Important**: Current version of kube-bind uses application level redirect (HTTP 302) to CLI. Your ingress controller must support this behavior.
13+
**Important**: Current version of kube-bind uses application-level redirect (HTTP 302) to CLI. Your ingress controller must support this behavior.
1414

1515
## Prerequisites & Setup Guides
1616

@@ -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)