diff --git a/.github/workflows/ci.yml b/.github/workflows/build-push-image.yml similarity index 97% rename from .github/workflows/ci.yml rename to .github/workflows/build-push-image.yml index 1905761..a16254d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build-push-image.yml @@ -1,6 +1,7 @@ -name: ci +name: build-push-image -on: push +on: + workflow_dispatch: jobs: build-push-image: diff --git a/Makefile b/Makefile index d56ee9f..c586fa3 100644 --- a/Makefile +++ b/Makefile @@ -41,12 +41,12 @@ dev-delete: tools @ $(SKAFFOLD) delete -p dev deploy: manifests tools - $(SKAFFOLD) run -p production + $(SKAFFOLD) run -p release # This is used to update the manifests into deploy/operator.yaml -render-production-manifests: - @ $(SKAFFOLD) build -q -p production - @ $(KUSTOMIZE) build config/production > deploy/operator.yaml +render-static-manifests: + @ $(SKAFFOLD) build -q -p release + @ $(KUSTOMIZE) build config/release > deploy/operator.yaml # Generate manifests e.g. CRD, RBAC etc. manifests: controller-gen diff --git a/README.md b/README.md index ee44a8c..e231ee2 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,14 @@ That Kubernetes operator doesn't exist. At least, it didn't until now. 🤠 ## Installation ```sh - kubectl apply -f https://raw.githubusercontent.com/annismckenzie/k3os-config-operator/v0.1.1/deploy/operator.yaml + kubectl apply -f https://raw.githubusercontent.com/annismckenzie/k3os-config-operator/v0.1.2/deploy/operator.yaml ``` ## Releasing 1. Tag locally with `vx.y.z`. Make sure the working directory is clean. -2. Run `make render-production-manifests`. This will build and push the new multi-arch image. +2. Run `make render-static-manifests`. This will build and push the new multi-arch image. 3. Update the installation path above with the new tag. 4. Commit the updated `deploy/operator.yaml` and the update to the README. 5. Delete the local tag, tag again, then push using `git push origin --tags`. diff --git a/config/production/kustomization.yaml b/config/release/kustomization.yaml similarity index 82% rename from config/production/kustomization.yaml rename to config/release/kustomization.yaml index 7828152..f28e8e6 100644 --- a/config/production/kustomization.yaml +++ b/config/release/kustomization.yaml @@ -1,9 +1,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -resources: +bases: - ../default images: - name: ghcr.io/annismckenzie/k3os-config-operator - newTag: v0.1.1 + newTag: v0.1.2 diff --git a/deploy/operator.yaml b/deploy/operator.yaml index 3dbe260..136153e 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -320,7 +320,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: ghcr.io/annismckenzie/k3os-config-operator:v0.1.1 + image: ghcr.io/annismckenzie/k3os-config-operator:v0.1.2 name: manager resources: limits: diff --git a/pkg/nodes/labeler.go b/pkg/nodes/labeler.go index 3a8f7ab..0cb19bd 100644 --- a/pkg/nodes/labeler.go +++ b/pkg/nodes/labeler.go @@ -54,13 +54,15 @@ func (l *labeler) Reconcile(node *corev1.Node, configNodeLabels map[string]strin } } - if len(configNodeLabels) > 0 { - update = true - for labelKey, labelValue := range configNodeLabels { - addedLabelsMap[labelKey] = struct{}{} - nodeLabels[labelKey] = labelValue - l.updatedLabels[labelKey] = labelValue + for labelKey, labelValue := range configNodeLabels { + if _, ok := addedLabelsMap[labelKey]; ok && labelValue == nodeLabels[labelKey] { // label already exists and hasn't been changed, skip + continue } + + update = true + addedLabelsMap[labelKey] = struct{}{} + nodeLabels[labelKey] = labelValue + l.updatedLabels[labelKey] = labelValue } if update { diff --git a/pkg/nodes/labeler_test.go b/pkg/nodes/labeler_test.go index d8e97b5..c96cf53 100644 --- a/pkg/nodes/labeler_test.go +++ b/pkg/nodes/labeler_test.go @@ -107,6 +107,24 @@ func Test_labeler_Reconcile(t *testing.T) { }, expectedAddedLabelsAnnotation: "someNewLabel", }, + { + name: "Node has existing labels, we added some labels, without any further changes it should skip updates", + args: args{ + node: labeledNode(map[string]string{"addedLabel": "value"}), + configNodeLabels: map[string]string{ + "addedLabel": "value", + }, + }, + expectedLabels: map[string]string{ + "k3s.io/hostname": "n2-node", + "kubernetes.io/arch": "arm64", + "node.kubernetes.io/instance-type": "k3s", + "someExistingLabel": "existingValue", + "addedLabel": "value", + }, + wantErr: errors.ErrSkipUpdate, + expectedAddedLabelsAnnotation: "addedLabel", + }, { name: "Node has existing labels and we add and update some labels", args: args{ diff --git a/skaffold.yaml b/skaffold.yaml index 1784128..5c0ecfd 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -5,21 +5,21 @@ metadata: build: local: push: false - artifacts: - - image: ghcr.io/annismckenzie/k3os-config-operator - custom: - buildCommand: make docker-build -deploy: - kustomize: - paths: - - config/default profiles: - - name: production + - name: release build: + artifacts: + - image: ghcr.io/annismckenzie/k3os-config-operator + custom: + buildCommand: make docker-build tagPolicy: gitCommit: {} local: push: true + deploy: + kustomize: + paths: + - config/default - name: dev build: tagPolicy: