Skip to content

Commit

Permalink
Merge branch 'release/v9.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ppxl committed Dec 1, 2023
2 parents 41f2e15 + 02425f0 commit 1053247
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 17 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v9.0.1](https://github.com/cloudogu/makefiles/releases/tag/v9.0.1) 2023-12-01
### Changed
- Make the targets for generate and copy manifests configurable. External components have to override them with empty values because they do not have CRDs in go-code. [#172]
- Make the target to importing images configurable. Components with own images to build should override `IMAGE_IMPORT_TARGET` with `image-import`. [#172]
- Make the target to check all environment variables configurable. Components with own images to build should override `CHECK_VAR_TARGETS` with `check-all-vars`. [#172]

### Fixed
- fixes wrong container image version `latest` during `image-import` [#172]
- the k8s/CRD target `helm-package-release` renames to `helm-package` in order to harmonize with `crd-helm-package`
- the k8s/CRD target `manifests` honors now the variable `HELM_CRD_SOURCE_DIR` if set to a different value

### Added
- runs k8s/CRD target `crd-add-labels` by default after the CRD generation target `manifest`

## [v9.0.0](https://github.com/cloudogu/makefiles/releases/tag/v9.0.0) 2023-11-30
Breaking change ahead! [#170]

Expand Down Expand Up @@ -66,7 +80,7 @@ Please take the time to revise the changes for your project if you use them afte
- adds k8s/crd target `crd-helm-lint` to lint the CRD's Helm chart
- adds k8s/component target `helm-lint` to lint the component's Helm chart

## [v8.8.0](https://github.com/cloudogu/makefiles/releases/tag/v8.7.3) 2023-11-21
## [v8.8.0](https://github.com/cloudogu/makefiles/releases/tag/v8.8.0) 2023-11-21
### Added
- [#168] Publish targets for yarn to run publish tasks in a unified way
- update the variable NODE_VERSION to define the used version of nodeJs (default: 8)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set these to the desired values
ARTIFACT_ID=makefiles
MAKEFILES_VERSION=9.0.0
MAKEFILES_VERSION=9.0.1
VERSION=${MAKEFILES_VERSION}

.DEFAULT_GOAL:=help
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ This module provides targets for developing K8s Cloudogu EcoSystem components (i
- `helm-reinstall` - Uninstalls the current helm chart and re-installs it
- `helm-chart-import` - Imports the currently available chart into the cluster-local registry
- Release targets
- `helm-package-release` - Generates and packages the helm chart with release urls.
- `helm-package` - Generates and packages the helm chart with release urls.
- `helm-generate-release` - Generates the final helm chart with release urls.
- Component-oriented targets
- `component-generate` - Generate the component YAML resource
Expand Down
14 changes: 9 additions & 5 deletions build/make/k8s-component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ HELM_POST_GENERATE_TARGETS ?=
HELM_PRE_APPLY_TARGETS ?=
COMPONENT_PRE_APPLY_TARGETS ?=

# This can be used by components with own images to build and push to the dev registry.
# These components should override this variable with `image-import`.
IMAGE_IMPORT_TARGET?=

##@ K8s - Helm general
.PHONY: helm-init-chart
helm-init-chart: ${BINARY_HELM} ## Creates a Chart.yaml-template with zero values
Expand Down Expand Up @@ -69,7 +73,7 @@ helm-update-dependencies: ${BINARY_HELM} ## Update Helm chart dependencies
##@ K8s - Helm dev targets

.PHONY: helm-apply
helm-apply: ${BINARY_HELM} check-k8s-namespace-env-var image-import helm-generate ${HELM_PRE_APPLY_TARGETS} ## Generates and installs the Helm chart.
helm-apply: ${BINARY_HELM} check-k8s-namespace-env-var ${IMAGE_IMPORT_TARGET} helm-generate ${HELM_PRE_APPLY_TARGETS} ## Generates and installs the Helm chart.
@echo "Apply generated helm chart"
@${BINARY_HELM} upgrade -i ${ARTIFACT_ID} ${HELM_TARGET_DIR} ${BINARY_HELM_ADDITIONAL_UPGR_ARGS} --namespace ${NAMESPACE}

Expand All @@ -82,7 +86,7 @@ helm-delete: ${BINARY_HELM} check-k8s-namespace-env-var ## Uninstalls the curren
helm-reinstall: helm-delete helm-apply ## Uninstalls the current helm chart and reinstalls it.

.PHONY: helm-chart-import
helm-chart-import: check-all-vars check-k8s-artifact-id helm-generate helm-package-release image-import ## Imports the currently available chart into the cluster-local registry.
helm-chart-import: ${CHECK_VAR_TARGETS} helm-generate helm-package ${IMAGE_IMPORT_TARGET} ## Imports the currently available chart into the cluster-local registry.
@if [[ ${STAGE} == "development" ]]; then \
echo "Import ${HELM_DEV_RELEASE_TGZ} into K8s cluster ${K3CES_REGISTRY_URL_PREFIX}..."; \
${BINARY_HELM} push ${HELM_DEV_RELEASE_TGZ} oci://${K3CES_REGISTRY_URL_PREFIX}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
Expand All @@ -98,8 +102,8 @@ helm-chart-import: check-all-vars check-k8s-artifact-id helm-generate helm-packa
helm-generate-release: update-urls ## Generates the final helm chart with release URLs.


.PHONY: helm-package-release
helm-package-release: helm-delete-existing-tgz ${HELM_RELEASE_TGZ} ## Generates and packages the helm chart with release URLs.
.PHONY: helm-package
helm-package: helm-delete-existing-tgz ${HELM_RELEASE_TGZ} ## Generates and packages the helm chart with release URLs.

${HELM_RELEASE_TGZ}: ${BINARY_HELM} ${HELM_TARGET_DIR}/Chart.yaml ${HELM_POST_GENERATE_TARGETS} ## Generates and packages the helm chart with release URLs.
@echo "Package generated helm chart"
Expand Down Expand Up @@ -133,7 +137,7 @@ ${K8S_RESOURCE_COMPONENT_CR_TEMPLATE_YAML}: ${K8S_RESOURCE_TEMP_FOLDER}
fi

.PHONY: component-apply
component-apply: check-k8s-namespace-env-var ${COMPONENT_PRE_APPLY_TARGETS} image-import helm-generate helm-chart-import component-generate ## Applies the component yaml resource to the actual defined context.
component-apply: check-k8s-namespace-env-var ${COMPONENT_PRE_APPLY_TARGETS} ${IMAGE_IMPORT_TARGET} helm-generate helm-chart-import component-generate ## Applies the component yaml resource to the actual defined context.
@kubectl apply -f "${K8S_RESOURCE_COMPONENT}" --namespace="${NAMESPACE}"
@echo "Done."

Expand Down
19 changes: 15 additions & 4 deletions build/make/k8s-crd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ HELM_CRD_DEV_RELEASE_TGZ = ${HELM_CRD_TARGET_DIR}/${ARTIFACT_CRD_ID}-${DEV_CRD_V
K8S_RESOURCE_CRD_COMPONENT ?= "${K8S_RESOURCE_TEMP_FOLDER}/component-${ARTIFACT_CRD_ID}-${VERSION}.yaml"
K8S_RESOURCE_COMPONENT_CR_TEMPLATE_YAML ?= $(BUILD_DIR)/make/k8s-component.tpl
# CRD_POST_MANIFEST_TARGETS can be used to post-process CRD YAMLs after their creation.
CRD_POST_MANIFEST_TARGETS ?=
CRD_POST_MANIFEST_TARGETS ?= crd-add-labels

# This can be used by external components to prevent generate and copy controller manifests by overriding with an empty value.
CRD_HELM_MANIFEST_TARGET?=manifests

##@ K8s - CRD targets

Expand All @@ -18,10 +21,18 @@ manifests: ${CONTROLLER_GEN} manifests-run ${CRD_POST_MANIFEST_TARGETS} ## Gener
.PHONY: manifests-run
manifests-run:
@echo "Generate manifests..."
@$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=k8s/helm-crd/templates
@$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=${HELM_CRD_SOURCE_DIR}/templates

.PHONY: crd-add-labels
crd-add-labels: $(BINARY_YQ)
@echo "Adding labels to CRD..."
@for file in ${HELM_CRD_SOURCE_DIR}/templates/*.yaml ; do \
$(BINARY_YQ) -i e ".metadata.labels.app = \"ces\"" $${file} ;\
$(BINARY_YQ) -i e ".metadata.labels.\"app.kubernetes.io/name\" = \"${ARTIFACT_ID}\"" $${file} ;\
done

.PHONY: crd-helm-generate ## Generates the Helm CRD chart
crd-helm-generate: manifests validate-crd-chart ${HELM_CRD_TARGET_DIR}/Chart.yaml ${K8S_POST_CRD_HELM_GENERATE_TARGETS}
crd-helm-generate: ${CRD_HELM_MANIFEST_TARGET} validate-crd-chart ${HELM_CRD_TARGET_DIR}/Chart.yaml ${K8S_POST_CRD_HELM_GENERATE_TARGETS}

# this is phony because of it is easier this way than the makefile-single-run way
.PHONY: ${HELM_CRD_TARGET_DIR}/Chart.yaml
Expand Down Expand Up @@ -70,7 +81,7 @@ ${HELM_CRD_RELEASE_TGZ}: ${BINARY_HELM} crd-helm-generate ## Generates and packa
@${BINARY_HELM} package ${HELM_CRD_TARGET_DIR} -d ${HELM_CRD_TARGET_DIR} ${BINARY_HELM_ADDITIONAL_PACK_ARGS}

.PHONY: crd-helm-chart-import
crd-helm-chart-import: check-all-vars check-k8s-artifact-id crd-helm-generate crd-helm-package ## Imports the currently available Helm CRD chart into the cluster-local registry.
crd-helm-chart-import: ${CHECK_VAR_TARGETS} check-k8s-artifact-id crd-helm-generate crd-helm-package ## Imports the currently available Helm CRD chart into the cluster-local registry.
@if [[ ${STAGE} == "development" ]]; then \
echo "Import ${HELM_CRD_DEV_RELEASE_TGZ} into K8s cluster ${K3CES_REGISTRY_URL_PREFIX}..."; \
${BINARY_HELM} push ${HELM_CRD_DEV_RELEASE_TGZ} oci://${K3CES_REGISTRY_URL_PREFIX}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
Expand Down
21 changes: 16 additions & 5 deletions build/make/k8s.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,26 @@ K3S_LOCAL_REGISTRY_PORT?=30099
K3CES_REGISTRY_URL_PREFIX="${K3S_CLUSTER_FQDN}:${K3S_LOCAL_REGISTRY_PORT}"
## Image URL to use all building/pushing image targets
IMAGE_DEV?=${K3CES_REGISTRY_URL_PREFIX}/${ARTIFACT_ID}
IMAGE_DEV_VERSION=${IMAGE_DEV}:${VERSION}

# Variables for the temporary yaml files. These are used as template to generate a development resource containing
# the current namespace and the dev image.
K8S_RESOURCE_TEMP_FOLDER ?= $(TARGET_DIR)/k8s

# This can be used by components with own images to check if all image env var are set.
# These components should override this variable with `check-all-vars`.
CHECK_VAR_TARGETS?=check-all-vars-without-image

##@ K8s - Variables

.PHONY: check-all-vars
check-all-vars: check-k8s-image-env-var check-k8s-artifact-id check-etc-hosts check-insecure-cluster-registry check-k8s-namespace-env-var ## Conduct a sanity check against selected build artefacts or local environment
check-all-vars: check-all-vars-without-image check-all-image-vars ## Conduct a sanity check against selected build artefacts or local environment

.PHONY: check-all-image-vars
check-all-image-vars: check-k8s-image-env-var check-k8s-image-dev-var check-etc-hosts check-insecure-cluster-registry

.PHONY: check-all-vars-without-image
check-all-vars-without-image: check-k8s-artifact-id check-k8s-namespace-env-var

.PHONY: check-k8s-namespace-env-var
check-k8s-namespace-env-var:
Expand Down Expand Up @@ -76,8 +87,8 @@ docker-build: check-k8s-image-env-var ## Builds the docker image of the K8s app.

.PHONY: docker-dev-tag
docker-dev-tag: check-k8s-image-dev-var docker-build ## Tags a Docker image for local K3ces deployment.
@echo "Tagging image with dev tag $(IMAGE_DEV)..."
@DOCKER_BUILDKIT=1 docker tag ${IMAGE} $(IMAGE_DEV)
@echo "Tagging image with dev tag $(IMAGE_DEV_VERSION)..."
@DOCKER_BUILDKIT=1 docker tag ${IMAGE} $(IMAGE_DEV_VERSION)

.PHONY: check-k8s-image-dev-var
check-k8s-image-dev-var:
Expand All @@ -88,8 +99,8 @@ endif

.PHONY: image-import
image-import: check-all-vars check-k8s-artifact-id docker-dev-tag ## Imports the currently available image into the cluster-local registry.
@echo "Import $(IMAGE_DEV) into K8s cluster ${K3S_CLUSTER_FQDN}..."
@docker push $(IMAGE_DEV)
@echo "Import $(IMAGE_DEV_VERSION) into K8s cluster ${K3S_CLUSTER_FQDN}..."
@docker push $(IMAGE_DEV_VERSION)
@echo "Done."

## Functions
Expand Down

0 comments on commit 1053247

Please sign in to comment.