Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s - Add annotation support for k8s containers #2814

Merged
merged 29 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
584b5c2
K8s - Add annotation support for k8s containers
armandomiani Nov 15, 2024
bcfa58a
Merge branch 'master' into miani-k8s-tagging-20241114
armandomiani Nov 15, 2024
9544a7a
Merge branch 'master' into miani-k8s-tagging-20241114
armandomiani Dec 19, 2024
5ed0f71
K8s - Add annotations to containers
armandomiani Dec 19, 2024
88cef96
feat: add crane setup
armandomiani Dec 19, 2024
b6c5faf
feat: add crane setup
armandomiani Dec 19, 2024
9d39156
feat: add crane setup
armandomiani Dec 19, 2024
ea23cf2
feat: add crane setup
armandomiani Dec 19, 2024
0fe204d
feat: add crane setup
armandomiani Dec 19, 2024
24738a1
feat: add crane setup
armandomiani Dec 19, 2024
3b39f24
feat: add crane setup
armandomiani Dec 19, 2024
bf8eb5d
Merge branch 'master' into miani-k8s-tagging-20241114
armandomiani Jan 7, 2025
6019ec0
fix: fix crane download
armandomiani Jan 7, 2025
877f42f
Merge branch 'master' into miani-k8s-tagging-20241114
armandomiani Jan 7, 2025
3d3d9d2
Merge branch 'miani-k8s-tagging-20241114' of github.com:GoogleCloudPl…
armandomiani Jan 7, 2025
ba23868
fix: fix builder name setup
armandomiani Jan 7, 2025
9fc0c10
fix: fix builder name setup
armandomiani Jan 7, 2025
2df355d
fix: fix builder name setup
armandomiani Jan 8, 2025
cd21f5c
fix: crane
armandomiani Jan 8, 2025
3fab772
fix: tester and deployer builders
armandomiani Jan 8, 2025
2cfc895
fix: tester and deployer builders
armandomiani Jan 8, 2025
18b3aba
chore: convert spaces to tabs
armandomiani Jan 9, 2025
c227768
chore: convert spaces to tabs
armandomiani Jan 9, 2025
1b7aa28
chore: convert spaces to tabs
armandomiani Jan 9, 2025
81e97a0
fix: makefile spaces indent
armandomiani Jan 9, 2025
6401547
fix: makefile spaces indent
armandomiani Jan 9, 2025
074759a
fix: setup crane
armandomiani Jan 9, 2025
0529df5
fix: setup crane
armandomiani Jan 9, 2025
e1f3973
fix: setup crane
armandomiani Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions k8s/app_v2.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ app/uninstall: .build/var/APP_DEPLOYER_IMAGE \
app/verify: app/publish \
.build/var/APP_DEPLOYER_IMAGE \
.build/var/MARKETPLACE_TOOLS_TAG \
.build/setup_crane \
armandomiani marked this conversation as resolved.
Show resolved Hide resolved
| .build/app/dev
$(call print_target)
.build/app/dev verify \
Expand Down
98 changes: 66 additions & 32 deletions k8s/c2d_deployer.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,35 @@ $(info ---- RELEASE = $(RELEASE))
.build/$(CHART_NAME): | .build
mkdir -p "$@"


app/build:: .build/$(CHART_NAME)/VERSION \
app/build:: .build/setup_crane \
.build/$(CHART_NAME)/VERSION \
.build/$(CHART_NAME)/$(CHART_NAME) \
.build/$(CHART_NAME)/images \
.build/$(CHART_NAME)/deployer


.build/$(CHART_NAME)/deployer: deployer/* \
.build/setup_crane:
@if ! command -v crane &>/dev/null; then \
set -x; \
VERSION=v0.20.2; \
OS=Linux; \
ARCH=x86_64; \
echo "Downloading crane version $$VERSION..."; \
curl -L -o go-containerregistry.tar.gz "https://github.com/google/go-containerregistry/releases/download/$$VERSION/go-containerregistry_$${OS}_$${ARCH}.tar.gz" \
&& tar -zxvf go-containerregistry.tar.gz crane \
&& mv crane /usr/local/bin/crane \
&& chmod 755 /usr/local/bin/crane \
&& chmod +x /usr/local/bin/crane \
&& rm go-containerregistry.tar.gz \
&& echo "crane successfully installed"; \
else \
echo "crane is already installed"; \
fi; \
crane version


.build/$(CHART_NAME)/deployer: .build/setup_crane \
deployer/* \
chart/$(CHART_NAME)/* \
chart/$(CHART_NAME)/templates/* \
schema.yaml \
Expand All @@ -67,68 +88,81 @@ app/build:: .build/$(CHART_NAME)/VERSION \
.build/var/RELEASE \
| .build/$(CHART_NAME)
$(call print_target,$@)
docker build \
--build-arg REGISTRY="$(REGISTRY)/$(APP_ID)" \
--build-arg TAG="$(RELEASE)" \
--build-arg CHART_NAME="$(CHART_NAME)" \
--build-arg MARKETPLACE_TOOLS_TAG="$(MARKETPLACE_TOOLS_TAG)" \
--tag "$(APP_DEPLOYER_IMAGE)" \
-f deployer/Dockerfile \
.
docker tag "$(APP_DEPLOYER_IMAGE)" "$(APP_DEPLOYER_IMAGE_TRACK_TAG)"
docker push "$(APP_DEPLOYER_IMAGE)"
docker push "$(APP_DEPLOYER_IMAGE_TRACK_TAG)"

DEPLOYER_BUILDER="deployer-builder-$$(openssl rand -base64 12 | tr -dc 'a-z0-9' | head -c 8)"; \
docker buildx create --name "$$DEPLOYER_BUILDER" --use \
&& docker buildx inspect "$$DEPLOYER_BUILDER" --bootstrap \
&& docker buildx build \
--push \
--annotation="index,manifest:cloudmarketplace.googleapis.com/service=$(SERVICE_NAME)" \
--build-arg REGISTRY="$(REGISTRY)/$(APP_ID)" \
--build-arg TAG="$(RELEASE)" \
--build-arg CHART_NAME="$(CHART_NAME)" \
--build-arg MARKETPLACE_TOOLS_TAG="$(MARKETPLACE_TOOLS_TAG)" \
--tag "$(APP_DEPLOYER_IMAGE)" \
--tag "$(APP_DEPLOYER_IMAGE_TRACK_TAG)" \
-f deployer/Dockerfile \
. \
&& docker buildx rm "$$DEPLOYER_BUILDER"
@touch "$@"


.build/$(CHART_NAME)/$(CHART_NAME): .build/var/REGISTRY \
.build/$(CHART_NAME)/$(CHART_NAME): .build/setup_crane \
.build/var/REGISTRY \
.build/var/TRACK \
.build/var/RELEASE \
| .build/$(CHART_NAME)
$(call print_target,$@)
docker pull $(image-$(CHART_NAME))
docker tag $(image-$(CHART_NAME)) "$(REGISTRY)/$(APP_ID):$(TRACK)"
docker tag $(image-$(CHART_NAME)) "$(REGISTRY)/$(APP_ID):$(RELEASE)"
docker push "$(REGISTRY)/$(APP_ID):$(TRACK)"
docker push "$(REGISTRY)/$(APP_ID):$(RELEASE)"

crane copy "$(image-$(CHART_NAME))" "$(REGISTRY)/$(APP_ID):$(TRACK)"
crane copy "$(image-$(CHART_NAME))" "$(REGISTRY)/$(APP_ID):$(RELEASE)"
@touch "$@"


# map every element of ADDITIONAL_IMAGES list
# from [image-name] to .build/$(CHART_NAME)/[image-name] format
IMAGE_TARGETS_LIST = $(patsubst %,.build/$(CHART_NAME)/%,$(ADDITIONAL_IMAGES))
.build/$(CHART_NAME)/images: $(IMAGE_TARGETS_LIST)
.build/$(CHART_NAME)/images: .build/setup_crane \
$(IMAGE_TARGETS_LIST)

# extract image name from rule with .build/$(CHART_NAME)/%
# and use % match as $* in recipe
$(IMAGE_TARGETS_LIST): .build/$(CHART_NAME)/%: .build/var/REGISTRY \
$(IMAGE_TARGETS_LIST): .build/$(CHART_NAME)/%: .build/setup_crane \
.build/var/REGISTRY \
.build/var/TRACK \
.build/var/RELEASE \
| .build/$(CHART_NAME)
$(call print_target,$*)
docker pull $(image-$*)
docker tag $(image-$*) "$(REGISTRY)/$(APP_ID)/$*:$(TRACK)"
docker tag $(image-$*) "$(REGISTRY)/$(APP_ID)/$*:$(RELEASE)"
docker push "$(REGISTRY)/$(APP_ID)/$*:$(TRACK)"
docker push "$(REGISTRY)/$(APP_ID)/$*:$(RELEASE)"

crane copy "$(image-$*)" "$(REGISTRY)/$(APP_ID)/$*:$(TRACK)"
crane copy "$(image-$*)" "$(REGISTRY)/$(APP_ID)/$*:$(RELEASE)"
@touch "$@"


.build/$(CHART_NAME)/tester: .build/var/APP_TESTER_IMAGE \
.build/$(CHART_NAME)/tester: .build/setup_crane \
.build/var/APP_TESTER_IMAGE \
$(shell find apptest -type f) \
| .build/$(CHART_NAME)
$(call print_target,$@)
cd apptest/tester \
&& docker build --tag "$(APP_TESTER_IMAGE)" .
docker push "$(APP_TESTER_IMAGE)"

TESTER_BUILDER="tester-builder-$$(openssl rand -base64 12 | tr -dc 'a-z0-9' | head -c 8)"; \
docker buildx create --name "$$TESTER_BUILDER" --use \
&& docker buildx inspect "$$TESTER_BUILDER" --bootstrap \
&& cd apptest/tester \
&& docker buildx build \
--push \
--annotation="index,manifest:cloudmarketplace.googleapis.com/service=$(SERVICE_NAME)" \
--tag "$(APP_TESTER_IMAGE)" . \
&& docker buildx rm "$$TESTER_BUILDER"
@touch "$@"


########### Main targets ###########


.PHONY: .build/$(CHART_NAME)/VERSION
.build/$(CHART_NAME)/VERSION:
.build/$(CHART_NAME)/VERSION: .build/setup_crane \
| .build/$(CHART_NAME)
$(call print_target,$@)
@echo "$(C2D_CONTAINER_RELEASE)" | grep -qE "^$(TRACK)\.[0-9]+(\.[0-9]+)?$$" || \
( echo "C2D_RELEASE doesn't start with TRACK or doesn't match TRACK exactly"; exit 1 )
Expand Down
1 change: 1 addition & 0 deletions k8s/wordpress/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CHART_NAME := wordpress
APP_ID ?= $(CHART_NAME)
VERIFY_WAIT_TIMEOUT = 1800

SERVICE_NAME := services/d60f6935-b4e7-46b3-8f96-eece88c7cd42.cloudpartnerservices.goog
TRACK ?= 6.6

METRICS_EXPORTER_TAG ?= v0.5.1
Expand Down
2 changes: 1 addition & 1 deletion k8s/wordpress/apptest/tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gcr.io/cloud-marketplace-tools/testrunner:0.1.5
FROM gcr.io/cloud-marketplace-tools/testrunner:0.1.8

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
Expand Down
Loading