Skip to content

Commit 8fe8d2f

Browse files
committed
chore(deps): update dependency cloudogu/makefiles to v10.11.0
1 parent a40fac7 commit 8fe8d2f

5 files changed

Lines changed: 109 additions & 23 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ IMAGE_NAME=registry.cloudogu.com/official/java
66
IMAGE_NAME_PRERELEASE=registry.cloudogu.com/prerelease_official/java
77
IMAGE_TAG=$(JAVA_VERSION)-$(CHANGE_COUNTER)
88
# renovate: datasource=github-tags depName=cloudogu/makefiles extractVersion=^v(?<version>.*)$
9-
MAKEFILES_VERSION=10.9.1
9+
MAKEFILES_VERSION=10.11.0
1010

1111
default: build
1212

build/make/bats/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ FROM ${BATS_BASE_IMAGE:-bats/bats}:${BATS_TAG:-1.12.0}
66
# Make bash more findable by scripts and tests
77
RUN apk add make git bash
88
# suppress git "detected dubious ownership" error/warning for repos which are checked out later
9-
RUN git config --global --add safe.directory /workspace
9+
RUN git config --global --add safe.directory /workspace
10+
# Add unprivileged users so Jenkins CI has less problems with the UID mapping inside this container. This avoids
11+
# undesired warnings (like "unknown ID 1002") in BATS assertions, failing assert_output tests
12+
RUN set -x && \
13+
addgroup -S -g 1000 jenkins && \
14+
adduser -S -h /home/jenkins -s /bin/bash -G jenkins -u 1000 jenkins && \
15+
adduser -S -h /home/jenkins -s /bin/bash -G jenkins -u 1001 jenkins1 && \
16+
adduser -S -h /home/jenkins -s /bin/bash -G jenkins -u 1002 jenkins2

build/make/k8s-component.mk

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ endif
99
ifeq (${RUNTIME_ENV}, local)
1010
BINARY_HELM_ADDITIONAL_PUSH_ARGS?=--plain-http
1111
endif
12+
ifeq (${RUNTIME_ENV}, k3d)
13+
BINARY_HELM_ADDITIONAL_PUSH_ARGS?=--plain-http
14+
endif
1215
BINARY_HELM_ADDITIONAL_PACK_ARGS?=
1316
BINARY_HELM_ADDITIONAL_UNINST_ARGS?=
1417
BINARY_HELM_ADDITIONAL_UPGR_ARGS?=
@@ -18,10 +21,15 @@ HELM_SOURCE_DIR ?= k8s/helm
1821
HELM_RELEASE_TGZ=${HELM_TARGET_DIR}/${COMPONENT_ARTIFACT_ID}-${VERSION}.tgz
1922
HELM_DEV_RELEASE_TGZ=${HELM_TARGET_DIR}/${COMPONENT_ARTIFACT_ID}-${COMPONENT_DEV_VERSION}.tgz
2023
HELM_ARTIFACT_NAMESPACE?=k8s
24+
HELM_PUSH_REGISTRY_HOST?=${CES_REGISTRY_HOST}
2125
ifeq (${RUNTIME_ENV}, remote)
2226
HELM_ARTIFACT_NAMESPACE=testing/k8s
2327
endif
28+
ifeq (${RUNTIME_ENV}, k3d)
29+
HELM_PUSH_REGISTRY_HOST=$(IMAGE_PUSH_REGISTRY_HOST)
30+
endif
2431
$(info HELM_ARTIFACT_NAMESPACE=$(HELM_ARTIFACT_NAMESPACE))
32+
$(info HELM_PUSH_REGISTRY_HOST=$(HELM_PUSH_REGISTRY_HOST))
2533

2634
K8S_RESOURCE_COMPONENT ?= "${K8S_RESOURCE_TEMP_FOLDER}/component-${COMPONENT_ARTIFACT_ID}-${VERSION}.yaml"
2735
K8S_RESOURCE_COMPONENT_CR_TEMPLATE_YAML ?= $(BUILD_DIR)/make/k8s-component.tpl
@@ -98,11 +106,11 @@ helm-reinstall: helm-delete helm-apply ## Uninstalls the current helm chart and
98106
.PHONY: helm-chart-import
99107
helm-chart-import: ${CHECK_VAR_TARGETS} helm-generate helm-package ${IMAGE_IMPORT_TARGET} ## Imports the currently available chart into the cluster-local registry.
100108
@if [[ ${STAGE} == "development" ]]; then \
101-
echo "Import ${HELM_DEV_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
102-
${BINARY_HELM} push ${HELM_DEV_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
109+
echo "Import ${HELM_DEV_RELEASE_TGZ} into K8s cluster ${HELM_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
110+
${BINARY_HELM} push ${HELM_DEV_RELEASE_TGZ} oci://${HELM_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
103111
else \
104-
echo "Import ${HELM_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
105-
${BINARY_HELM} push ${HELM_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
112+
echo "Import ${HELM_RELEASE_TGZ} into K8s cluster ${HELM_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
113+
${BINARY_HELM} push ${HELM_RELEASE_TGZ} oci://${HELM_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
106114
fi
107115
@echo "Done."
108116

build/make/k8s-crd.mk

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ ${HELM_CRD_RELEASE_TGZ}: ${BINARY_HELM} crd-helm-generate ## Generates and packa
9090
.PHONY: crd-helm-chart-import
9191
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.
9292
@if [[ ${STAGE} == "development" ]]; then \
93-
echo "Import ${HELM_CRD_DEV_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
94-
${BINARY_HELM} push ${HELM_CRD_DEV_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
93+
echo "Import ${HELM_CRD_DEV_RELEASE_TGZ} into K8s cluster ${IMAGE_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
94+
${BINARY_HELM} push ${HELM_CRD_DEV_RELEASE_TGZ} oci://${IMAGE_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
9595
else \
96-
echo "Import ${HELM_CRD_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
97-
${BINARY_HELM} push ${HELM_CRD_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
96+
echo "Import ${HELM_CRD_RELEASE_TGZ} into K8s cluster ${IMAGE_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
97+
${BINARY_HELM} push ${HELM_CRD_RELEASE_TGZ} oci://${IMAGE_PUSH_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
9898
fi
9999
@echo "Done."
100100

@@ -120,3 +120,32 @@ crd-component-apply: isProduction check-k8s-namespace-env-var crd-helm-chart-imp
120120
crd-component-delete: check-k8s-namespace-env-var crd-component-generate ## Deletes the CRD component YAML resource from the actual defined context.
121121
@kubectl delete -f "${K8S_RESOURCE_CRD_COMPONENT}" --namespace="${NAMESPACE}" --context="${KUBE_CONTEXT_NAME}" || true
122122
@echo "Done."
123+
124+
CLIENT_GEN = $(UTILITY_BIN_PATH)/client-gen
125+
CLIENT_GEN_VERSION?=v0.36.4
126+
127+
.PHONY: client-gen
128+
client-gen: ${CLIENT_GEN} ## Download client-gen locally if necessary.
129+
130+
${CLIENT_GEN}:
131+
$(call go-get-tool,$(CLIENT_GEN),k8s.io/code-generator/cmd/client-gen@${CLIENT_GEN_VERSION})
132+
133+
CLIENT_GEN_OUTPUT_DIR?="./"
134+
CLIENT_GEN_OUTPUT_PKG?="$(shell awk '/^module/ {print $$2}' go.mod)" # Get module path from go.mod
135+
CLIENT_GEN_CLIENTSET_NAME?="client"
136+
CLIENT_GEN_CLIENTSET_INPUT?="$(shell find api/ -mindepth 1 -maxdepth 1 -type d -printf 'api/%P\n' | paste -sd, -)" # Get all packages under version names under api/
137+
CLIENT_GEN_INPUT_BASE?="$(shell pwd)"
138+
139+
.PHONY: generate-client
140+
generate-client: ${CLIENT_GEN} ## Generate client code from API definitions.
141+
@echo "Generating client..."
142+
$(CLIENT_GEN) \
143+
--output-dir ${CLIENT_GEN_OUTPUT_DIR} \
144+
--output-pkg ${CLIENT_GEN_OUTPUT_PKG} \
145+
--clientset-name ${CLIENT_GEN_CLIENTSET_NAME} \
146+
--input ${CLIENT_GEN_CLIENTSET_INPUT} \
147+
--input-base ${CLIENT_GEN_INPUT_BASE}
148+
149+
.PHONY: generate-crd-api
150+
generate-crd-api: generate-deepcopy generate-client manifests
151+
@echo "generated deepcopy, api-client and manifests"

build/make/k8s.mk

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,41 +33,75 @@ BINARY_CRANE_ARCHIVE_STRIP?=0
3333
SHELL = /usr/bin/env bash -o pipefail
3434
.SHELLFLAGS = -ec
3535

36+
ifneq (${KUBECONFIG},)
37+
# Values from the repo-local .env become plain make variables first. Export KUBECONFIG so
38+
# recipe shells and nested kubectl/helm calls use the same kubeconfig file as the make logic.
39+
export KUBECONFIG
40+
endif
41+
3642
# The productive tag of the image
3743
IMAGE ?=
3844

3945
# Set production as default stage. Use "development" as stage in your .env file to generate artifacts
4046
# with development images pointing to CES_REGISTRY_URL_PREFIX.
4147
STAGE?=production
4248

43-
# Set the "local" as runtime-environment, to push images to the container-registry of the local cluster and to apply resources to the local cluster.
44-
# Use "remote" as runtime-environment in your .env file to push images to the container-registry at "registry.cloudogu.com/testing" and to apply resources to the configured kubernetes-context in KUBE_CONTEXT_NAME.
49+
# Set "local" as runtime-environment to use the legacy in-cluster registry of the local cluster.
50+
# Set "k3d" as runtime-environment for local k3d development with local registry push/pull:
51+
# - push from host to ${K3D_PUSH_REGISTRY_HOST}${K3D_PUSH_REGISTRY_NAMESPACE}
52+
# - pull in-cluster via ${K3D_PULL_REGISTRY_HOST}${K3D_PULL_REGISTRY_NAMESPACE}
53+
# Use "remote" as runtime-environment in your .env file to push images to the container-registry at
54+
# "registry.cloudogu.com/testing" and to apply resources to the configured kubernetes-context in KUBE_CONTEXT_NAME.
4555
RUNTIME_ENV?=local
4656
$(info RUNTIME_ENV=$(RUNTIME_ENV))
4757

4858
# The host and port of the local cluster
4959
K3S_CLUSTER_FQDN?=k3ces.localdomain
5060
K3S_LOCAL_REGISTRY_PORT?=30099
51-
52-
# The URL of the container-registry to use. Defaults to the registry of the local-cluster.
53-
# If RUNTIME_ENV is "remote" it is "registry.cloudogu.com/testing", if ENVIRONMENT is "ci" it is "registry.cloudogu.com/ci"
54-
# if run on ci (jenkins) the images must be pushed to a separate namespace in order to free space every night after the build.
61+
K3D_PULL_REGISTRY_HOST?=k3d-registry-proxy.localhost:5000
62+
K3D_PULL_REGISTRY_NAMESPACE?=/local-dev
63+
K3D_PUSH_REGISTRY_HOST?=localhost:5001
64+
K3D_PUSH_REGISTRY_NAMESPACE?=$(K3D_PULL_REGISTRY_NAMESPACE)
65+
66+
# The URL or image-prefix host to use for development images.
67+
# If RUNTIME_ENV is "remote" it is "registry.cloudogu.com/testing", if ENVIRONMENT is "ci" it is "registry.cloudogu.com/ci".
68+
# If run on ci (jenkins) the images must be pushed to a separate namespace in order to free space every night after the build.
5569
CES_REGISTRY_HOST?=${K3S_CLUSTER_FQDN}:${K3S_LOCAL_REGISTRY_PORT}
5670
CES_REGISTRY_NAMESPACE ?=
71+
IMAGE_PUSH_REGISTRY_HOST ?= $(CES_REGISTRY_HOST)
72+
IMAGE_PUSH_REGISTRY_NAMESPACE ?= $(CES_REGISTRY_NAMESPACE)
5773
ifeq (${RUNTIME_ENV}, remote)
5874
CES_REGISTRY_HOST=registry.cloudogu.com
5975
CES_REGISTRY_NAMESPACE=/testing
76+
IMAGE_PUSH_REGISTRY_HOST=$(CES_REGISTRY_HOST)
77+
IMAGE_PUSH_REGISTRY_NAMESPACE=$(CES_REGISTRY_NAMESPACE)
6078
ifeq ($(ENVIRONMENT), ci)
6179
CES_REGISTRY_NAMESPACE=/ci
80+
IMAGE_PUSH_REGISTRY_NAMESPACE=$(CES_REGISTRY_NAMESPACE)
6281
endif
6382
endif
83+
ifeq (${RUNTIME_ENV}, k3d)
84+
CES_REGISTRY_HOST=$(K3D_PULL_REGISTRY_HOST)
85+
CES_REGISTRY_NAMESPACE=$(K3D_PULL_REGISTRY_NAMESPACE)
86+
IMAGE_PUSH_REGISTRY_HOST=$(K3D_PUSH_REGISTRY_HOST)
87+
IMAGE_PUSH_REGISTRY_NAMESPACE=$(K3D_PUSH_REGISTRY_NAMESPACE)
88+
endif
6489
$(info CES_REGISTRY_HOST=$(CES_REGISTRY_HOST))
6590

6691
# The name of the kube-context to use for applying resources.
92+
# If KUBECONFIG is set and KUBE_CONTEXT_NAME is empty, the current context from this kubeconfig is used.
6793
# If KUBE_CONTEXT_NAME is empty and RUNTIME_ENV is "remote" the currently configured kube-context is used.
68-
# If KUBE_CONTEXT_NAME is empty and RUNTIME_ENV is not "remote" the "k3ces.localdomain" is used as kube-context.
94+
# If KUBE_CONTEXT_NAME is empty and RUNTIME_ENV is "k3d" the currently configured kube-context is used.
95+
# Set KUBE_CONTEXT_NAME explicitly if the current kube-context does not point to the desired local k3d cluster.
96+
# If KUBE_CONTEXT_NAME is empty and RUNTIME_ENV is neither "remote" nor "k3d" the "k3ces.localdomain" is used as kube-context.
6997
ifeq (${KUBE_CONTEXT_NAME}, )
70-
ifeq (${RUNTIME_ENV}, remote)
98+
ifneq (${KUBECONFIG}, )
99+
# Resolve the current context from the explicitly configured kubeconfig instead of the
100+
# user's default ~/.kube/config. This keeps repo-local .env settings self-contained.
101+
KUBE_CONTEXT_NAME = $(shell KUBECONFIG="${KUBECONFIG}" kubectl config current-context)
102+
else ifeq (${RUNTIME_ENV}, remote)
103+
KUBE_CONTEXT_NAME = $(shell kubectl config current-context)
104+
else ifeq (${RUNTIME_ENV}, k3d)
71105
KUBE_CONTEXT_NAME = $(shell kubectl config current-context)
72106
else
73107
KUBE_CONTEXT_NAME = k3ces.localdomain
@@ -83,6 +117,8 @@ GIT_HASH := $(shell git rev-parse --short HEAD)
83117
## Image URL to use all building/pushing image targets
84118
IMAGE_DEV?=$(CES_REGISTRY_HOST)$(CES_REGISTRY_NAMESPACE)/$(ARTIFACT_ID)/$(GIT_BRANCH)
85119
IMAGE_DEV_VERSION=$(IMAGE_DEV):$(VERSION)
120+
IMAGE_DEV_PUSH?=$(IMAGE_PUSH_REGISTRY_HOST)$(IMAGE_PUSH_REGISTRY_NAMESPACE)/$(ARTIFACT_ID)/$(GIT_BRANCH)
121+
IMAGE_DEV_PUSH_VERSION=$(IMAGE_DEV_PUSH):$(VERSION)
86122

87123
# Variables for the temporary yaml files. These are used as template to generate a development resource containing
88124
# the current namespace and the dev image.
@@ -174,9 +210,17 @@ ifeq (${IMAGE_DEV},)
174210
endif
175211

176212
.PHONY: image-import
177-
image-import: check-all-vars check-k8s-artifact-id docker-dev-tag ## Imports the currently available image into the configured ces-registry.
178-
@echo "Import $(IMAGE_DEV_VERSION) into K8s cluster ${KUBE_CONTEXT_NAME}..."
179-
@docker push $(IMAGE_DEV_VERSION)
213+
image-import: check-all-vars check-k8s-artifact-id docker-dev-tag ## Imports the currently available image into the configured runtime target.
214+
@if [[ "${RUNTIME_ENV}" == "k3d" ]]; then \
215+
echo "Push $(IMAGE_DEV_VERSION) for k3d registry workflow..."; \
216+
echo "Push target: $(IMAGE_DEV_PUSH_VERSION)"; \
217+
echo "Pull target: $(IMAGE_DEV_VERSION)"; \
218+
DOCKER_BUILDKIT=1 docker tag $(IMAGE_DEV_VERSION) $(IMAGE_DEV_PUSH_VERSION); \
219+
docker push $(IMAGE_DEV_PUSH_VERSION); \
220+
else \
221+
echo "Import $(IMAGE_DEV_VERSION) into K8s cluster ${KUBE_CONTEXT_NAME}..."; \
222+
docker push $(IMAGE_DEV_VERSION); \
223+
fi
180224
@echo "Done."
181225

182226
## Functions
@@ -237,5 +281,3 @@ isProduction:
237281
else \
238282
echo "Command executed in development stage. Continuing."; \
239283
fi
240-
241-

0 commit comments

Comments
 (0)