Skip to content

Adjust kustomize labels injection mechanism #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
5 changes: 1 addition & 4 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set -E # needs to be set if we want the ERR trap
set -o pipefail # prevents errors in a pipeline from being masked

# Expected variables:
PULL_BASE_REF=${PULL_BASE_REF?"Define PULL_BASE_REF env"} # name of the tag
GITHUB_TOKEN=${GITHUB_TOKEN?"Define GITHUB_TOKEN env"} # github token used to upload the template yaml
RELEASE_ID=${RELEASE_ID?"Define RELEASE_ID env"} # github token used to upload the template yaml

Expand All @@ -31,9 +30,7 @@ uploadFile() {
fi
}

echo "PULL_BASE_REF ${PULL_BASE_REF}"

MODULE_VERSION=${PULL_BASE_REF} make render-manifest
make render-manifest

echo "Generated keda-manager.yaml:"
cat keda-manager.yaml
Expand Down
24 changes: 24 additions & 0 deletions .github/scripts/upgrade-operator-kustomize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# standard bash error handling
set -o errexit # exit immediately when a command fails.
set -E # needs to be set if we want the ERR trap
set -o pipefail # prevents errors in a pipeline from being masked

# Expected variables:
IMG=${IMG?"Define IMG env"} # operator img
MODULE_VERSION=${MODULE_VERSION?"Define MODULE_VERSION env"} # module version used to set common labels

PROJECT_ROOT=${PWD}
CONFIG_OPERATOR=${PROJECT_ROOT}/config

echo "ensure kustomize..."
PROJECT_ROOT=${PROJECT_ROOT} make -C ${PROJECT_ROOT} kustomize

echo "upgrade ${CONFIG_OPERATOR}..."

echo "upgrade image to ${IMG}..."
cd ${CONFIG_OPERATOR}/manager && ${PROJECT_ROOT}/bin/kustomize edit set image controller=${IMG}

echo "upgrade module version to ${MODULE_VERSION}..."
cd ${CONFIG_OPERATOR}/default && ${PROJECT_ROOT}/bin/kustomize edit add label app.kubernetes.io/version:${MODULE_VERSION} --force --without-selector --include-templates
9 changes: 4 additions & 5 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: 0

- name: Bump crd
- name: Bump kustomize
run: |
./hack/replace_keda_crd_version.sh
./.github/scripts/upgrade-operator-kustomize.sh
env:
IMG_VERSION: ${{ github.event.inputs.name }}
PROJECT_ROOT: "."
IMG: europe-docker.pkg.dev/kyma-project/prod/keda-manager:${{ github.event.inputs.name }}
MODULE_VERSION: ${{ github.event.inputs.name }}

- name: Bump sec-scanners-config.yaml
run: ./.github/scripts/upgrade-sec-scanners-config.sh
Expand Down Expand Up @@ -101,7 +101,6 @@ jobs:
id: create-assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_BASE_REF: ${{ github.event.inputs.name }}
RELEASE_ID: ${{ steps.create-draft.outputs.release_id }}
run: ./.github/scripts/release.sh

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: render-manifest
render-manifest: manifests kustomize ## Render keda-manager.yaml manifest.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
render-manifest: kustomize ## Render keda-manager.yaml manifest.
$(KUSTOMIZE) build config/default > keda-manager.yaml

.PHONY: undeploy
Expand Down
28 changes: 15 additions & 13 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# Adds namespace to all resources.
namespace: kyma-system

Expand All @@ -10,18 +13,17 @@ namePrefix: keda-

# Labels to add to all resources.
labels:
- pairs:
app.kubernetes.io/component: keda-manager.kyma-project.io
kyma-project.io/module: keda
app.kubernetes.io/name: keda-manager
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-manager
app.kubernetes.io/managed-by: kustomize
includeSelectors: false
- pairs:
app.kubernetes.io/component: keda-manager.kyma-project.io
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: keda-manager
app.kubernetes.io/part-of: keda-manager
app.kubernetes.io/version: 1.1.0
kyma-project.io/module: keda

resources:
- ../crd
- ../rbac
- ../priority-class
- ../manager
- ../ui-extensions
- ../crd
- ../rbac
- ../priority-class
- ../manager
- ../ui-extensions
17 changes: 0 additions & 17 deletions hack/replace_keda_crd_version.sh

This file was deleted.

Loading