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
76 changes: 31 additions & 45 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ on:
- main
pull_request:

env:
GORELEASER_VER: "v2.3.2"

jobs:
release:
env:
flags: ""
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -24,51 +19,42 @@ jobs:
id-token: write

steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
input_string: ${{ (startsWith(github.ref, 'refs/tags/v') && github.ref) || 'refs/tags/v0.0.0' }}
version_extractor_regex: '\/v(.*)$'

- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: echo "flags=--snapshot" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # It is required for GoReleaser to work properly

- name: Install modules
run: go mod tidy

- name: check git status
run: git --no-pager diff --exit-code
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to Docker hub
# list of Docker images to use as base name for tags
images: |
netbirdio/kubernetes-operator
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}

- name: Login to Docker Hub
if: github.repository == github.event.pull_request.head.repo.full_name || !github.head_ref
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Install OS build dependencies
run: sudo apt update && sudo apt install -y -q gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install goversioninfo
run: go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@233067e

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
- name: Build and push
uses: docker/build-push-action@v6
with:
version: ${{ env.GORELEASER_VER }}
args: release --clean ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
"org.opencontainers.image.created={{.Date}}"
"org.opencontainers.image.title={{.ProjectName}}"
"org.opencontainers.image.version={{.Version}}"
"org.opencontainers.image.revision={{.FullCommit}}"
"org.opencontainers.image.version={{.Version}}"
"[email protected]"
52 changes: 14 additions & 38 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
paths:
# update this file to trigger helm chart release
- 'helm/netbird-operator/Chart.yaml'
- 'helm/kubernetes-operator/Chart.yaml'
branches:
- main

Expand All @@ -18,49 +18,25 @@ jobs:
contents: write
pages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v3.1.0
with:
fetch-depth: 0

- name: Set ENVs
id: env-setup
- name: Configure Git
run: |
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"

- name: Package Charts
run: |
# Package charts
mkdir -p charts/.ci-build
echo "Setting chart version to ${{ steps.env-setup.outputs.CHART_VERSION }}"

for DIR in $CHART_BASE_DIR/*; do
# Check if Chart.yaml exists in this directory
if [ -f "${DIR}/Chart.yaml" ]; then
echo "Packaging ${DIR}"
helm dependency update $DIR
helm lint $DIR
helm package $DIR --destination charts/.ci-build
fi
done
git fetch --all

- name: Upload chart artifacts
uses: actions/upload-artifact@v4
- name: Install Helm
uses: azure/[email protected]
with:
name: helm-charts-${{ github.ref_name }}
path: charts/.ci-build/*
retention-days: 30
version: v3.4.2

- name: Publish to GH-Pages
id: ghpublish
run: |
git checkout $GH_PAGES_BRANCH --force
helm repo index charts/.ci-build/ --merge index.yaml --url ${{ github.server_url }}/${{github.repository}}/releases/download/${{ github.ref_name }}
cp charts/.ci-build/index.yaml index.yaml
echo "New index:" && cat index.yaml
git add index.yaml charts
git commit -a -m "bot: update pages index for helm charts"
git push origin $GH_PAGES_BRANCH
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: helm
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NAME_TEMPLATE: "helm-v{{ .Version }}"
4 changes: 2 additions & 2 deletions .github/workflows/test-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Lint Helm Chart
run: |
helm lint ./helm/netbird-operator
helm lint ./helm/kubernetes-operator
- name: Install cert-manager via Helm
run: |
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Install Helm chart for project
run: |
helm install test-chart --create-namespace --namespace netbird --set 'operator.image.tag=debug' ./helm/netbird-operator
helm install test-chart --create-namespace --namespace netbird --set 'operator.image.tag=debug' ./helm/kubernetes-operator
- name: Check Helm release status
run: |
Expand Down
86 changes: 0 additions & 86 deletions .goreleaser.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=helm/netbird-operator/crds
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=helm/kubernetes-operator/crds

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down Expand Up @@ -126,7 +126,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
.PHONY: build-installer
build-installer: manifests ## Generate a consolidated YAML with CRDs and deployment.
mkdir -p manifests
$(HELM) template --include-crds netbird-operator helm/netbird-operator > manifests/install.yaml
$(HELM) template --include-crds kubernetes-operator helm/kubernetes-operator > manifests/install.yaml

##@ Deployment

Expand All @@ -136,19 +136,19 @@ endif

.PHONY: install
install: manifests ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUBECTL) apply -f helm/netbird-operator/crds
$(KUBECTL) apply -f helm/kubernetes-operator/crds

.PHONY: uninstall
uninstall: manifests ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUBECTL) delete -f helm/netbird-operator/crds
$(KUBECTL) delete -f helm/kubernetes-operator/crds

.PHONY: deploy
deploy: manifests ## Deploy controller to the K8s cluster specified in ~/.kube/config.
$(HELM) install -n netbird --create-namespace netbird-operator --set operator.image.tag=$(word 2,$(subst :, ,${IMG})) helm/netbird-operator
$(HELM) install -n netbird --create-namespace kubernetes-operator --set operator.image.tag=$(word 2,$(subst :, ,${IMG})) helm/kubernetes-operator

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(HELM) uninstall -n netbird netbird-operator
$(HELM) uninstall -n netbird kubernetes-operator

##@ Dependencies

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ kubectl apply -n netbird -f https://github.com/netbirdio/kubernetes-operator/rel

```sh
helm repo add netbirdio https://netbirdio.github.io/kubernetes-operator
helm install -n netbird netbird-operator netbirdio/netbird-operator
helm install -n netbird kubernetes-operator netbirdio/kubernetes-operator
```

For more options, check the default values by running
```sh
helm show values netbirdio/netbird-operator
helm show values netbirdio/kubernetes-operator
```

### To Uninstall
Expand All @@ -45,7 +45,7 @@ kubectl delete namespace netbird
**Using helm**

```sh
helm uninstall -n netbird netbird-operator
helm uninstall -n netbird kubernetes-operator
```

### Provision pods with NetBird access
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: netbird-operator
name: kubernetes-operator
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
Expand Down
16 changes: 16 additions & 0 deletions helm/kubernetes-operator/secretvalues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
netbirdAPI:
key: "nbp_1TpgsCUaF2BU3NVZfaDrGpoY1jx2iT2g7rWj"

operator:
image:
tag: "v0.1.0"

ingress:
enabled: true
router:
enabled: true
policies:
default:
name: Kubernetes Default Policy
sourceGroups:
- All
Loading
Loading