Skip to content

Commit bc97061

Browse files
committed
Publish docker images and helm chart also to Github Container Registry
1 parent 8d0edd2 commit bc97061

38 files changed

+337
-228
lines changed

.github/workflows/build-push-docker.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/build-push-kafka-docker.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags-ignore:
6+
- 'kafka-*'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
# GitHub Container Registry
14+
GHCR_REGISTRY: ghcr.io
15+
# github.repository as <account>/<repo>
16+
GHCR_IMAGE_NAME: ${{ github.repository }}
17+
# Docker Hub image name
18+
DOCKERHUB_IMAGE: adobe/kafka-operator
19+
20+
jobs:
21+
prepare:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
outputs:
26+
tag: ${{ steps.vars.outputs.tag }}
27+
built_at: ${{ steps.date.outputs.built_at }}
28+
steps:
29+
- name: Get tag name
30+
id: vars
31+
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
32+
- name: Set Release Date
33+
id: date
34+
run: |
35+
echo "built_at=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT
36+
37+
operator-test:
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: read
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v5
44+
- name: Set up Go 1.25
45+
uses: actions/setup-go@v5
46+
with:
47+
go-version: '1.25'
48+
id: go
49+
- name: Set up Go for root
50+
run: |
51+
sudo ln -sf `which go` `sudo which go` || true
52+
sudo go version
53+
- name: get go version
54+
run: go version
55+
- name: Gofmt and License checks
56+
run: make check
57+
- name: unit tests
58+
run: make test
59+
60+
build-operator:
61+
runs-on: ubuntu-latest
62+
needs: [prepare, operator-test]
63+
permissions:
64+
contents: read
65+
packages: write
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v5
69+
- name: Set up QEMU
70+
uses: docker/setup-qemu-action@v3
71+
- name: Set up Docker Buildx
72+
uses: docker/setup-buildx-action@v3
73+
- name: Login to DockerHub Registry
74+
uses: docker/login-action@v3
75+
with:
76+
username: ${{ secrets.DOCKER_USERNAME }}
77+
password: ${{ secrets.DOCKER_PASSWORD }}
78+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
79+
uses: docker/login-action@v3
80+
with:
81+
registry: ${{ env.GHCR_REGISTRY }}
82+
username: ${{ github.actor }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
- name: Extract Docker metadata
85+
id: meta
86+
uses: docker/metadata-action@v5
87+
with:
88+
images: |
89+
${{ env.DOCKERHUB_IMAGE }}
90+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
91+
tags: |
92+
type=ref,event=tag
93+
labels: |
94+
org.opencontainers.image.description=Kafka Operator for Kubernetes
95+
- name: Build and push operator docker image
96+
uses: docker/build-push-action@v6
97+
with:
98+
context: .
99+
file: ./Dockerfile
100+
build-args: |
101+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
102+
BUILT_AT=${{ needs.prepare.outputs.built_at }}
103+
GIT_SHA=${{ github.sha }}
104+
tags: ${{ steps.meta.outputs.tags }}
105+
labels: ${{ steps.meta.outputs.labels }}
106+
annotations: ${{ steps.meta.outputs.annotations }}
107+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
108+
109+
release-helm:
110+
runs-on: ubuntu-latest
111+
needs: [prepare, build-operator]
112+
permissions:
113+
contents: read
114+
packages: write
115+
steps:
116+
- name: Checkout code
117+
uses: actions/checkout@v5
118+
- name: Update Chart.yaml version and values.yaml image tag
119+
run: |
120+
sed -i "s/^version:.*/version: \"${{ needs.prepare.outputs.tag }}\"/" charts/kafka-operator/Chart.yaml
121+
sed -i "s/^appVersion:.*/appVersion: \"${{ needs.prepare.outputs.tag }}\"/" charts/kafka-operator/Chart.yaml
122+
# Ensure consistent space-based indentation and update tag
123+
sed -i 's/\t/ /g' charts/kafka-operator/values.yaml
124+
sed -i "/^operator:/,/^[^[:space:]]/ { /^[[:space:]]*image:/,/^[[:space:]]*[^[:space:]]/ s/^[[:space:]]*tag:.*/ tag: \"${{ needs.prepare.outputs.tag }}\"/; }" charts/kafka-operator/values.yaml
125+
- name: Push Helm Chart to GHCR
126+
uses: appany/[email protected]
127+
with:
128+
name: kafka-operator
129+
repository: ${{ github.repository_owner }}/helm-charts
130+
tag: ${{ needs.prepare.outputs.tag }}
131+
path: charts/kafka-operator
132+
registry: ${{ env.GHCR_REGISTRY }}
133+
registry_username: ${{ github.actor }}
134+
registry_password: ${{ secrets.GITHUB_TOKEN }}
135+
update_dependencies: 'true'
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: kafka-release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'kafka-*'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
# GitHub Container Registry
14+
GHCR_REGISTRY: ghcr.io
15+
# github.repository as <account>/<repo>
16+
GHCR_IMAGE_NAME: ${{ github.repository }}/kafka
17+
# Docker Hub image name
18+
DOCKERHUB_IMAGE: adobe/kafka
19+
20+
jobs:
21+
prepare:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
outputs:
26+
tag: ${{ steps.vars.outputs.tag }}
27+
built_at: ${{ steps.date.outputs.built_at }}
28+
steps:
29+
- name: Get tag name
30+
id: vars
31+
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
32+
- name: Set Release Date
33+
id: date
34+
run: |
35+
echo "built_at=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT
36+
37+
build-kafka:
38+
runs-on: ubuntu-latest
39+
needs: prepare
40+
permissions:
41+
contents: read
42+
packages: write
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v5
46+
- name: Set up QEMU
47+
uses: docker/setup-qemu-action@v3
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v3
50+
- name: Login to DockerHub Registry
51+
if: startsWith(github.ref, 'refs/tags/')
52+
uses: docker/login-action@v3
53+
with:
54+
username: ${{ secrets.DOCKER_USERNAME }}
55+
password: ${{ secrets.DOCKER_PASSWORD }}
56+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
57+
if: startsWith(github.ref, 'refs/tags/')
58+
uses: docker/login-action@v3
59+
with:
60+
registry: ${{ env.GHCR_REGISTRY }}
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
- name: Extract Docker metadata
64+
id: meta
65+
uses: docker/metadata-action@v5
66+
with:
67+
images: |
68+
${{ env.DOCKERHUB_IMAGE }}
69+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
70+
tags: |
71+
type=match,pattern=kafka-(.*),group=1
72+
labels: |
73+
org.opencontainers.image.description=Apache Kafka with OpenJDK 21
74+
- name: Build and push kafka image
75+
uses: docker/build-push-action@v6
76+
with:
77+
context: docker/kafka
78+
platforms: linux/amd64,linux/arm64
79+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
80+
tags: ${{ steps.meta.outputs.tags }}
81+
labels: ${{ steps.meta.outputs.labels }}
82+
annotations: ${{ steps.meta.outputs.annotations }}
83+
build-args: |
84+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
85+
BUILT_AT=${{ needs.prepare.outputs.built_at }}
86+
COMMIT=${{ github.sha }}

Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ ARG BUILDPLATFORM
55
ARG TARGETPLATFORM
66
ARG TARGETOS
77
ARG TARGETARCH
8+
ARG VERSION
9+
ARG BUILT_AT
10+
ARG GIT_SHA
11+
812
RUN echo "BUILDPLATFORM: ${BUILDPLATFORM}, TARGETPLATFORM: ${TARGETPLATFORM}, TARGETOS: ${TARGETOS}, TARGETARCH: ${TARGETARCH}"
913

1014
WORKDIR /workspace
@@ -30,7 +34,19 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODUL
3034

3135
# Use distroless as minimal base image to package the manager binary
3236
# Refer to https://github.com/GoogleContainerTools/distroless for more details
33-
FROM --platform=${TARGETPLATFORM:-linux/amd64} gcr.io/distroless/static-debian11:nonroot
37+
FROM gcr.io/distroless/static-debian11:nonroot
38+
39+
# Add metadata labels
40+
LABEL org.opencontainers.image.title="Kafka Operator"
41+
LABEL org.opencontainers.image.description="Kafka Operator for Kubernetes"
42+
LABEL org.opencontainers.image.vendor="Adobe"
43+
LABEL org.opencontainers.image.licenses="Apache-2.0"
44+
LABEL org.opencontainers.image.source="https://github.com/adobe/koperator"
45+
LABEL org.opencontainers.image.documentation="https://github.com/adobe/koperator/blob/main/README.md"
46+
LABEL org.opencontainers.image.version="${VERSION}"
47+
LABEL org.opencontainers.image.created="${BUILT_AT}"
48+
LABEL org.opencontainers.image.revision="${GIT_SHA}"
49+
3450
WORKDIR /
3551
COPY --from=builder /workspace/manager .
3652
ENTRYPOINT ["/manager"]

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ zookeeper-operator-54444dbd9d-2tccj 1/1 Running 0 28m
101101

102102
### Install Koperator
103103

104-
You can deploy Koperator using a Helm chart. Complete the following steps.
104+
You can deploy Koperator using a Helm chart from GitHub Container Registry (OCI). Complete the following steps.
105105

106106
1. Install the Koperator `CustomResourceDefinition` resources (adjust the version number to the Koperator release you want to install). This is performed in a separate step to allow you to uninstall and reinstall Koperator without deleting your already installed custom resources.
107107

@@ -112,10 +112,30 @@ kubectl apply -f https://raw.githubusercontent.com/adobe/koperator/refs/heads/ma
112112
kubectl apply -f https://raw.githubusercontent.com/adobe/koperator/refs/heads/master/config/base/crds/kafka.banzaicloud.io_kafkausers.yaml
113113
```
114114

115-
1. Install Koperator into the `kafka` namespace:
115+
2. Install Koperator into the `kafka` namespace using the OCI Helm chart from GitHub Container Registry:
116+
117+
> 📦 **View available versions**: [ghcr.io/adobe/koperator/chart](https://github.com/adobe/koperator/pkgs/container/koperator/chart)
118+
119+
```sh
120+
# Install the latest release
121+
helm install kafka-operator oci://ghcr.io/adobe/koperator/chart --namespace=kafka --create-namespace
122+
123+
# Or install a specific version (replace with desired version)
124+
helm install kafka-operator oci://ghcr.io/adobe/koperator/chart --version 0.28.0-adobe-20250911 --namespace=kafka --create-namespace
125+
```
126+
127+
#### Pull and inspect the chart before installation
116128

117129
```sh
118-
helm install kafka-operator --repo https://kubernetes-charts.banzaicloud.com kafka-operator --namespace=kafka --create-namespace
130+
# Pull the chart locally
131+
helm pull oci://ghcr.io/adobe/koperator/chart --version 0.28.0-adobe-20250911
132+
133+
# Extract and inspect
134+
tar -xzf chart-0.28.0-adobe-20250911.tgz
135+
helm template kafka-operator ./chart/
136+
137+
# Install from local chart
138+
helm install kafka-operator ./chart/ --namespace=kafka --create-namespace
119139
```
120140

121141
1. Create the Kafka cluster using the `KafkaCluster` custom resource. The quick start uses a minimal custom resource, but there are other examples in the same directory.

0 commit comments

Comments
 (0)