diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml index fb13443..a08a761 100644 --- a/.github/workflows/helm.yaml +++ b/.github/workflows/helm.yaml @@ -8,4 +8,4 @@ jobs: - name: Clone the code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 - name: Lint Helm Chart - run: helm lint ./helm/kubernetes-operator + run: helm lint ./charts/netbird-operator diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 04ea0c2..ba6babc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,15 +3,16 @@ on: push: tags: - "v*" - branches: - - main +permissions: + contents: read + packages: write + id-token: write +defaults: + run: + shell: bash jobs: - docker: + release: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write steps: - name: Clone the code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 @@ -19,23 +20,41 @@ jobs: uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0 with: go-version-file: go.mod + - name: Set up Docker + uses: docker/setup-docker-action@b2189fbf2a6592b51fee7cdd93ee2bfaeba733db #v5.1.0 + with: + daemon-config: | + { + "features": { + "containerd-snapshotter": true + } + } - name: Set up Docker Buildx uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd #v4.0.0 - - name: Login to Docker Hub + with: + driver: docker + - name: Login to GitHub Container Registry uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4.1.0 with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: Build image - id: build + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare versions + id: prep run: | + IMG_TAG="${GITHUB_REF_NAME}" if [[ "${{ github.ref_type }}" == "tag" ]]; then - IMG_TAG="${GITHUB_REF_NAME#v}" + HELM_VERSION=${GITHUB_REF_NAME#v} else - IMG_TAG="${GITHUB_SHA::7}" + HELM_VERSION="0.0.0-${GITHUB_REF_NAME}" fi - IMG=$(make build-image-multiarch) || exit 1 - echo "IMG=${IMG}" >> $GITHUB_OUTPUT - - name: Push image + echo "IMG_TAG=${IMG_TAG}" >> $GITHUB_OUTPUT + echo "HELM_VERSION=${HELM_VERSION}" >> $GITHUB_OUTPUT + - name: Build and push image run: | - docker push ${{ steps.build.outputs.IMG }} + IMG_REF=$(make build-image-multiarch IMG_REPOSITORY=${{ github.repository_owner }}/netbird-operator IMG_TAG=${{ steps.prep.outputs.IMG_TAG }}) || exit 1 + docker push ${IMG_REF} + - name: Build and push Helm chart + run: | + helm package --app-version ${{ steps.prep.outputs.IMG_TAG }} --version ${{ steps.prep.outputs.HELM_VERSION }} charts/netbird-operator + helm push netbird-operator-${{ steps.prep.outputs.HELM_VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}/helm-charts diff --git a/Dockerfile b/Dockerfile index d822995..923134b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,10 @@ FROM gcr.io/distroless/static:nonroot ARG TARGETOS ARG TARGETARCH LABEL org.opencontainers.image.title="NetBird Operator" \ - org.opencontainers.image.description="Kubernetes operator for NetBird." \ + org.opencontainers.image.description="Kubernetes operator for NetBird" \ org.opencontainers.image.source="https://github.com/netbirdio/kubernetes-operator" \ org.opencontainers.image.vendor="NetBird" \ org.opencontainers.image.licenses="BSD-3-Clause" -COPY bin/${TARGETOS}-${TARGETARCH}/netbird-operator . +COPY bin/${TARGETOS}-${TARGETARCH}/netbird-operator /usr/local/bin/ USER 65532:65532 -ENTRYPOINT ["/netbird-operator"] +ENTRYPOINT ["netbird-operator"] diff --git a/Makefile b/Makefile index eac4229..77a8618 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,13 @@ else GOBIN = $(shell go env GOBIN) endif -IMG_REGISTRY ?= docker.io -IMG_REPOSITORY ?= netbirdio/kubernetes-operator +IMG_REGISTRY ?= ghcr.io +IMG_REPOSITORY ?= netbirdio/netbird-operator IMG_TAG ?= dev IMG_REF := $(IMG_REGISTRY)/$(IMG_REPOSITORY):$(IMG_TAG) .PHONY: generate -generate: api/v1/zz_generated.deepcopy.go api/v1alpha1/zz_generated.deepcopy.go pkg/applyconfigurations helm/kubernetes-operator/crds docs/api-reference.md +generate: api/v1/zz_generated.deepcopy.go api/v1alpha1/zz_generated.deepcopy.go pkg/applyconfigurations charts/netbird-operator/crds docs/api-reference.md api/v1/zz_generated.deepcopy.go api/v1alpha1/zz_generated.deepcopy.go: $(shell find api -not -name 'zz_generated*') hack/boilerplate.go.txt @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 @go tool controller-gen applyconfiguration:headerFile="hack/boilerplate.go.txt" object:headerFile="hack/boilerplate.go.txt" paths="./..." @touch pkg/applyconfigurations -helm/kubernetes-operator/crds: $(shell find api) - @go tool controller-gen crd paths="./..." output:crd:artifacts:config=helm/kubernetes-operator/crds - @touch helm/kubernetes-operator/crds +charts/netbird-operator/crds: $(shell find api) + @go tool controller-gen crd paths="./..." output:crd:artifacts:config=charts/netbird-operator/crds + @touch charts/netbird-operator/crds docs/api-reference.md: $(shell find api) docs/.crd-ref-docs.yaml @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 .PHONY: build-image build-image: build - @docker buildx build -t ${IMG_REF} . + @DOCKER_BUILDKIT=1 docker build -t ${IMG_REF} . @echo ${IMG_REF} .PHONY: build-image-multiarch build-image-multiarch: generate bin/linux-amd64/netbird-operator bin/linux-arm64/netbird-operator - @docker buildx build --platform linux/amd64,linux/arm64 -t ${IMG_REF} . + @DOCKER_BUILDKIT=1 docker build --platform linux/amd64,linux/arm64 -t ${IMG_REF} . @echo ${IMG_REF} ## Generate a consolidated YAML with CRDs and deployment. .PHONY: build-installer build-installer: generate mkdir -p manifests - helm template --include-crds kubernetes-operator helm/kubernetes-operator > manifests/install.yaml + helm template --include-crds netbird-operator charts/netbird-operator > manifests/install.yaml ##@ Deployment .PHONY: install install: generate - kubectl apply --server-side -f helm/kubernetes-operator/crds + kubectl apply --server-side -f charts/netbird-operator/crds .PHONY: uninstall uninstall: - kubectl delete -f helm/kubernetes-operator/crds + kubectl delete -f charts/netbird-operator/crds run: install kubectl create namespace netbird --dry-run=client -o yaml | kubectl apply -f - diff --git a/helm/kubernetes-operator/.helmignore b/charts/netbird-operator/.helmignore similarity index 100% rename from helm/kubernetes-operator/.helmignore rename to charts/netbird-operator/.helmignore diff --git a/charts/netbird-operator/Chart.yaml b/charts/netbird-operator/Chart.yaml new file mode 100644 index 0000000..62e7f65 --- /dev/null +++ b/charts/netbird-operator/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: netbird-operator +description: Kubernetes operator for NetBird +type: application +version: "0.0.0" +appVersion: "" diff --git a/helm/kubernetes-operator/crds/netbird.io_groups.yaml b/charts/netbird-operator/crds/netbird.io_groups.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_groups.yaml rename to charts/netbird-operator/crds/netbird.io_groups.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_nbgroups.yaml b/charts/netbird-operator/crds/netbird.io_nbgroups.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_nbgroups.yaml rename to charts/netbird-operator/crds/netbird.io_nbgroups.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_nbpolicies.yaml b/charts/netbird-operator/crds/netbird.io_nbpolicies.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_nbpolicies.yaml rename to charts/netbird-operator/crds/netbird.io_nbpolicies.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_nbresources.yaml b/charts/netbird-operator/crds/netbird.io_nbresources.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_nbresources.yaml rename to charts/netbird-operator/crds/netbird.io_nbresources.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_nbroutingpeers.yaml b/charts/netbird-operator/crds/netbird.io_nbroutingpeers.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_nbroutingpeers.yaml rename to charts/netbird-operator/crds/netbird.io_nbroutingpeers.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_nbsetupkeys.yaml b/charts/netbird-operator/crds/netbird.io_nbsetupkeys.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_nbsetupkeys.yaml rename to charts/netbird-operator/crds/netbird.io_nbsetupkeys.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_networkresources.yaml b/charts/netbird-operator/crds/netbird.io_networkresources.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_networkresources.yaml rename to charts/netbird-operator/crds/netbird.io_networkresources.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_networkrouters.yaml b/charts/netbird-operator/crds/netbird.io_networkrouters.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_networkrouters.yaml rename to charts/netbird-operator/crds/netbird.io_networkrouters.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_setupkeys.yaml b/charts/netbird-operator/crds/netbird.io_setupkeys.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_setupkeys.yaml rename to charts/netbird-operator/crds/netbird.io_setupkeys.yaml diff --git a/helm/kubernetes-operator/crds/netbird.io_sidecarprofiles.yaml b/charts/netbird-operator/crds/netbird.io_sidecarprofiles.yaml similarity index 100% rename from helm/kubernetes-operator/crds/netbird.io_sidecarprofiles.yaml rename to charts/netbird-operator/crds/netbird.io_sidecarprofiles.yaml diff --git a/helm/kubernetes-operator/templates/_helpers.tpl b/charts/netbird-operator/templates/_helpers.tpl similarity index 68% rename from helm/kubernetes-operator/templates/_helpers.tpl rename to charts/netbird-operator/templates/_helpers.tpl index ebef1ea..0163d75 100644 --- a/helm/kubernetes-operator/templates/_helpers.tpl +++ b/charts/netbird-operator/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "kubernetes-operator.name" -}} +{{- define "netbird-operator.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} -{{- define "kubernetes-operator.fullname" -}} +{{- define "netbird-operator.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "kubernetes-operator.chart" -}} +{{- define "netbird-operator.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "kubernetes-operator.labels" -}} -helm.sh/chart: {{ include "kubernetes-operator.chart" . }} -{{ include "kubernetes-operator.selectorLabels" . }} +{{- define "netbird-operator.labels" -}} +helm.sh/chart: {{ include "netbird-operator.chart" . }} +{{ include "netbird-operator.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -50,17 +50,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "kubernetes-operator.selectorLabels" -}} -app.kubernetes.io/name: {{ include "kubernetes-operator.name" . }} +{{- define "netbird-operator.selectorLabels" -}} +app.kubernetes.io/name: {{ include "netbird-operator.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "kubernetes-operator.serviceAccountName" -}} +{{- define "netbird-operator.serviceAccountName" -}} {{- if .Values.operator.serviceAccount.create }} -{{- default (include "kubernetes-operator.fullname" .) .Values.operator.serviceAccount.name }} +{{- default (include "netbird-operator.fullname" .) .Values.operator.serviceAccount.name }} {{- else }} {{- default "default" .Values.operator.serviceAccount.name }} {{- end }} @@ -70,23 +70,23 @@ Create the name of the service account to use {{/* Create the name of the webhook service */}} -{{- define "kubernetes-operator.webhookService" -}} -{{- printf "%s-webhook-service" (include "kubernetes-operator.fullname" .) -}} +{{- define "netbird-operator.webhookService" -}} +{{- printf "%s-webhook-service" (include "netbird-operator.fullname" .) -}} {{- end -}} {{/* Create the name of the webhook cert secret */}} -{{- define "kubernetes-operator.webhookCertSecret" -}} -{{- printf "%s-tls" (include "kubernetes-operator.fullname" .) -}} +{{- define "netbird-operator.webhookCertSecret" -}} +{{- printf "%s-tls" (include "netbird-operator.fullname" .) -}} {{- end -}} {{/* Generate certificates for webhook */}} -{{- define "kubernetes-operator.webhookCerts" -}} -{{- $serviceName := (include "kubernetes-operator.webhookService" .) -}} -{{- $secretName := (include "kubernetes-operator.webhookCertSecret" .) -}} +{{- define "netbird-operator.webhookCerts" -}} +{{- $serviceName := (include "netbird-operator.webhookService" .) -}} +{{- $secretName := (include "netbird-operator.webhookCertSecret" .) -}} {{- $secret := lookup "v1" "Secret" .Release.Namespace $secretName -}} {{- if (and .Values.webhook.tls.caCert .Values.webhook.tls.cert .Values.webhook.tls.key) -}} caCert: {{ .Values.webhook.tls.caCert | b64enc }} @@ -98,10 +98,10 @@ clientCert: {{ index $secret.data "tls.crt" }} clientKey: {{ index $secret.data "tls.key" }} {{- else -}} {{- $altNames := list (printf "%s.%s" $serviceName .Release.Namespace) (printf "%s.%s.svc" $serviceName .Release.Namespace) (printf "%s.%s.%s" $serviceName .Release.Namespace .Values.cluster.dns) -}} -{{- $ca := genCA "kubernetes-operator-ca" 3650 -}} -{{- $cert := genSignedCert (include "kubernetes-operator.fullname" .) nil $altNames 3650 $ca -}} +{{- $ca := genCA "netbird-operator-ca" 3650 -}} +{{- $cert := genSignedCert (include "netbird-operator.fullname" .) nil $altNames 3650 $ca -}} caCert: {{ $ca.Cert | b64enc }} clientCert: {{ $cert.Cert | b64enc }} clientKey: {{ $cert.Key | b64enc }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/helm/kubernetes-operator/templates/deployment.yaml b/charts/netbird-operator/templates/deployment.yaml similarity index 91% rename from helm/kubernetes-operator/templates/deployment.yaml rename to charts/netbird-operator/templates/deployment.yaml index 31fe20b..385ef08 100644 --- a/helm/kubernetes-operator/templates/deployment.yaml +++ b/charts/netbird-operator/templates/deployment.yaml @@ -1,15 +1,15 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} labels: app.kubernetes.io/component: operator - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} spec: replicas: {{ .Values.operator.replicaCount }} selector: matchLabels: - {{- include "kubernetes-operator.selectorLabels" . | nindent 6 }} + {{- include "netbird-operator.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.operator.podAnnotations }} @@ -18,7 +18,7 @@ spec: {{- end }} labels: app.kubernetes.io/component: operator - {{- include "kubernetes-operator.labels" . | nindent 8 }} + {{- include "netbird-operator.labels" . | nindent 8 }} {{- with .Values.operator.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} @@ -27,7 +27,7 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "kubernetes-operator.serviceAccountName" . }} + serviceAccountName: {{ include "netbird-operator.serviceAccountName" . }} securityContext: {{- toYaml .Values.operator.podSecurityContext | nindent 8 }} containers: @@ -36,8 +36,6 @@ spec: {{- toYaml .Values.operator.securityContext | nindent 12 }} image: "{{ .Values.operator.image.registry }}/{{ .Values.operator.image.repository }}:{{ .Values.operator.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.operator.image.pullPolicy }} - command: - - /manager args: {{- if .Values.operator.metrics.enabled }} - --metrics-bind-address=:{{ .Values.operator.metrics.port}} @@ -104,7 +102,7 @@ spec: name: {{ .Values.netbirdAPI.keyFromSecret.name }} key: {{ .Values.netbirdAPI.keyFromSecret.key }} {{- else }} - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} key: NB_API_KEY {{- end }} {{- end }} @@ -131,7 +129,7 @@ spec: - name: webhook-certs secret: defaultMode: 420 - secretName: {{ template "kubernetes-operator.webhookCertSecret" . }} + secretName: {{ template "netbird-operator.webhookCertSecret" . }} {{- with .Values.operator.volumes }} {{- toYaml . | nindent 8 }} {{- end }} diff --git a/helm/kubernetes-operator/templates/gateway-api.yaml b/charts/netbird-operator/templates/gateway-api.yaml similarity index 74% rename from helm/kubernetes-operator/templates/gateway-api.yaml rename to charts/netbird-operator/templates/gateway-api.yaml index 7199e53..887a7d0 100644 --- a/helm/kubernetes-operator/templates/gateway-api.yaml +++ b/charts/netbird-operator/templates/gateway-api.yaml @@ -4,7 +4,7 @@ kind: GatewayClass metadata: name: netbird-private labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} spec: controllerName: "gateway.netbird.io/controller" --- @@ -13,7 +13,7 @@ kind: GatewayClass metadata: name: netbird-public labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} spec: controllerName: "gateway.netbird.io/controller" {{- end }} diff --git a/helm/kubernetes-operator/templates/nbpolicies.yaml b/charts/netbird-operator/templates/nbpolicies.yaml similarity index 90% rename from helm/kubernetes-operator/templates/nbpolicies.yaml rename to charts/netbird-operator/templates/nbpolicies.yaml index c5f24b2..d9f544a 100644 --- a/helm/kubernetes-operator/templates/nbpolicies.yaml +++ b/charts/netbird-operator/templates/nbpolicies.yaml @@ -7,7 +7,7 @@ metadata: - netbird.io/cleanup labels: app.kubernetes.io/component: operator - {{- include "kubernetes-operator.labels" $ | nindent 4 }} + {{- include "netbird-operator.labels" $ | nindent 4 }} annotations: helm.sh/resource-policy: keep name: {{ $k }} @@ -29,4 +29,4 @@ spec: {{- if hasKey $v "bidirectional" }} bidirectional: {{ $v.bidirectional }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/helm/kubernetes-operator/templates/nbroutingpeers.yaml b/charts/netbird-operator/templates/nbroutingpeers.yaml similarity index 94% rename from helm/kubernetes-operator/templates/nbroutingpeers.yaml rename to charts/netbird-operator/templates/nbroutingpeers.yaml index 505d3a7..95f923a 100644 --- a/helm/kubernetes-operator/templates/nbroutingpeers.yaml +++ b/charts/netbird-operator/templates/nbroutingpeers.yaml @@ -9,7 +9,7 @@ metadata: - netbird.io/cleanup labels: app.kubernetes.io/component: operator - {{- include "kubernetes-operator.labels" $ | nindent 4 }} + {{- include "netbird-operator.labels" $ | nindent 4 }} annotations: helm.sh/resource-policy: keep name: router @@ -52,7 +52,7 @@ metadata: - netbird.io/cleanup labels: app.kubernetes.io/component: operator - {{- include "kubernetes-operator.labels" $ | nindent 4 }} + {{- include "netbird-operator.labels" $ | nindent 4 }} annotations: helm.sh/resource-policy: keep name: router @@ -86,4 +86,4 @@ spec: {} {{- end }} {{- end }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/helm/kubernetes-operator/templates/rbac.yaml b/charts/netbird-operator/templates/rbac.yaml similarity index 82% rename from helm/kubernetes-operator/templates/rbac.yaml rename to charts/netbird-operator/templates/rbac.yaml index 50ec2a0..4587884 100644 --- a/helm/kubernetes-operator/templates/rbac.yaml +++ b/charts/netbird-operator/templates/rbac.yaml @@ -1,9 +1,9 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} rules: - apiGroups: - netbird.io @@ -164,24 +164,24 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} subjects: - kind: ServiceAccount - name: {{ include "kubernetes-operator.serviceAccountName" . }} + name: {{ include "netbird-operator.serviceAccountName" . }} namespace: {{ .Release.Namespace }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} rules: - apiGroups: - "" @@ -218,14 +218,14 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: {{ include "kubernetes-operator.fullname" . }} + name: {{ include "netbird-operator.fullname" . }} subjects: - kind: ServiceAccount - name: {{ include "kubernetes-operator.serviceAccountName" . }} + name: {{ include "netbird-operator.serviceAccountName" . }} namespace: {{ .Release.Namespace }} diff --git a/helm/kubernetes-operator/templates/service.yaml b/charts/netbird-operator/templates/service.yaml similarity index 59% rename from helm/kubernetes-operator/templates/service.yaml rename to charts/netbird-operator/templates/service.yaml index da3125f..f5f0b9c 100644 --- a/helm/kubernetes-operator/templates/service.yaml +++ b/charts/netbird-operator/templates/service.yaml @@ -2,9 +2,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "kubernetes-operator.fullname" . }}-metrics + name: {{ include "netbird-operator.fullname" . }}-metrics labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} spec: type: {{ .Values.operator.metrics.type }} ports: @@ -13,15 +13,15 @@ spec: protocol: TCP targetPort: {{ .Values.operator.metrics.port }} selector: - {{- include "kubernetes-operator.selectorLabels" . | nindent 4 }} + {{- include "netbird-operator.selectorLabels" . | nindent 4 }} {{- end }} --- apiVersion: v1 kind: Service metadata: - name: {{ include "kubernetes-operator.webhookService" . }} + name: {{ include "netbird-operator.webhookService" . }} labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} spec: type: {{ .Values.webhook.service.type }} ports: @@ -30,4 +30,4 @@ spec: protocol: TCP targetPort: {{ .Values.webhook.service.targetPort }} selector: - {{- include "kubernetes-operator.selectorLabels" . | nindent 4 }} + {{- include "netbird-operator.selectorLabels" . | nindent 4 }} diff --git a/helm/kubernetes-operator/templates/serviceaccount.yaml b/charts/netbird-operator/templates/serviceaccount.yaml similarity index 71% rename from helm/kubernetes-operator/templates/serviceaccount.yaml rename to charts/netbird-operator/templates/serviceaccount.yaml index c8bfbf3..3f3836d 100644 --- a/helm/kubernetes-operator/templates/serviceaccount.yaml +++ b/charts/netbird-operator/templates/serviceaccount.yaml @@ -2,9 +2,9 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "kubernetes-operator.serviceAccountName" . }} + name: {{ include "netbird-operator.serviceAccountName" . }} labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} {{- with .Values.operator.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/helm/kubernetes-operator/templates/webhook.yaml b/charts/netbird-operator/templates/webhook.yaml similarity index 67% rename from helm/kubernetes-operator/templates/webhook.yaml rename to charts/netbird-operator/templates/webhook.yaml index fc12f4f..1637001 100644 --- a/helm/kubernetes-operator/templates/webhook.yaml +++ b/charts/netbird-operator/templates/webhook.yaml @@ -1,22 +1,22 @@ -{{ $tls := fromYaml ( include "kubernetes-operator.webhookCerts" . ) }} +{{ $tls := fromYaml ( include "netbird-operator.webhookCerts" . ) }} --- apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: {{- if $.Values.webhook.enableCertManager }} annotations: - cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ template "kubernetes-operator.fullname" . }}-serving-cert + cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ template "netbird-operator.fullname" . }}-serving-cert {{- end }} - name: {{ include "kubernetes-operator.fullname" . }}-mpod-webhook + name: {{ include "netbird-operator.fullname" . }}-mpod-webhook labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} webhooks: - clientConfig: {{- if not $.Values.webhook.enableCertManager }} caBundle: {{ $tls.caCert }} {{ end }} service: - name: {{ template "kubernetes-operator.webhookService" . }} + name: {{ template "netbird-operator.webhookService" . }} namespace: {{ $.Release.Namespace }} path: /mutate--v1-pod failurePolicy: {{ .Values.webhook.failurePolicy }} @@ -33,7 +33,7 @@ webhooks: - key: app.kubernetes.io/name operator: NotIn values: - - {{ include "kubernetes-operator.name" . }} + - {{ include "netbird-operator.name" . }} {{- if .Values.webhook.objectSelector.matchExpressions }} {{- toYaml .Values.webhook.objectSelector.matchExpressions | nindent 4 }} {{- end }} @@ -58,18 +58,18 @@ kind: ValidatingWebhookConfiguration metadata: {{- if $.Values.webhook.enableCertManager }} annotations: - cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ template "kubernetes-operator.fullname" . }}-serving-cert + cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ template "netbird-operator.fullname" . }}-serving-cert {{- end }} - name: {{ include "kubernetes-operator.fullname" . }}-vnbgroup-webhook + name: {{ include "netbird-operator.fullname" . }}-vnbgroup-webhook labels: - {{- include "kubernetes-operator.labels" . | nindent 4 }} + {{- include "netbird-operator.labels" . | nindent 4 }} webhooks: - clientConfig: {{- if not $.Values.webhook.enableCertManager }} caBundle: {{ $tls.caCert }} {{ end }} service: - name: {{ template "kubernetes-operator.webhookService" . }} + name: {{ template "netbird-operator.webhookService" . }} namespace: {{ $.Release.Namespace }} path: /validate-netbird-io-v1-nbgroup failurePolicy: {{ .Values.webhook.failurePolicy }} @@ -97,10 +97,10 @@ webhooks: apiVersion: v1 kind: Secret metadata: - name: {{ template "kubernetes-operator.webhookCertSecret" . }} + name: {{ template "netbird-operator.webhookCertSecret" . }} namespace: {{ .Release.Namespace }} labels: -{{ include "kubernetes-operator.labels" . | indent 4 }} +{{ include "netbird-operator.labels" . | indent 4 }} type: kubernetes.io/tls data: ca.crt: {{ $tls.caCert }} @@ -110,26 +110,26 @@ data: apiVersion: cert-manager.io/v1 kind: Certificate metadata: - name: {{ template "kubernetes-operator.fullname" . }}-serving-cert + name: {{ template "netbird-operator.fullname" . }}-serving-cert namespace: {{ .Release.Namespace }} labels: -{{ include "kubernetes-operator.labels" . | indent 4 }} +{{ include "netbird-operator.labels" . | indent 4 }} spec: dnsNames: - - {{ template "kubernetes-operator.webhookService" . }}.{{ .Release.Namespace }}.svc - - {{ template "kubernetes-operator.webhookService" . }}.{{ .Release.Namespace }}.{{ .Values.cluster.dns }} + - {{ template "netbird-operator.webhookService" . }}.{{ .Release.Namespace }}.svc + - {{ template "netbird-operator.webhookService" . }}.{{ .Release.Namespace }}.{{ .Values.cluster.dns }} issuerRef: kind: Issuer - name: {{ template "kubernetes-operator.fullname" . }}-selfsigned-issuer - secretName: {{ template "kubernetes-operator.webhookCertSecret" . }} + name: {{ template "netbird-operator.fullname" . }}-selfsigned-issuer + secretName: {{ template "netbird-operator.webhookCertSecret" . }} --- apiVersion: cert-manager.io/v1 kind: Issuer metadata: - name: {{ template "kubernetes-operator.fullname" . }}-selfsigned-issuer + name: {{ template "netbird-operator.fullname" . }}-selfsigned-issuer namespace: {{ .Release.Namespace }} labels: -{{ include "kubernetes-operator.labels" . | indent 4 }} +{{ include "netbird-operator.labels" . | indent 4 }} spec: selfSigned: {} {{- end }} diff --git a/helm/kubernetes-operator/values.yaml b/charts/netbird-operator/values.yaml similarity index 98% rename from helm/kubernetes-operator/values.yaml rename to charts/netbird-operator/values.yaml index b9464f9..907284c 100644 --- a/helm/kubernetes-operator/values.yaml +++ b/charts/netbird-operator/values.yaml @@ -41,9 +41,9 @@ operator: # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: # Set operator image registry - registry: docker.io + registry: ghcr.io # Set operator image repository - repository: netbirdio/kubernetes-operator + repository: netbirdio/netbird-operator # This sets the pull policy for images. pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. diff --git a/examples/gateway-api/README.md b/examples/gateway-api/README.md index cc13900..4420e6c 100644 --- a/examples/gateway-api/README.md +++ b/examples/gateway-api/README.md @@ -5,7 +5,7 @@ This example walks you through how to setup a Netbird Gateway API and expose Ngi Build image locally and load it into Kind. ```shell make build-image -kind load docker-image docker.io/netbirdio/kubernetes-operator:dev +kind load docker-image ghcr.io/netbirdio/kubernetes-operator:dev ``` Install the Gateway API CRDs. diff --git a/helm/kubernetes-operator/Chart.yaml b/helm/kubernetes-operator/Chart.yaml deleted file mode 100644 index 8facf76..0000000 --- a/helm/kubernetes-operator/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: kubernetes-operator -description: NetBird Kubernetes Operator -type: application -version: "0.3.1" -appVersion: "0.3.1" diff --git a/helm/kubernetes-operator/templates/NOTES.txt b/helm/kubernetes-operator/templates/NOTES.txt deleted file mode 100644 index e69de29..0000000 diff --git a/helm/kubernetes-operator/templates/pre-delete.yaml b/helm/kubernetes-operator/templates/pre-delete.yaml deleted file mode 100644 index a13a0d1..0000000 --- a/helm/kubernetes-operator/templates/pre-delete.yaml +++ /dev/null @@ -1,41 +0,0 @@ -{{/*apiVersion: batch/v1*/}} -{{/*kind: Job*/}} -{{/*metadata:*/}} -{{/* name: {{ include "kubernetes-operator.fullname" . }}-delete-router-deployments*/}} -{{/* labels:*/}} -{{/* app.kubernetes.io/component: operator*/}} -{{/* {{- include "kubernetes-operator.labels" . | nindent 4 }}*/}} -{{/* annotations:*/}} -{{/* helm.sh/hook: pre-delete*/}} -{{/* helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded*/}} -{{/*spec:*/}} -{{/* backoffLimit: 3*/}} -{{/* template:*/}} -{{/* metadata:*/}} -{{/* name: {{ include "kubernetes-operator.fullname" . }}*/}} -{{/* labels:*/}} -{{/* app.kubernetes.io/component: operator*/}} -{{/* {{- include "kubernetes-operator.labels" . | nindent 8 }}*/}} -{{/* {{- with .Values.operator.podLabels }}*/}} -{{/* {{- toYaml . | nindent 8 }}*/}} -{{/* {{- end }}*/}} -{{/* spec:*/}} -{{/* containers:*/}} -{{/* - name: pre-delete*/}} -{{/* image: "netbirdio/kubectl:latest"*/}} -{{/* imagePullPolicy: {{ .Values.operator.image.pullPolicy }}*/}} -{{/* command:*/}} -{{/* - sh*/}} -{{/* - -c*/}} -{{/* args:*/}} -{{/* - kubectl get NBRoutingPeer -A --no-headers -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name | while read "L"; do kubectl patch --type=json -p '[{"op":"replace","path":"/spec/disableDeployment","value":true}]' NBRoutingPeer -n $(echo "$L" | awk '{print $1}') $(echo "$L" | awk '{print $2}'); done*/}} -{{/* - name: delete-wait*/}} -{{/* image: "netbirdio/kubectl:latest"*/}} -{{/* imagePullPolicy: {{ .Values.operator.image.pullPolicy }}*/}} -{{/* command:*/}} -{{/* - sh*/}} -{{/* - -c*/}} -{{/* args:*/}} -{{/* - kubectl get NBRoutingPeer -A --no-headers -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name | while read "L"; do kubectl wait --for=delete deployment -n $(echo "$L" | awk '{print $1}') $(echo "$L" | awk '{print $2}'); done*/}} -{{/* serviceAccountName: {{ include "kubernetes-operator.serviceAccountName" . }}*/}} -{{/* restartPolicy: Never*/}} diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index 1b24fdf..3d63aa7 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -58,7 +58,7 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "helm", "kubernetes-operator", "crds")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "charts", "netbird-operator", "crds")}, ErrorIfCRDPathMissing: true, } diff --git a/internal/webhook/v1/webhook_suite_test.go b/internal/webhook/v1/webhook_suite_test.go index b46adbb..0a33423 100644 --- a/internal/webhook/v1/webhook_suite_test.go +++ b/internal/webhook/v1/webhook_suite_test.go @@ -70,7 +70,7 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "helm", "kubernetes-operator", "crds")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "charts", "netbird-operator", "crds")}, ErrorIfCRDPathMissing: false, // WebhookInstallOptions: envtest.WebhookInstallOptions{ diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 2f9e95f..2159f9c 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -155,13 +155,15 @@ func TestE2E(t *testing.T) { err = actionCfg.Init(clientGetter, netbirdNamespace, "secret") require.NoError(t, err) - charter, err := loader.Load("../../helm/kubernetes-operator") + charter, err := loader.Load("../../charts/netbird-operator") require.NoError(t, err) vals := map[string]any{ - "image": map[string]any{ - "tag": "dev", - "pullPolicy": "Never", + "operator": map[string]any{ + "image": map[string]any{ + "tag": "dev", + "pullPolicy": "Never", + }, }, "webhook": map[string]any{ "enableCertManager": false, @@ -171,7 +173,7 @@ func TestE2E(t *testing.T) { _, err = action.NewGet(actionCfg).Run(netbirdNamespace) if err != nil { install := action.NewInstall(actionCfg) - install.ReleaseName = netbirdNamespace + install.ReleaseName = "netbird-operator" install.Namespace = netbirdNamespace install.CreateNamespace = true install.WaitStrategy = kube.StatusWatcherStrategy @@ -183,7 +185,7 @@ func TestE2E(t *testing.T) { upgrade.Namespace = netbirdNamespace upgrade.WaitStrategy = kube.StatusWatcherStrategy upgrade.Timeout = 60 * time.Second - _, err := upgrade.RunWithContext(t.Context(), netbirdNamespace, charter, vals) + _, err := upgrade.RunWithContext(t.Context(), "netbird-operator", charter, vals) require.NoError(t, err) } })