Skip to content

Commit ae34898

Browse files
authored
Rename Helm chart and Docker image and move to GHCR (#233)
This change does a few things, none of these are breaking. It changes the registry from Docker Hub to GHCR, as we dont have the same rate limiting issues with unauthenticated pulls. It changes the release process to push the Helm chart as an OCI artifact removing the need for GH pages. It renames both the image and chart from kubernetes-operator to netbird-operator. This name is cleaner and easier for people to understand in a sea of Helm charts. Funnily enough this is not a breaking change as the release name is used and not the chart name. So in place upgrades just work. Fixes #207 Signed-off-by: Philip Laine <philip.laine@gmail.com>
1 parent ea9f1cb commit ae34898

33 files changed

Lines changed: 145 additions & 167 deletions

.github/workflows/helm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ jobs:
88
- name: Clone the code
99
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
1010
- name: Lint Helm Chart
11-
run: helm lint ./helm/kubernetes-operator
11+
run: helm lint ./charts/netbird-operator

.github/workflows/release.yaml

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,58 @@ on:
33
push:
44
tags:
55
- "v*"
6-
branches:
7-
- main
6+
permissions:
7+
contents: read
8+
packages: write
9+
id-token: write
10+
defaults:
11+
run:
12+
shell: bash
813
jobs:
9-
docker:
14+
release:
1015
runs-on: ubuntu-latest
11-
permissions:
12-
contents: read
13-
packages: write
14-
id-token: write
1516
steps:
1617
- name: Clone the code
1718
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
1819
- name: Setup Go
1920
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
2021
with:
2122
go-version-file: go.mod
23+
- name: Set up Docker
24+
uses: docker/setup-docker-action@b2189fbf2a6592b51fee7cdd93ee2bfaeba733db #v5.1.0
25+
with:
26+
daemon-config: |
27+
{
28+
"features": {
29+
"containerd-snapshotter": true
30+
}
31+
}
2232
- name: Set up Docker Buildx
2333
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd #v4.0.0
24-
- name: Login to Docker Hub
34+
with:
35+
driver: docker
36+
- name: Login to GitHub Container Registry
2537
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4.1.0
2638
with:
27-
username: ${{ secrets.DOCKER_USER }}
28-
password: ${{ secrets.DOCKER_TOKEN }}
29-
- name: Build image
30-
id: build
39+
registry: ghcr.io
40+
username: ${{ github.repository_owner }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Prepare versions
43+
id: prep
3144
run: |
45+
IMG_TAG="${GITHUB_REF_NAME}"
3246
if [[ "${{ github.ref_type }}" == "tag" ]]; then
33-
IMG_TAG="${GITHUB_REF_NAME#v}"
47+
HELM_VERSION=${GITHUB_REF_NAME#v}
3448
else
35-
IMG_TAG="${GITHUB_SHA::7}"
49+
HELM_VERSION="0.0.0-${GITHUB_REF_NAME}"
3650
fi
37-
IMG=$(make build-image-multiarch) || exit 1
38-
echo "IMG=${IMG}" >> $GITHUB_OUTPUT
39-
- name: Push image
51+
echo "IMG_TAG=${IMG_TAG}" >> $GITHUB_OUTPUT
52+
echo "HELM_VERSION=${HELM_VERSION}" >> $GITHUB_OUTPUT
53+
- name: Build and push image
54+
run: |
55+
IMG_REF=$(make build-image-multiarch IMG_REPOSITORY=${{ github.repository_owner }}/netbird-operator IMG_TAG=${{ steps.prep.outputs.IMG_TAG }}) || exit 1
56+
docker push ${IMG_REF}
57+
- name: Build and push Helm chart
4058
run: |
41-
docker push ${{ steps.build.outputs.IMG }}
59+
helm package --app-version ${{ steps.prep.outputs.IMG_TAG }} --version ${{ steps.prep.outputs.HELM_VERSION }} charts/netbird-operator
60+
helm push netbird-operator-${{ steps.prep.outputs.HELM_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}/helm-charts

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ FROM gcr.io/distroless/static:nonroot
22
ARG TARGETOS
33
ARG TARGETARCH
44
LABEL org.opencontainers.image.title="NetBird Operator" \
5-
org.opencontainers.image.description="Kubernetes operator for NetBird." \
5+
org.opencontainers.image.description="Kubernetes operator for NetBird" \
66
org.opencontainers.image.source="https://github.com/netbirdio/kubernetes-operator" \
77
org.opencontainers.image.vendor="NetBird" \
88
org.opencontainers.image.licenses="BSD-3-Clause"
9-
COPY bin/${TARGETOS}-${TARGETARCH}/netbird-operator .
9+
COPY bin/${TARGETOS}-${TARGETARCH}/netbird-operator /usr/local/bin/
1010
USER 65532:65532
11-
ENTRYPOINT ["/netbird-operator"]
11+
ENTRYPOINT ["netbird-operator"]

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ else
1010
GOBIN = $(shell go env GOBIN)
1111
endif
1212

13-
IMG_REGISTRY ?= docker.io
14-
IMG_REPOSITORY ?= netbirdio/kubernetes-operator
13+
IMG_REGISTRY ?= ghcr.io
14+
IMG_REPOSITORY ?= netbirdio/netbird-operator
1515
IMG_TAG ?= dev
1616
IMG_REF := $(IMG_REGISTRY)/$(IMG_REPOSITORY):$(IMG_TAG)
1717

1818
.PHONY: generate
19-
generate: api/v1/zz_generated.deepcopy.go api/v1alpha1/zz_generated.deepcopy.go pkg/applyconfigurations helm/kubernetes-operator/crds docs/api-reference.md
19+
generate: api/v1/zz_generated.deepcopy.go api/v1alpha1/zz_generated.deepcopy.go pkg/applyconfigurations charts/netbird-operator/crds docs/api-reference.md
2020

2121
api/v1/zz_generated.deepcopy.go api/v1alpha1/zz_generated.deepcopy.go: $(shell find api -not -name 'zz_generated*') hack/boilerplate.go.txt
2222
@go tool controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
@@ -25,9 +25,9 @@ pkg/applyconfigurations: $(shell find api -not -name 'zz_generated*') hack/boile
2525
@go tool controller-gen applyconfiguration:headerFile="hack/boilerplate.go.txt" object:headerFile="hack/boilerplate.go.txt" paths="./..."
2626
@touch pkg/applyconfigurations
2727

28-
helm/kubernetes-operator/crds: $(shell find api)
29-
@go tool controller-gen crd paths="./..." output:crd:artifacts:config=helm/kubernetes-operator/crds
30-
@touch helm/kubernetes-operator/crds
28+
charts/netbird-operator/crds: $(shell find api)
29+
@go tool controller-gen crd paths="./..." output:crd:artifacts:config=charts/netbird-operator/crds
30+
@touch charts/netbird-operator/crds
3131

3232
docs/api-reference.md: $(shell find api) docs/.crd-ref-docs.yaml
3333
@go tool crd-ref-docs --log-level error --output-path docs/api-reference.md --renderer markdown --source-path api/v1alpha1 --config docs/.crd-ref-docs.yaml
@@ -51,29 +51,29 @@ bin/linux-%/netbird-operator: $(shell find api cmd internal pkg) go.mod go.sum
5151

5252
.PHONY: build-image
5353
build-image: build
54-
@docker buildx build -t ${IMG_REF} .
54+
@DOCKER_BUILDKIT=1 docker build -t ${IMG_REF} .
5555
@echo ${IMG_REF}
5656

5757
.PHONY: build-image-multiarch
5858
build-image-multiarch: generate bin/linux-amd64/netbird-operator bin/linux-arm64/netbird-operator
59-
@docker buildx build --platform linux/amd64,linux/arm64 -t ${IMG_REF} .
59+
@DOCKER_BUILDKIT=1 docker build --platform linux/amd64,linux/arm64 -t ${IMG_REF} .
6060
@echo ${IMG_REF}
6161

6262
## Generate a consolidated YAML with CRDs and deployment.
6363
.PHONY: build-installer
6464
build-installer: generate
6565
mkdir -p manifests
66-
helm template --include-crds kubernetes-operator helm/kubernetes-operator > manifests/install.yaml
66+
helm template --include-crds netbird-operator charts/netbird-operator > manifests/install.yaml
6767

6868
##@ Deployment
6969

7070
.PHONY: install
7171
install: generate
72-
kubectl apply --server-side -f helm/kubernetes-operator/crds
72+
kubectl apply --server-side -f charts/netbird-operator/crds
7373

7474
.PHONY: uninstall
7575
uninstall:
76-
kubectl delete -f helm/kubernetes-operator/crds
76+
kubectl delete -f charts/netbird-operator/crds
7777

7878
run: install
7979
kubectl create namespace netbird --dry-run=client -o yaml | kubectl apply -f -

charts/netbird-operator/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: netbird-operator
3+
description: Kubernetes operator for NetBird
4+
type: application
5+
version: "0.0.0"
6+
appVersion: ""
File renamed without changes.

helm/kubernetes-operator/crds/netbird.io_nbgroups.yaml renamed to charts/netbird-operator/crds/netbird.io_nbgroups.yaml

File renamed without changes.

helm/kubernetes-operator/crds/netbird.io_nbpolicies.yaml renamed to charts/netbird-operator/crds/netbird.io_nbpolicies.yaml

File renamed without changes.

helm/kubernetes-operator/crds/netbird.io_nbresources.yaml renamed to charts/netbird-operator/crds/netbird.io_nbresources.yaml

File renamed without changes.

0 commit comments

Comments
 (0)