From 741c29f369de55d42031cc3dc29bb1ef0bd6cc66 Mon Sep 17 00:00:00 2001 From: Zeort Date: Wed, 16 Oct 2024 12:10:07 +0300 Subject: [PATCH 1/2] add service account based kubeconfig --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile b/Makefile index b93df7d..4ab6bcb 100644 --- a/Makefile +++ b/Makefile @@ -104,6 +104,17 @@ release: manifests kustomize pushd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG_SHA) && popd $(KUSTOMIZE) build config/default > release-$(VERSION)/cfapi-manager.yaml +##@ Kubeconfig +.PHONY: kubeconfig +kubeconfig: + kubectl apply -f tools/kubeconfig/serviceaccount.yaml + kubectl wait --for=jsonpath='{.data.token}' secret/admin-serviceaccount + $(eval SA_TOKEN=$(kubectl get secret admin-serviceaccount -o=go-template='{{.data.token | base64decode}}')) + cp ~/.kube/config kubeconfig-sa.yaml + yq -i ".users |= [{\"name\":\"admin-serviceaccount\", \"user\": {\"token\":\"$SA_TOKEN\"}}]" kubeconfig-sa.yaml + yq -i ".contexts[0].context.user |= \"admin-serviceaccount\"" kubeconfig-sa.yaml + + ##@ Deployment ifndef ignore-not-found From 07ddf79efc43598572bfe98002011ffdec9ad3b9 Mon Sep 17 00:00:00 2001 From: Zeort Date: Wed, 16 Oct 2024 18:27:13 +0300 Subject: [PATCH 2/2] korifi github server,repo,ref configurable --- .github/workflows/build-korifi.yml | 10 +++++----- .github/workflows/release-draft.yml | 12 ++++++------ .github/workflows/run-kyma.yml | 16 ++++++++-------- Makefile | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-korifi.yml b/.github/workflows/build-korifi.yml index 5e97774..41d1b09 100644 --- a/.github/workflows/build-korifi.yml +++ b/.github/workflows/build-korifi.yml @@ -22,9 +22,9 @@ jobs: - name: 'Checkout Korifi-Trinity' uses: actions/checkout@v3 with: - repository: unified-runtime/korifi-trinity - ref: ${{ vars.KORIFI_REF }} - github-server-url: 'https://github.tools.sap' + repository: ${{ vars.KORIFI_GITHUB_REPOSITORY }} + ref: ${{ vars.KORIFI_GITHUB_REF }} + github-server-url: ${{ vars.KORIFI_GITHUB_SERVER }} token: ${{ secrets.KORIFI_TRINITY_TOKEN }} path: '.korifi' @@ -38,14 +38,14 @@ jobs: - name: Create korifi release artifacts env: - VERSION: ${{ vars.KORIFI_REF }} + VERSION: ${{ vars.KORIFI_GITHUB_REF }} DOCKER_REGISTRY: ${{ env.REGISTRY }} DOCKER_REGISTRY_USER: ${{ github.actor }} DOCKER_REGISTRY_PASS: ${{ secrets.GITHUB_TOKEN }} shell: bash working-directory: '.korifi' run: | - ../scripts/create-korifi-release.sh ${{ vars.KORIFI_REF }} + ../scripts/create-korifi-release.sh ${{ vars.KORIFI_GITHUB_REF }} diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml index d213c9c..2ccff3a 100644 --- a/.github/workflows/release-draft.yml +++ b/.github/workflows/release-draft.yml @@ -27,9 +27,9 @@ jobs: - name: Checkout Korifi-Trinity uses: actions/checkout@v3 with: - repository: unified-runtime/korifi-trinity - ref: ${{ vars.KORIFI_REF }} - github-server-url: 'https://github.tools.sap' + repository: ${{ vars.KORIFI_GITHUB_REPOSITORY }} + ref: ${{ vars.KORIFI_GITHUB_REF }} + github-server-url: ${{ vars.KORIFI_GITHUB_SERVER }} token: ${{ secrets.KORIFI_TRINITY_TOKEN }} path: '.korifi' @@ -42,21 +42,21 @@ jobs: - name: Create korifi release artifacts env: - VERSION: ${{ vars.KORIFI_REF }} + VERSION: ${{ vars.KORIFI_GITHUB_REF }} DOCKER_REGISTRY: ${{ env.REGISTRY }} DOCKER_REGISTRY_USER: ${{ github.actor }} DOCKER_REGISTRY_PASS: ${{ secrets.GITHUB_TOKEN }} shell: bash working-directory: '.korifi' run: | - ../scripts/create-korifi-release.sh ${{ vars.KORIFI_REF }} + ../scripts/create-korifi-release.sh ${{ vars.KORIFI_GITHUB_REF }} - name: set version run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT id: version - name: docker build - run: VERSION=${{ steps.version.outputs.version }} KORIFI_REF=${{ vars.KORIFI_REF }} make docker-build + run: VERSION=${{ steps.version.outputs.version }} KORIFI_REF=${{ vars.KORIFI_GITHUB_REF }} make docker-build - name: docker-push run: VERSION=${{ steps.version.outputs.version }} make docker-push diff --git a/.github/workflows/run-kyma.yml b/.github/workflows/run-kyma.yml index 5d1e6c9..2e46df3 100644 --- a/.github/workflows/run-kyma.yml +++ b/.github/workflows/run-kyma.yml @@ -1,10 +1,10 @@ name: Run-On-Kyma on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + #push: + # branches: [ "main" ] + #pull_request: + # branches: [ "main" ] workflow_dispatch: env: @@ -38,9 +38,9 @@ jobs: - name: 'Checkout Korifi-Trinity' uses: actions/checkout@v3 with: - repository: unified-runtime/korifi-trinity - ref: v${{ env.V_KORIFI }} - github-server-url: 'https://github.tools.sap' + repository: ${{ vars.KORIFI_GITHUB_REPOSITORY }} + ref: ${{ vars.KORIFI_GITHUB_REF }} + github-server-url: ${{ vars.KORIFI_GITHUB_SERVER }} token: ${{ secrets.KORIFI_TRINITY_TOKEN }} path: '.korifi' @@ -53,7 +53,7 @@ jobs: shell: bash working-directory: '.korifi' run: | - ../scripts/create-korifi-release.sh ${{ env.V_KORIFI }} + ../scripts/create-korifi-release.sh ${{ vars.KORIFI_GITHUB_REF }} - name: docker build run: make docker-build diff --git a/Makefile b/Makefile index 4ab6bcb..fefbf2d 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ VERSION ?= 0.0.0 #IMG ?= trinity.common.repositories.cloud.sap/kyma-module/cfapi-controller-$(VERSION) REGISTRY = ghcr.io IMG ?= kyma-project/cfapi/cfapi-controller -KORIFI_REF ?= v0.11.2 +KORIFI_GITHUB_REF ?= v0.11.2 # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.24.1 @@ -83,7 +83,7 @@ run: manifests generate fmt vet ## Run a controller from your host. .PHONY: docker-build docker-build: ## Build docker image with the manager. - docker build -t ${REGISTRY}/${IMG} --build-arg TARGETARCH=amd64 --build-arg V_KORIFI=${KORIFI_REF} . + docker build -t ${REGISTRY}/${IMG} --build-arg TARGETARCH=amd64 --build-arg V_KORIFI=${KORIFI_GITHUB_REF} . docker tag ${REGISTRY}/${IMG} ${VERSION} .PHONY: docker-push