From 1b6cdd2576091b65086256a9e93facdd3c94872c Mon Sep 17 00:00:00 2001 From: Benjamin Ernst Date: Thu, 6 Jul 2023 16:04:24 +0200 Subject: [PATCH 1/7] #32 update makefiles --- Makefile | 2 +- build/make/k8s-dogu.mk | 2 +- build/make/k8s.mk | 63 +++++++++++++++++++++++++++++++++++++-- build/make/version-sha.mk | 18 +++++++++++ 4 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 build/make/version-sha.mk diff --git a/Makefile b/Makefile index e15dda7..0f43cdd 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ VERSION=0.12.1 IMAGE_DEV=${K3CES_REGISTRY_URL_PREFIX}/${ARTIFACT_ID}:${VERSION} IMAGE=cloudogu/${ARTIFACT_ID}:${VERSION} GOTAG?=1.20.3 -MAKEFILES_VERSION=7.5.0 +MAKEFILES_VERSION=7.9.0 LINT_VERSION?=v1.52.1 ADDITIONAL_CLEAN=dist-clean diff --git a/build/make/k8s-dogu.mk b/build/make/k8s-dogu.mk index ff0973b..c498dcd 100644 --- a/build/make/k8s-dogu.mk +++ b/build/make/k8s-dogu.mk @@ -6,7 +6,7 @@ DOGU_JSON_DEV_FILE=${TARGET_DIR}/dogu.json ARTIFACT_ID=$(shell $(BINARY_YQ) -e ".Name" $(DOGU_JSON_FILE) | sed "s|.*/||g") # Namespace of the dogu is extracted from the dogu.json ARTIFACT_NAMESPACE=$(shell $(BINARY_YQ) -e ".Name" $(DOGU_JSON_FILE) | sed "s|/.*||g") -# Namespace of the dogu is extracted from the dogu.json +# Version of the dogu is extracted from the dogu.json VERSION=$(shell $(BINARY_YQ) -e ".Version" $(DOGU_JSON_FILE)) # Image of the dogu is extracted from the dogu.json IMAGE=$(shell $(BINARY_YQ) -e ".Image" $(DOGU_JSON_FILE)):$(VERSION) diff --git a/build/make/k8s.mk b/build/make/k8s.mk index 8e0fa4a..9bcd5ea 100644 --- a/build/make/k8s.mk +++ b/build/make/k8s.mk @@ -7,6 +7,8 @@ endif ## Variables BINARY_YQ = $(UTILITY_BIN_PATH)/yq +BINARY_HELM = $(UTILITY_BIN_PATH)/helm +BINARY_HELMIFY = $(UTILITY_BIN_PATH)/helmify # The productive tag of the image IMAGE ?= @@ -19,6 +21,8 @@ K3CES_REGISTRY_URL_PREFIX="${K3S_CLUSTER_FQDN}:${K3S_LOCAL_REGISTRY_PORT}" # the current namespace and the dev image. K8S_RESOURCE_TEMP_FOLDER ?= $(TARGET_DIR)/make/k8s K8S_RESOURCE_TEMP_YAML ?= $(K8S_RESOURCE_TEMP_FOLDER)/$(ARTIFACT_ID)_$(VERSION).yaml +K8S_HELM_TARGET ?= $(K8S_RESOURCE_TEMP_FOLDER)/helm +K8S_HELM_RESSOURCES ?= k8s/helm ##@ K8s - Variables @@ -75,6 +79,55 @@ k8s-apply: k8s-generate $(K8S_POST_GENERATE_TARGETS) ## Applies all generated K8 @echo "Apply generated K8s resources..." @kubectl apply -f $(K8S_RESOURCE_TEMP_YAML) --namespace=${NAMESPACE} +##@ K8s - Helm general + +${K8S_HELM_RESSOURCES}/Chart.yaml: ${BINARY_HELM} ## Creates the Chart.yaml-template if missing + @echo "Create Chart.yaml..." + @mkdir -p ${K8S_HELM_RESSOURCES}/tmp/ + @${BINARY_HELM} create ${K8S_HELM_RESSOURCES}/tmp/${ARTIFACT_ID} + @cp ${K8S_HELM_RESSOURCES}/tmp/${ARTIFACT_ID}/Chart.yaml ${K8S_HELM_RESSOURCES}/ + @rm -dr ${K8S_HELM_RESSOURCES}/tmp + @sed -i 's/appVersion: ".*"/appVersion: "0.0.0-replaceme"/' ${K8S_HELM_RESSOURCES}/Chart.yaml + @sed -i 's/version: .*/version: 0.0.0-replaceme/' ${K8S_HELM_RESSOURCES}/Chart.yaml + +.PHONY: k8s-helm-delete +k8s-helm-delete: ${BINARY_HELM} ## Uninstalls the current helm chart. + @echo "Uninstall helm chart" + @${BINARY_HELM} uninstall ${ARTIFACT_ID} + +.PHONY: k8s-helm-generate-chart +k8s-helm-generate-chart: ## Generates the final helm chart. + @echo "Generate helm chart..." + @rm -drf ${K8S_HELM_TARGET} # delete folder, so Chart.yaml is newly created from template + @mkdir -p ${K8S_HELM_TARGET} + @cat $(K8S_RESOURCE_TEMP_YAML) | ${BINARY_HELMIFY} ${K8S_HELM_TARGET} + @cp ${K8S_HELM_RESSOURCES}/Chart.yaml ${K8S_HELM_TARGET} + @sed -i 's/appVersion: "0.0.0-replaceme"/appVersion: "${VERSION}"/' ${K8S_HELM_TARGET}/Chart.yaml + @sed -i 's/version: 0.0.0-replaceme/version: ${VERSION}/' ${K8S_HELM_TARGET}/Chart.yaml + +##@ K8s - Helm dev targets + +.PHONY: k8s-helm-generate +k8s-helm-generate: k8s-generate ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart ## Generates the final helm chart with dev-urls. + +.PHONY: k8s-helm-apply +k8s-helm-apply: ${BINARY_HELM} image-import k8s-helm-generate $(K8S_POST_GENERATE_TARGETS) ## Generates and installs the helm chart. + @echo "Apply generated helm chart" + @${BINARY_HELM} upgrade -i ${ARTIFACT_ID} ${K8S_HELM_TARGET} + +.PHONY: k8s-helm-reinstall +k8s-helm-reinstall: k8s-helm-delete k8s-helm-apply ## Uninstalls the current helm chart and reinstalls it. + +##@ K8s - Helm release targets + +.PHONY: k8s-helm-generate-release +k8s-helm-generate-release: $(K8S_PRE_GENERATE_TARGETS) ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart ## Generates the final helm chart with release urls. + +.PHONY: k8s-helm-package-release +k8s-helm-package-release: ${BINARY_HELM} k8s-helm-generate-release $(K8S_POST_GENERATE_TARGETS) ## Generates and packages the helm chart with release urls. + @echo "Package generated helm chart" + @${BINARY_HELM} package ${K8S_HELM_TARGET} -d ${K8S_HELM_TARGET} + ##@ K8s - Docker .PHONY: docker-build @@ -115,5 +168,11 @@ __check_defined = \ $(if $(value $1),, \ $(error Undefined $1$(if $2, ($2)))) -${BINARY_YQ}: $(UTILITY_BIN_PATH) ## Download controller-gen locally if necessary. - $(call go-get-tool,$(BINARY_YQ),github.com/mikefarah/yq/v4@v4.25.1) \ No newline at end of file +${BINARY_YQ}: $(UTILITY_BIN_PATH) ## Download yq locally if necessary. + $(call go-get-tool,$(BINARY_YQ),github.com/mikefarah/yq/v4@v4.25.1) + +${BINARY_HELM}: $(UTILITY_BIN_PATH) ## Download helm locally if necessary. + $(call go-get-tool,$(BINARY_HELM),helm.sh/helm/v3/cmd/helm@latest) + +${BINARY_HELMIFY}: $(UTILITY_BIN_PATH) ## Download helmify locally if necessary. + $(call go-get-tool,$(BINARY_HELMIFY),github.com/arttor/helmify/cmd/helmify@latest) \ No newline at end of file diff --git a/build/make/version-sha.mk b/build/make/version-sha.mk new file mode 100644 index 0000000..1335532 --- /dev/null +++ b/build/make/version-sha.mk @@ -0,0 +1,18 @@ +##@ Version + +# This makefile is used to get the sha256sum of a specific github tag-src.tar.gz or .zip. +# You may set any of the following variables before your make call to change the hash url. + +SHA_SUM_ORGANISATION?="cloudogu" +SHA_SUM_REPOSITORY?="ecosystem" +SHA_SUM_FILE_TYPE?="tar.gz" +SHA_SUM_VERSION?="v20.04.4-2" +SHA_SUM_URL?="https://github.com/${SHA_SUM_ORGANISATION}/${SHA_SUM_REPOSITORY}/archive/refs/tags/${SHA_SUM_VERSION}.${SHA_SUM_FILE_TYPE}" + +.PHONY: sha-sum +sha-sum: ## Print out the version + @echo "Downloading from: ${SHA_SUM_URL}" + @wget -O - -o /dev/null "${SHA_SUM_URL}" > .download.for.hash \ + || (echo "Could not be downloaded" && exit 1) \ + && cat .download.for.hash | sha256sum + @rm -f .download.for.hash From 29421b124880b8c8a1c9795783f4f262dd9180a8 Mon Sep 17 00:00:00 2001 From: Benjamin Ernst Date: Thu, 6 Jul 2023 16:34:08 +0200 Subject: [PATCH 2/7] #32 add helm-chart release --- CHANGELOG.md | 2 ++ Jenkinsfile | 25 +++++++++++++++++++++++-- Makefile | 17 ++++++++++++----- config/manager/kustomization.yaml | 14 +++++++------- k8s/helm/Chart.yaml | 24 ++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 k8s/helm/Chart.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e29d7..7b029cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- [#32] Add Helm chart release process to project ## [v0.12.1] - 2023-06-01 ### Fixed diff --git a/Jenkinsfile b/Jenkinsfile index 7f0bf68..d29b3a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ #!groovy -@Library(['github.com/cloudogu/ces-build-lib@1.64.2']) +@Library(['github.com/cloudogu/ces-build-lib@1.65.0']) import com.cloudogu.ces.cesbuildlib.* // Creating necessary git objects @@ -12,11 +12,14 @@ github = new GitHub(this, git) changelog = new Changelog(this) Docker docker = new Docker(this) gpg = new Gpg(this, docker) +goVersion = "1.20" // Configuration of repository repositoryOwner = "cloudogu" repositoryName = "k8s-service-discovery" project = "github.com/${repositoryOwner}/${repositoryName}" +registry = "registry.cloudogu.com" +registry_namespace = "k8s" // Configuration of branches productionReleaseBranch = "main" @@ -40,7 +43,7 @@ node('docker') { } docker - .image('golang:1.20.3') + .image("golang:${goVersion}") .mountJenkinsUser() .inside("--volume ${WORKSPACE}:/go/src/${project} -w /go/src/${project}") { @@ -202,6 +205,24 @@ void stageAutomaticRelease() { registry.pushK8sYaml(targetOperatorResourceYaml, repositoryName, "k8s", "${controllerVersion}") } + stage('Push Helm chart to Harbor') { + new Docker(this) + .image("golang:${goVersion}") + .mountJenkinsUser() + .inside("--volume ${WORKSPACE}:/go/src/${project} -w /go/src/${project}") + { + make 'k8s-helm-package-release' + + Makefile makefile = new Makefile(this) + String controllerVersion = makefile.getVersion() + + withCredentials([usernamePassword(credentialsId: 'harborhelmchartpush', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) { + sh ".bin/helm registry login ${registry} --username '${HARBOR_USERNAME}' --password '${HARBOR_PASSWORD}'" + sh ".bin/helm push target/make/k8s/helm/${repositoryName}-${controllerVersion}.tgz oci://${registry}/${registry_namespace}/" + } + } + } + stage('Add Github-Release') { releaseId = github.createReleaseWithChangelog(releaseVersion, changelog, productionReleaseBranch) } diff --git a/Makefile b/Makefile index 0f43cdd..f53a072 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ include build/make/mocks.mk K8S_RUN_PRE_TARGETS=setup-etcd-port-forward PRE_COMPILE=generate -K8S_PRE_GENERATE_TARGETS=k8s-create-temporary-resource generate-warp-config generate-menu-json template-dev-only-image-pull-policy +K8S_PRE_GENERATE_TARGETS=k8s-create-temporary-resource template-dev-only-image-pull-policy include build/make/k8s-controller.mk @@ -52,13 +52,13 @@ setup-etcd-port-forward: .PHONY: generate-warp-config generate-warp-config: - @echo "---" >> $(K8S_RESOURCE_TEMP_YAML) - @cat $(K8S_WARP_CONFIG_RESOURCE_YAML) >> $(K8S_RESOURCE_TEMP_YAML) + @echo "Add Warp-Config" + @cp $(K8S_WARP_CONFIG_RESOURCE_YAML) ${K8S_HELM_TARGET}/templates .PHONY: generate-menu-json generate-menu-json: - @echo "---" >> $(K8S_RESOURCE_TEMP_YAML) - @cat $(K8S_WARP_MENU_JSON_YAML) >> $(K8S_RESOURCE_TEMP_YAML) + @echo "Add menu.json" + @cp $(K8S_WARP_MENU_JSON_YAML) ${K8S_HELM_TARGET}/templates create-temporary-release-resources: $(K8S_PRE_GENERATE_TARGETS) @@ -66,3 +66,10 @@ create-temporary-release-resources: $(K8S_PRE_GENERATE_TARGETS) template-dev-only-image-pull-policy: $(BINARY_YQ) @echo "Setting pull policy to always!" @$(BINARY_YQ) -i e "(select(.kind == \"Deployment\").spec.template.spec.containers[]|select(.image == \"*$(ARTIFACT_ID)*\").imagePullPolicy)=\"Always\"" $(K8S_RESOURCE_TEMP_YAML) + +##@ Override k8s-helm-generate targets to add menu.json & warp-config +.PHONY: k8s-helm-generate +k8s-helm-generate: k8s-generate ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart generate-menu-json generate-warp-config ## Generates the final helm chart with dev-urls. + +.PHONY: k8s-helm-generate-release +k8s-helm-generate-release: $(K8S_PRE_GENERATE_TARGETS) ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart generate-menu-json generate-warp-config ## Generates the final helm chart with release urls. diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 69ffc7e..61ba000 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,14 +1,14 @@ resources: - - manager.yaml +- manager.yaml generatorOptions: disableNameSuffixHash: true configMapGenerator: - - files: - - controller_manager_config.yaml - name: manager-config +- files: + - controller_manager_config.yaml + name: manager-config apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - - name: controller - newName: cloudogu/k8s-service-discovery - newTag: 0.12.1 +- name: controller + newName: cloudogu/k8s-service-discovery + newTag: 0.12.1 diff --git a/k8s/helm/Chart.yaml b/k8s/helm/Chart.yaml new file mode 100644 index 0000000..25e8bf4 --- /dev/null +++ b/k8s/helm/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: k8s-service-discovery +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.0-replaceme + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.0.0-replaceme" From 5272dc6e9aa3e35fae8017209f3d593539e3c4ad Mon Sep 17 00:00:00 2001 From: Benjamin Ernst Date: Fri, 7 Jul 2023 10:28:08 +0200 Subject: [PATCH 3/7] #32 remove helmify --- Makefile | 17 +++++------------ build/make/k8s.mk | 17 +++++++---------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index f53a072..0f43cdd 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ include build/make/mocks.mk K8S_RUN_PRE_TARGETS=setup-etcd-port-forward PRE_COMPILE=generate -K8S_PRE_GENERATE_TARGETS=k8s-create-temporary-resource template-dev-only-image-pull-policy +K8S_PRE_GENERATE_TARGETS=k8s-create-temporary-resource generate-warp-config generate-menu-json template-dev-only-image-pull-policy include build/make/k8s-controller.mk @@ -52,13 +52,13 @@ setup-etcd-port-forward: .PHONY: generate-warp-config generate-warp-config: - @echo "Add Warp-Config" - @cp $(K8S_WARP_CONFIG_RESOURCE_YAML) ${K8S_HELM_TARGET}/templates + @echo "---" >> $(K8S_RESOURCE_TEMP_YAML) + @cat $(K8S_WARP_CONFIG_RESOURCE_YAML) >> $(K8S_RESOURCE_TEMP_YAML) .PHONY: generate-menu-json generate-menu-json: - @echo "Add menu.json" - @cp $(K8S_WARP_MENU_JSON_YAML) ${K8S_HELM_TARGET}/templates + @echo "---" >> $(K8S_RESOURCE_TEMP_YAML) + @cat $(K8S_WARP_MENU_JSON_YAML) >> $(K8S_RESOURCE_TEMP_YAML) create-temporary-release-resources: $(K8S_PRE_GENERATE_TARGETS) @@ -66,10 +66,3 @@ create-temporary-release-resources: $(K8S_PRE_GENERATE_TARGETS) template-dev-only-image-pull-policy: $(BINARY_YQ) @echo "Setting pull policy to always!" @$(BINARY_YQ) -i e "(select(.kind == \"Deployment\").spec.template.spec.containers[]|select(.image == \"*$(ARTIFACT_ID)*\").imagePullPolicy)=\"Always\"" $(K8S_RESOURCE_TEMP_YAML) - -##@ Override k8s-helm-generate targets to add menu.json & warp-config -.PHONY: k8s-helm-generate -k8s-helm-generate: k8s-generate ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart generate-menu-json generate-warp-config ## Generates the final helm chart with dev-urls. - -.PHONY: k8s-helm-generate-release -k8s-helm-generate-release: $(K8S_PRE_GENERATE_TARGETS) ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart generate-menu-json generate-warp-config ## Generates the final helm chart with release urls. diff --git a/build/make/k8s.mk b/build/make/k8s.mk index 9bcd5ea..5a957e7 100644 --- a/build/make/k8s.mk +++ b/build/make/k8s.mk @@ -8,7 +8,6 @@ endif BINARY_YQ = $(UTILITY_BIN_PATH)/yq BINARY_HELM = $(UTILITY_BIN_PATH)/helm -BINARY_HELMIFY = $(UTILITY_BIN_PATH)/helmify # The productive tag of the image IMAGE ?= @@ -96,11 +95,11 @@ k8s-helm-delete: ${BINARY_HELM} ## Uninstalls the current helm chart. @${BINARY_HELM} uninstall ${ARTIFACT_ID} .PHONY: k8s-helm-generate-chart -k8s-helm-generate-chart: ## Generates the final helm chart. +k8s-helm-generate-chart: ${K8S_HELM_RESSOURCES}/Chart.yaml $(K8S_RESOURCE_TEMP_FOLDER) ## Generates the final helm chart. @echo "Generate helm chart..." @rm -drf ${K8S_HELM_TARGET} # delete folder, so Chart.yaml is newly created from template - @mkdir -p ${K8S_HELM_TARGET} - @cat $(K8S_RESOURCE_TEMP_YAML) | ${BINARY_HELMIFY} ${K8S_HELM_TARGET} + @mkdir -p ${K8S_HELM_TARGET}/templates + @cp $(K8S_RESOURCE_TEMP_YAML) ${K8S_HELM_TARGET}/templates @cp ${K8S_HELM_RESSOURCES}/Chart.yaml ${K8S_HELM_TARGET} @sed -i 's/appVersion: "0.0.0-replaceme"/appVersion: "${VERSION}"/' ${K8S_HELM_TARGET}/Chart.yaml @sed -i 's/version: 0.0.0-replaceme/version: ${VERSION}/' ${K8S_HELM_TARGET}/Chart.yaml @@ -108,7 +107,7 @@ k8s-helm-generate-chart: ## Generates the final helm chart. ##@ K8s - Helm dev targets .PHONY: k8s-helm-generate -k8s-helm-generate: k8s-generate ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart ## Generates the final helm chart with dev-urls. +k8s-helm-generate: k8s-generate k8s-helm-generate-chart ## Generates the final helm chart with dev-urls. .PHONY: k8s-helm-apply k8s-helm-apply: ${BINARY_HELM} image-import k8s-helm-generate $(K8S_POST_GENERATE_TARGETS) ## Generates and installs the helm chart. @@ -121,7 +120,8 @@ k8s-helm-reinstall: k8s-helm-delete k8s-helm-apply ## Uninstalls the current hel ##@ K8s - Helm release targets .PHONY: k8s-helm-generate-release -k8s-helm-generate-release: $(K8S_PRE_GENERATE_TARGETS) ${K8S_HELM_RESSOURCES}/Chart.yaml ${BINARY_HELMIFY} $(K8S_RESOURCE_TEMP_FOLDER) k8s-helm-generate-chart ## Generates the final helm chart with release urls. +k8s-helm-generate-release: $(K8S_PRE_GENERATE_TARGETS) k8s-helm-generate-chart ## Generates the final helm chart with release urls. + @sed -i "s/'{{ .Namespace }}'/'{{ .Release.Namespace }}'/" ${K8S_HELM_TARGET}/templates/$(ARTIFACT_ID)_$(VERSION).yaml .PHONY: k8s-helm-package-release k8s-helm-package-release: ${BINARY_HELM} k8s-helm-generate-release $(K8S_POST_GENERATE_TARGETS) ## Generates and packages the helm chart with release urls. @@ -172,7 +172,4 @@ ${BINARY_YQ}: $(UTILITY_BIN_PATH) ## Download yq locally if necessary. $(call go-get-tool,$(BINARY_YQ),github.com/mikefarah/yq/v4@v4.25.1) ${BINARY_HELM}: $(UTILITY_BIN_PATH) ## Download helm locally if necessary. - $(call go-get-tool,$(BINARY_HELM),helm.sh/helm/v3/cmd/helm@latest) - -${BINARY_HELMIFY}: $(UTILITY_BIN_PATH) ## Download helmify locally if necessary. - $(call go-get-tool,$(BINARY_HELMIFY),github.com/arttor/helmify/cmd/helmify@latest) \ No newline at end of file + $(call go-get-tool,$(BINARY_HELM),helm.sh/helm/v3/cmd/helm@latest) \ No newline at end of file From 4eda590badbe577489131953e237ddd86e897d90 Mon Sep 17 00:00:00 2001 From: Benjamin Ernst Date: Fri, 7 Jul 2023 11:01:21 +0200 Subject: [PATCH 4/7] #32 update makefiles --- Makefile | 2 +- build/make/k8s.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0f43cdd..b1ef9f5 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ VERSION=0.12.1 IMAGE_DEV=${K3CES_REGISTRY_URL_PREFIX}/${ARTIFACT_ID}:${VERSION} IMAGE=cloudogu/${ARTIFACT_ID}:${VERSION} GOTAG?=1.20.3 -MAKEFILES_VERSION=7.9.0 +MAKEFILES_VERSION=7.10.0 LINT_VERSION?=v1.52.1 ADDITIONAL_CLEAN=dist-clean diff --git a/build/make/k8s.mk b/build/make/k8s.mk index 5a957e7..c569fa3 100644 --- a/build/make/k8s.mk +++ b/build/make/k8s.mk @@ -172,4 +172,4 @@ ${BINARY_YQ}: $(UTILITY_BIN_PATH) ## Download yq locally if necessary. $(call go-get-tool,$(BINARY_YQ),github.com/mikefarah/yq/v4@v4.25.1) ${BINARY_HELM}: $(UTILITY_BIN_PATH) ## Download helm locally if necessary. - $(call go-get-tool,$(BINARY_HELM),helm.sh/helm/v3/cmd/helm@latest) \ No newline at end of file + $(call go-get-tool,$(BINARY_HELM),helm.sh/helm/v3/cmd/helm@latest) From 9493cd5d950f3bb672b9e0d6a9647f0ca91edfd0 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 7 Jul 2023 13:21:50 +0200 Subject: [PATCH 5/7] #32 Refactoring --- Jenkinsfile | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d29b3a9..da06da6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,6 +13,7 @@ changelog = new Changelog(this) Docker docker = new Docker(this) gpg = new Gpg(this, docker) goVersion = "1.20" +makefile = new Makefile(this) // Configuration of repository repositoryOwner = "cloudogu" @@ -76,14 +77,12 @@ node('docker') { K3d k3d = new K3d(this, "${WORKSPACE}", "${WORKSPACE}/k3d", env.PATH) try { - Makefile makefile = new Makefile(this) - String controllerVersion = makefile.getVersion() - stage('Set up k3d cluster') { k3d.startK3d() } def imageName + String controllerVersion = makefile.getVersion() stage('Build & Push Image') { imageName=k3d.buildAndPushToLocalRegistry("cloudogu/${repositoryName}", controllerVersion) } @@ -128,14 +127,12 @@ void gitWithCredentials(String command) { void stageLintK8SResources() { String kubevalImage = "cytopia/kubeval:0.13" - Makefile makefile = new Makefile(this) - String controllerVersion = makefile.getVersion() docker .image(kubevalImage) .inside("-v ${WORKSPACE}/target/make/k8s:/data -t --entrypoint=") { - sh "kubeval /data/${repositoryName}_${controllerVersion}.yaml --ignore-missing-schemas" + sh "kubeval /data/${repositoryName}_${makefile.getVersion()}.yaml --ignore-missing-schemas" } } @@ -184,6 +181,7 @@ void stageAutomaticRelease() { if (gitflow.isReleaseBranch()) { String releaseVersion = git.getSimpleBranchName() String dockerReleaseVersion = releaseVersion.split("v")[1] + String controllerVersion = makefile.getVersion() stage('Build & Push Image') { def dockerImage = docker.build("cloudogu/${repositoryName}:${dockerReleaseVersion}") @@ -197,8 +195,6 @@ void stageAutomaticRelease() { } stage('Push to Registry') { - Makefile makefile = new Makefile(this) - String controllerVersion = makefile.getVersion() GString targetOperatorResourceYaml = "target/make/k8s/${repositoryName}_${controllerVersion}.yaml" DoguRegistry registry = new DoguRegistry(this) @@ -213,9 +209,6 @@ void stageAutomaticRelease() { { make 'k8s-helm-package-release' - Makefile makefile = new Makefile(this) - String controllerVersion = makefile.getVersion() - withCredentials([usernamePassword(credentialsId: 'harborhelmchartpush', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) { sh ".bin/helm registry login ${registry} --username '${HARBOR_USERNAME}' --password '${HARBOR_PASSWORD}'" sh ".bin/helm push target/make/k8s/helm/${repositoryName}-${controllerVersion}.tgz oci://${registry}/${registry_namespace}/" From 4e7ab8fd6d42997f1a9b9f1404d2d054f0752943 Mon Sep 17 00:00:00 2001 From: meiserloh Date: Fri, 7 Jul 2023 13:39:40 +0200 Subject: [PATCH 6/7] Bump version --- Dockerfile | 2 +- Makefile | 2 +- config/manager/kustomization.yaml | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5eb0045..090716e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ RUN make compile-generic FROM gcr.io/distroless/static:nonroot LABEL maintainer="hello@cloudogu.com" \ NAME="k8s-service-discovery" \ - VERSION="0.12.1" + VERSION="0.13.0" WORKDIR / diff --git a/Makefile b/Makefile index b1ef9f5..e553366 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Set these to the desired values ARTIFACT_ID=k8s-service-discovery -VERSION=0.12.1 +VERSION=0.13.0 ## Image URL to use all building/pushing image targets IMAGE_DEV=${K3CES_REGISTRY_URL_PREFIX}/${ARTIFACT_ID}:${VERSION} diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 61ba000..f04a4dd 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,14 +1,14 @@ resources: -- manager.yaml + - manager.yaml generatorOptions: disableNameSuffixHash: true configMapGenerator: -- files: - - controller_manager_config.yaml - name: manager-config + - files: + - controller_manager_config.yaml + name: manager-config apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: -- name: controller - newName: cloudogu/k8s-service-discovery - newTag: 0.12.1 + - name: controller + newName: cloudogu/k8s-service-discovery + newTag: 0.13.0 From 9a134d10cad4511e3785e0ecf019edd4e7bc7f30 Mon Sep 17 00:00:00 2001 From: meiserloh Date: Fri, 7 Jul 2023 13:39:56 +0200 Subject: [PATCH 7/7] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b029cd..1ea449b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [v0.13.0] - 2023-07-07 ### Added - [#32] Add Helm chart release process to project