Skip to content

Commit

Permalink
Create make release target to update versions (#610)
Browse files Browse the repository at this point in the history
* Added some basic labels to the resource deployments

* Corrected the formatting for deploy file

* Updated versions to 1.1.0

* Updated Makefile to substitute version in version.go

* Revert version change in go file and use IMAGE_TAG instead of new VERSION variable

* Updated release process for the new labels

* Update HPA to reference the ScaledObject in the part-of label

* Add a release target to the Makefile

* Disable printing to output for the new commands in Makefile

* Update release process documentation

* Move release target into its own section

* Update release process doc with shorthand

* Change IMAGE_TAG to VERSION
  • Loading branch information
Cottonglow authored Feb 5, 2020
1 parent 44fa696 commit c7a9ceb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}

- name: Publish
run: make IMAGE_TAG=$VERSION publish
run: make VERSION=$VERSION publish
2 changes: 1 addition & 1 deletion CREATE-NEW-SCALER.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In order to develop a scaler, a developer should do the following:
6. Run `make build` from the root of KEDA and your scaler is ready.

If you want to deploy locally
1. Run `export IMAGE_TAG=local`
1. Run `export VERSION=local`
2. Open the terminal and go to the root of the source code
3. Run `make build`
5. If you haven't done it yet clone the charts repository: `git clone [email protected]:kedacore/charts.git`
Expand Down
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
##################################################
# Variables #
##################################################
IMAGE_TAG ?= master
VERSION ?= master
IMAGE_REGISTRY ?= docker.io
IMAGE_REPO ?= kedacore

IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda:$(IMAGE_TAG)
IMAGE_ADAPTER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-metrics-adapter:$(IMAGE_TAG)
IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda:$(VERSION)
IMAGE_ADAPTER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-metrics-adapter:$(VERSION)

ARCH ?=amd64
CGO ?=0
Expand Down Expand Up @@ -49,6 +49,20 @@ publish: build
docker push $(IMAGE_ADAPTER)
docker push $(IMAGE_CONTROLLER)

##################################################
# Release #
##################################################
K8S_DEPLOY_FILES = $(shell find ./deploy -name '*.yaml')

.PHONY: release
release:
@sed -i 's@Version =.*@Version = "$(VERSION)"@g' ./version/version.go;
@for file in $(K8S_DEPLOY_FILES); do \
sed -i '[email protected]/version:.*@app.kubernetes.io/version: "$(VERSION)"@g' $$file; \
sed -i 's@image: docker.io/kedacore/keda:.*@image: docker.io/kedacore/keda:$(VERSION)@g' $$file; \
sed -i 's@image: docker.io/kedacore/keda-metrics-adapter:.*@image: docker.io/kedacore/keda-metrics-adapter:$(VERSION)@g' $$file; \
done

##################################################
# Build #
##################################################
Expand All @@ -66,12 +80,12 @@ build: checkenv build-adapter build-controller
.PHONY: build-controller
build-controller: generate-api pkg/scalers/liiklus/LiiklusService.pb.go
$(GO_BUILD_VARS) operator-sdk build $(IMAGE_CONTROLLER) \
--go-build-args "-ldflags -X=main.GitCommit=$(GIT_COMMIT) -ldflags -X=github.com/kedacore/keda/version.Version=$(IMAGE_TAG) -o build/_output/bin/keda"
--go-build-args "-ldflags -X=main.GitCommit=$(GIT_COMMIT) -ldflags -X=github.com/kedacore/keda/version.Version=$(VERSION) -o build/_output/bin/keda"

.PHONY: build-adapter
build-adapter: generate-api pkg/scalers/liiklus/LiiklusService.pb.go
$(GO_BUILD_VARS) go build \
-ldflags "-X=main.GitCommit=$(GIT_COMMIT) -X=github.com/kedacore/keda/version.Version=$(IMAGE_TAG)" \
-ldflags "-X=main.GitCommit=$(GIT_COMMIT) -X=github.com/kedacore/keda/version.Version=$(VERSION)" \
-o build/_output/bin/keda-adapter \
cmd/adapter/main.go
docker build -f build/Dockerfile.adapter -t $(IMAGE_ADAPTER) .
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ 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. In terminal, create an environment variable `IMAGE_TAG` and assign it a value for your preference, this tag will
2. In terminal, create an environment variable `VERSION` and assign it a value for your preference, this tag will
be used when creating the operator image that will run KEDA.
***Note***: make sure it doesn't clash with the official tags of KEDA containers in DockerHub.
3. Still in terminal, run `make build` at the root of the source code. This will also build the docker image for
Expand All @@ -149,7 +149,7 @@ to deploy it as part of KEDA. Do the following:
5. Still in terminal, navigate to the `charts/keda` folder (downloaded in step 4), and run the following command
(don't forget to replace the placeholder text in the command):
```bash
helm install . --set image.keda=kedacore/keda:$IMAGE_TAG,image.metricsAdapter=kedacore/keda-metrics-adapter:$IMAGE_TAG,image.pullPolicy=IfNotPresent
helm install . --set image.keda=kedacore/keda:$VERSION,image.metricsAdapter=kedacore/keda-metrics-adapter:$VERSION,image.pullPolicy=IfNotPresent
```
This will use the images built at step 3. Notice the need to override the image pullPolicy to `IfNotPresent` in
order to use the locally built images and not try to pull the images from remote repo on Docker Hub (and complain
Expand Down
26 changes: 6 additions & 20 deletions RELEASE-PROCESS.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,12 @@ The next version will thus be 1.2.0

**1) Update KEDA version in code and YAMLs**

Update version string in:
https://github.com/kedacore/keda/blob/master/version/version.go

Update sections related to images in these yamls:
https://github.com/kedacore/keda/blob/master/deploy/12-operator.yaml
https://github.com/kedacore/keda/blob/master/deploy/22-metrics-deployment.yaml

Update sections related to the version label in these yamls:
https://github.com/kedacore/keda/blob/master/deploy/00-namespace.yaml
https://github.com/kedacore/keda/blob/master/deploy/01-service_account.yaml
https://github.com/kedacore/keda/blob/master/deploy/10-cluster_role.yaml
https://github.com/kedacore/keda/blob/master/deploy/11-role_binding.yaml
https://github.com/kedacore/keda/blob/master/deploy/12-operator.yaml
https://github.com/kedacore/keda/blob/master/deploy/20-metrics-cluster_role.yaml
https://github.com/kedacore/keda/blob/master/deploy/21-metrics-role_binding.yaml
https://github.com/kedacore/keda/blob/master/deploy/22-metrics-deployment.yaml
https://github.com/kedacore/keda/blob/master/deploy/23-metrics-service.yaml
https://github.com/kedacore/keda/blob/master/deploy/24-metrics-api_service.yaml

Commit these changes.
* Run the following command to update the version, setting the `VERSION` value to the next version, eg 1.2.0:
```bash
VERSION=1.2.0 make release
```
> Note: This will update the version labels and images in the yaml files located in the `deploy` folder as well as the version in `version.go`.
* Commit these changes.

**2) Deploy the new KEDA images to Docker Hub**

Expand Down

0 comments on commit c7a9ceb

Please sign in to comment.