From f5d82fddbf86353af6d0f44d9ae606ba51e8f3da Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Mon, 15 Mar 2021 14:26:12 +0100 Subject: [PATCH] publish KEDA images on GitHub Container Registry Signed-off-by: Zbynek Roubalik --- .github/workflows/build-tools.yml | 14 +++++++++----- .github/workflows/main-build.yml | 15 ++++++++++++++- .github/workflows/release-build.yml | 17 ++++++++++++++++- BUILD.md | 8 ++++---- CREATE-NEW-SCALER.md | 4 ++-- Makefile | 19 ++++++++++++++----- config/manager/kustomization.yaml | 4 ++-- config/manager/manager.yaml | 2 +- config/metrics-server/deployment.yaml | 2 +- config/metrics-server/kustomization.yaml | 4 ++-- 10 files changed, 65 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-tools.yml b/.github/workflows/build-tools.yml index 2120a9813b5..052742e8fe1 100644 --- a/.github/workflows/build-tools.yml +++ b/.github/workflows/build-tools.yml @@ -16,11 +16,15 @@ jobs: with: fetch-depth: 1 - - name: Login to Docker Hub - env: - DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} - run: echo $DOCKER_HUB_ACCESS_TOKEN | docker login -u $DOCKER_HUB_USERNAME --password-stdin + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.repository_owner }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GHCR_AUTH_PAT }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io - name: Build and publish Tools image run: make publish-build-tools diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 7530e0b5ceb..02ff9668ace 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -29,15 +29,28 @@ jobs: - name: Test run: make test + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.repository_owner }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GHCR_AUTH_PAT }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io + - name: Login to Docker Hub env: DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} run: echo $DOCKER_HUB_ACCESS_TOKEN | docker login -u $DOCKER_HUB_USERNAME --password-stdin - - name: Publish + - name: Publish on GitHub Container Registry run: make publish + - name: Publish on Docker Hub + run: make publish-dockerhub + - name: Run end to end tests env: AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }} diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 92a36021615..af4f5b3c780 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -26,6 +26,16 @@ jobs: - name: Go modules sync run: go mod tidy + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.repository_owner }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GHCR_AUTH_PAT }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io + - name: Login to Docker Hub env: DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} @@ -41,11 +51,16 @@ jobs: env: VERSION: ${{ steps.get_version.outputs.VERSION }} - - name: Publish KEDA images to Docker Hub + - name: Publish KEDA images on GitHub Container Registry run: make publish env: VERSION: ${{ steps.get_version.outputs.VERSION }} + - name: Publish KEDA images on Docker Hub + run: make publish-dockerhub + env: + VERSION: ${{ steps.get_version.outputs.VERSION }} + # Get release information to determine id of the current release - name: Get Release id: get-release-info diff --git a/BUILD.md b/BUILD.md index 6987602591d..f48cc6d199d 100644 --- a/BUILD.md +++ b/BUILD.md @@ -107,14 +107,14 @@ If you want to change KEDA's behaviour, or if you have created a new scaler (mor to deploy it as part of KEDA. Do the following: 1. Make your change in the code. -2. Build and publish on Docker Hub images with your changes, `IMAGE_REPO` should point to your repository - (specifying `IMAGE_REGISTRY` as well allows you to use registry of your choice eg. quay.io). +2. Build and publish images with your changes, `IMAGE_REPO` should point to your repository, +`IMAGE_REGISTRY` allows you to use registry of your choice eg. quay.io, default is `ghcr.io` ```bash - IMAGE_REPO=johndoe make publish + IMAGE_REGISTRY=docker.io IMAGE_REPO=johndoe make publish ``` 3. Deploy KEDA with your custom images. ```bash - IMAGE_REPO=johndoe make deploy + IMAGE_REGISTRY=docker.io IMAGE_REPO=johndoe make deploy ``` 4. Once the KEDA pods are up, check the logs to verify everything running ok, eg: ```bash diff --git a/CREATE-NEW-SCALER.md b/CREATE-NEW-SCALER.md index 41da0e3436e..0383438f54b 100644 --- a/CREATE-NEW-SCALER.md +++ b/CREATE-NEW-SCALER.md @@ -13,8 +13,8 @@ In order to develop a scaler, a developer should do the following: If you want to deploy locally 1. Open the terminal and go to the root of the source code -2. Run `IMAGE_REPO=johndoe make publish`, where `johndoe` is your Docker Hub repo, this will create and publish images with your build of KEDA into your repo. Please refer [the guide for local deployment](https://github.com/kedacore/keda/blob/main/BUILD.md#custom-keda-locally-outside-cluster) for more details. -3. Run `IMAGE_REPO=johndoe make deploy`, this will deploy KEDA to your cluster. +2. Run `IMAGE_REGISTRY=docker.io IMAGE_REPO=johndoe make publish`, where `johndoe` is your Docker Hub repo, this will create and publish images with your build of KEDA into your repo. Please refer [the guide for local deployment](https://github.com/kedacore/keda/blob/main/BUILD.md#custom-keda-locally-outside-cluster) for more details. +3. Run `IMAGE_REGISTRY=docker.io IMAGE_REPO=johndoe make deploy`, this will deploy KEDA to your cluster. ## Scaler interface diff --git a/Makefile b/Makefile index cb140585f5d..b99a3cfe1eb 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Variables # ################################################## VERSION ?= main -IMAGE_REGISTRY ?= docker.io +IMAGE_REGISTRY ?= ghcr.io IMAGE_REPO ?= kedacore IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda:$(VERSION) @@ -70,15 +70,24 @@ publish: docker-build docker push $(IMAGE_CONTROLLER) docker push $(IMAGE_ADAPTER) +# Mirror images on Docker Hub +.PHONY: publish-dockerhub +publish-dockerhub: + docker tag $(IMAGE_CONTROLLER) docker.io/$(IMAGE_REPO)/keda:$(VERSION) + docker tag $(IMAGE_ADAPTER) docker.io/$(IMAGE_REPO)/keda-metrics-apiserver:$(VERSION) + docker push docker.io/$(IMAGE_REPO)/keda:$(VERSION) + docker push docker.io/$(IMAGE_REPO)/keda-metrics-apiserver:$(VERSION) + + ################################################## # Release # ################################################## .PHONY: release release: manifests kustomize set-version cd config/manager && \ - $(KUSTOMIZE) edit set image docker.io/kedacore/keda=${IMAGE_CONTROLLER} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda=${IMAGE_CONTROLLER} cd config/metrics-server && \ - $(KUSTOMIZE) edit set image docker.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} cd config/default && \ $(KUSTOMIZE) edit add label -f app.kubernetes.io/version:${VERSION} $(KUSTOMIZE) build config/default > keda-$(VERSION).yaml @@ -110,9 +119,9 @@ uninstall: manifests kustomize .PHONY: deploy deploy: manifests kustomize cd config/manager && \ - $(KUSTOMIZE) edit set image docker.io/kedacore/keda=${IMAGE_CONTROLLER} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda=${IMAGE_CONTROLLER} cd config/metrics-server && \ - $(KUSTOMIZE) edit set image docker.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} + $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} cd config/default && \ $(KUSTOMIZE) edit add label -f app.kubernetes.io/version:${VERSION} $(KUSTOMIZE) build config/default | kubectl apply -f - diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index b317047a84d..77c0cd34eaf 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -4,6 +4,6 @@ resources: apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: -- name: docker.io/kedacore/keda - newName: docker.io/kedacore/keda +- name: ghcr.io/kedacore/keda + newName: ghcr.io/kedacore/keda newTag: main diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 395ab2b7b34..7dd3a15b0d9 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -25,7 +25,7 @@ spec: serviceAccountName: keda-operator containers: - name: keda-operator - image: docker.io/kedacore/keda:latest + image: ghcr.io/kedacore/keda:latest command: - /keda args: diff --git a/config/metrics-server/deployment.yaml b/config/metrics-server/deployment.yaml index 32e62725063..eaa0d46cbb3 100644 --- a/config/metrics-server/deployment.yaml +++ b/config/metrics-server/deployment.yaml @@ -22,7 +22,7 @@ spec: serviceAccountName: keda-operator containers: - name: keda-metrics-apiserver - image: docker.io/kedacore/keda-metrics-apiserver:latest + image: ghcr.io/kedacore/keda-metrics-apiserver:latest imagePullPolicy: Always resources: requests: diff --git a/config/metrics-server/kustomization.yaml b/config/metrics-server/kustomization.yaml index 743a08ca4f7..bd650d97723 100644 --- a/config/metrics-server/kustomization.yaml +++ b/config/metrics-server/kustomization.yaml @@ -9,6 +9,6 @@ resources: apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: -- name: docker.io/kedacore/keda-metrics-apiserver - newName: docker.io/kedacore/keda-metrics-apiserver +- name: ghcr.io/kedacore/keda-metrics-apiserver + newName: ghcr.io/kedacore/keda-metrics-apiserver newTag: main