Skip to content

Commit

Permalink
publish KEDA images on GitHub Container Registry
Browse files Browse the repository at this point in the history
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
  • Loading branch information
Zbynek Roubalik committed Mar 15, 2021
1 parent 397ab81 commit 31f4846
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 24 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/build-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions CREATE-NEW-SCALER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 -
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/metrics-server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions config/metrics-server/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 31f4846

Please sign in to comment.