-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore: Migrate Skaffold presubmits to new Kokoro instance #9952
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
base: main
Are you sure you want to change the base?
Changes from all commits
e3c20a2
78401b7
87e7bde
1cccda3
577f71e
c4fdbb0
552e556
3a2d5ee
e379cc8
07526b1
fe4e128
2e93229
e15e05e
161cd90
7c97cb8
2658f26
a865acf
2ac9fa6
eaf4d5d
c68c567
0716e37
69d6c19
fd3b6d3
8885a87
cb4a492
6e84083
5e071ee
0588108
30cc8ef
6d5c55a
0072ab6
de4d187
5245dd4
af9928c
180ba73
fe2df70
747db64
786bdb6
8049952
848f6e9
a0192ec
d97335a
c581ee7
43d54c9
555ea6a
9b8f70a
3fbfab6
71c9419
7671708
69a9aa2
79c3905
0638e7c
5b2d2f2
552d25a
5e12734
83958d6
feed083
ffa08c9
a09dae7
ea30ca9
82daa3b
b2658a5
7124682
e505086
c5837cb
2cca858
22a4ccf
f6d92ce
adf43ab
69bfe97
7e33799
4e15239
8bcc664
f47b439
5a04cfc
10f0711
a7a6abd
980e700
76a78f8
3487536
db93f2c
4d82cf3
7655332
7e4817c
9fe82bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,39 @@ GCP_ONLY ?= false | |
| GCP_PROJECT ?= k8s-skaffold | ||
| GKE_CLUSTER_NAME ?= integration-tests | ||
| GKE_ZONE ?= us-central1-a | ||
| GKE_REGION=us-central1 | ||
| AR_REGION ?= us-central1 | ||
|
|
||
| # Set registry/auth/cluster location based on GCP_PROJECT | ||
| ifeq ($(GCP_PROJECT),skaffold-ci-cd) | ||
| # Presubmit environment: skaffold-ci-cd project with Artifact Registry | ||
| IMAGE_REPO_BASE := $(AR_REGION)-docker.pkg.dev/$(GCP_PROJECT) | ||
|
|
||
| # Define full paths including the 4th segment (Image Name) for AR | ||
| SKAFFOLD_IMAGE := $(IMAGE_REPO_BASE)/skaffold/skaffold | ||
| # Artifact registry does not allow _ in the repo name (with GCR this was | ||
| # build_deps). | ||
| SKAFFOLD_DEPS_IMAGE := $(IMAGE_REPO_BASE)/builddeps/skaffold-deps | ||
| SKAFFOLD_BUILDER_IMAGE := $(IMAGE_REPO_BASE)/skaffold-builder/skaffold-builder | ||
|
|
||
| # For Integration Tests: Export a 4-segment default repo | ||
| export SKAFFOLD_DEFAULT_REPO := $(IMAGE_REPO_BASE)/testing | ||
| GCLOUD_AUTH_CONFIG := $(AR_REGION)-docker.pkg.dev | ||
| GKE_LOCATION_FLAG := --region $(GKE_REGION) | ||
| $(info Using Artifact Registry config for project: $(GCP_PROJECT)) | ||
| else | ||
| # k8s-skaffold project with GCR | ||
| IMAGE_REPO_BASE := gcr.io/$(GCP_PROJECT) | ||
|
|
||
| # Define full paths using the 3 segments GCR expects | ||
| SKAFFOLD_IMAGE := $(IMAGE_REPO_BASE)/skaffold | ||
| SKAFFOLD_DEPS_IMAGE := $(IMAGE_REPO_BASE)/build_deps | ||
| SKAFFOLD_BUILDER_IMAGE := $(IMAGE_REPO_BASE)/skaffold-builder | ||
|
|
||
| GCLOUD_AUTH_CONFIG := gcr.io | ||
| GKE_LOCATION_FLAG := --zone $(GKE_ZONE) | ||
| $(info Using GCR config for project: $(GCP_PROJECT)) | ||
| endif | ||
|
|
||
| SUPPORTED_PLATFORMS = linux-amd64 darwin-amd64 windows-amd64.exe linux-arm64 darwin-arm64 | ||
| BUILD_PACKAGE = $(REPOPATH)/v2/cmd/skaffold | ||
|
|
@@ -142,9 +175,16 @@ integration-tests: | |
| ifeq ($(GCP_ONLY),true) | ||
| gcloud container clusters get-credentials \ | ||
| $(GKE_CLUSTER_NAME) \ | ||
| --zone $(GKE_ZONE) \ | ||
| $(GKE_LOCATION_FLAG) \ | ||
| --project $(GCP_PROJECT) | ||
| gcloud auth configure-docker us-central1-docker.pkg.dev | ||
|
|
||
| # Conditional Docker authentication: ONLY when GCR is used | ||
| ifneq ($(GCP_PROJECT),skaffold-ci-cd) | ||
| @echo "Configuring Docker for GCR: $(GCLOUD_AUTH_CONFIG)" | ||
| gcloud auth configure-docker $(GCLOUD_AUTH_CONFIG) -q | ||
| else | ||
| @echo "Docker auth is handled in the build script for skaffold-ci-cd" | ||
| endif | ||
| endif | ||
| @ GCP_ONLY=$(GCP_ONLY) GKE_CLUSTER_NAME=$(GKE_CLUSTER_NAME) ./hack/gotest.sh -v $(REPOPATH)/v2/integration -timeout 50m $(INTEGRATION_TEST_ARGS) | ||
|
|
||
|
|
@@ -155,74 +195,102 @@ integration: install integration-tests | |
| release: $(BUILD_DIR)/VERSION | ||
| docker build \ | ||
| --build-arg VERSION=$(VERSION) \ | ||
| --build-arg BASE_IMAGE=$(SKAFFOLD_DEPS_IMAGE):latest \ | ||
| -f deploy/skaffold/Dockerfile \ | ||
| --target release \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:$(VERSION) \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:latest \ | ||
| -t $(SKAFFOLD_IMAGE):$(VERSION) \ | ||
| -t $(SKAFFOLD_IMAGE):latest \ | ||
| . | ||
|
|
||
| .PHONY: release-build | ||
| release-build: | ||
| docker build \ | ||
| -f deploy/skaffold/Dockerfile \ | ||
| --build-arg BASE_IMAGE=$(SKAFFOLD_DEPS_IMAGE):latest \ | ||
| --target release \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:edge \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:$(COMMIT) \ | ||
| -t $(SKAFFOLD_IMAGE):edge \ | ||
| -t $(SKAFFOLD_IMAGE):$(COMMIT) \ | ||
| . | ||
|
|
||
| .PHONY: release-lts | ||
| release-lts: $(BUILD_DIR)/VERSION | ||
| docker build \ | ||
| --build-arg VERSION=$(VERSION) \ | ||
| --build-arg BASE_IMAGE=$(SKAFFOLD_DEPS_IMAGE):latest \ | ||
| -f deploy/skaffold/Dockerfile.lts \ | ||
| --target release \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:lts \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:$(VERSION)-lts \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:$(SCANNING_MARKER)-lts \ | ||
| -t $(SKAFFOLD_IMAGE):lts \ | ||
| -t $(SKAFFOLD_IMAGE):$(VERSION)-lts \ | ||
| -t $(SKAFFOLD_IMAGE):$(SCANNING_MARKER)-lts \ | ||
| . | ||
|
|
||
| .PHONY: release-lts-build | ||
| release-lts-build: | ||
| docker build \ | ||
| -f deploy/skaffold/Dockerfile.lts \ | ||
| --build-arg BASE_IMAGE=$(SKAFFOLD_DEPS_IMAGE):latest \ | ||
| --target release \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:edge-lts \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold:$(COMMIT)-lts \ | ||
| -t $(SKAFFOLD_IMAGE):edge-lts \ | ||
| -t $(SKAFFOLD_IMAGE):$(COMMIT)-lts \ | ||
| . | ||
|
|
||
| .PHONY: clean | ||
| clean: | ||
| rm -rf $(BUILD_DIR) hack/bin $(EMBEDDED_FILES_CHECK) fs/assets/schemas_generated/ | ||
|
|
||
| # Runs a script to calculate a hash/digest of the build dependencies. Store it | ||
| # in DEPS_DIGEST. Then push the dependency image to GCR/AR. | ||
| .PHONY: build_deps | ||
| build_deps: | ||
| $(eval DEPS_DIGEST := $(shell ./hack/skaffold-deps-sha1.sh)) | ||
| docker build \ | ||
| -f deploy/skaffold/Dockerfile.deps \ | ||
| -t gcr.io/$(GCP_PROJECT)/build_deps:$(DEPS_DIGEST) \ | ||
| -t $(SKAFFOLD_DEPS_IMAGE):$(DEPS_DIGEST) \ | ||
| -t $(SKAFFOLD_DEPS_IMAGE):latest \ | ||
| deploy/skaffold | ||
| docker push gcr.io/$(GCP_PROJECT)/build_deps:$(DEPS_DIGEST) | ||
|
|
||
| # Prepares the Docker images needed to run integration tests. | ||
| # First part builds the base image containing all build-time dependencies and pushes to AR. | ||
| # Second part builds the actual image used for running the integration tests, | ||
| # using the 'builddeps' image as a base. It build only up to the 'builder' stage | ||
| # in the Dockerfile. | ||
| # | ||
| # The push flag is needed to tell Buildx to build the image and push it directly to AR. | ||
| # AR supports multi-architecture images and manifest lists so this will pass for hybrid tests. | ||
| # Note: --provenance=false and --sbom=false are required because modern Buildx | ||
| # attempts to push attestation manifests that are currently rejected by | ||
| # GCP Artifact Registry with a '400 Bad Request' error. | ||
| # --cache-from $(IMAGE_REPO_BASE)/$(BUILD_DEPS_REPO_NAME) | ||
| skaffold-builder-ci: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| docker build \ | ||
| --cache-from gcr.io/$(GCP_PROJECT)/build_deps \ | ||
| docker system prune -a -f | ||
| docker buildx build \ | ||
| --provenance=false \ | ||
| --sbom=false \ | ||
| --push \ | ||
| -f deploy/skaffold/Dockerfile.deps \ | ||
| -t gcr.io/$(GCP_PROJECT)/build_deps \ | ||
| -t $(SKAFFOLD_DEPS_IMAGE):latest \ | ||
| . | ||
| time docker build \ | ||
|
|
||
| time docker buildx build \ | ||
| --provenance=false \ | ||
| --sbom=false \ | ||
| --push \ | ||
| -f deploy/skaffold/Dockerfile \ | ||
| --target builder \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold-builder \ | ||
| -t $(SKAFFOLD_BUILDER_IMAGE):latest \ | ||
| . | ||
|
|
||
| .PHONY: skaffold-builder | ||
| skaffold-builder: | ||
| time docker build \ | ||
| time docker buildx build \ | ||
| --provenance=false --sbom=false --push \ | ||
| -f deploy/skaffold/Dockerfile \ | ||
| --build-arg BASE_IMAGE=$(SKAFFOLD_DEPS_IMAGE):latest \ | ||
| --target builder \ | ||
| -t gcr.io/$(GCP_PROJECT)/skaffold-builder \ | ||
| -t $(SKAFFOLD_BUILDER_IMAGE):latest \ | ||
| . | ||
|
|
||
| # Run integration tests within a local kind (Kubernetes IN Docker) cluster. | ||
| .PHONY: integration-in-kind | ||
| integration-in-kind: skaffold-builder | ||
| echo '{}' > /tmp/docker-config | ||
|
|
@@ -232,12 +300,11 @@ integration-in-kind: skaffold-builder | |
| -v $(HOME)/.gradle:/root/.gradle \ | ||
| -v $(HOME)/.cache:/root/.cache \ | ||
| -v /tmp/docker-config:/root/.docker/config.json \ | ||
| -v $(CURDIR)/hack/maven/settings.xml:/root/.m2/settings.xml \ | ||
| -e KUBECONFIG=/tmp/kind-config \ | ||
| -e INTEGRATION_TEST_ARGS=$(INTEGRATION_TEST_ARGS) \ | ||
| -e IT_PARTITION=$(IT_PARTITION) \ | ||
| --network kind \ | ||
| gcr.io/$(GCP_PROJECT)/skaffold-builder \ | ||
| $(SKAFFOLD_BUILDER_IMAGE) \ | ||
| sh -eu -c ' \ | ||
| if ! kind get clusters | grep -q kind; then \ | ||
| trap "kind delete cluster" 0 1 2 15; \ | ||
|
|
@@ -262,7 +329,7 @@ integration-in-k3d: skaffold-builder | |
| -v $(CURDIR)/hack/maven/settings.xml:/root/.m2/settings.xml \ | ||
| -e INTEGRATION_TEST_ARGS=$(INTEGRATION_TEST_ARGS) \ | ||
| -e IT_PARTITION=$(IT_PARTITION) \ | ||
| gcr.io/$(GCP_PROJECT)/skaffold-builder \ | ||
| $(SKAFFOLD_BUILDER_IMAGE) \ | ||
| sh -eu -c ' \ | ||
| if ! k3d cluster list | grep -q k3s-default; then \ | ||
| trap "k3d cluster delete" 0 1 2 15; \ | ||
|
|
@@ -276,27 +343,54 @@ integration-in-k3d: skaffold-builder | |
| make integration \ | ||
| ' | ||
|
|
||
| # The `gcloud auth configure-docker` below is needed this starts a separate | ||
| # container (us-central1-docker.pkg.dev/skaffold-ci-cd/skaffold-builder) to run | ||
| # the tests. This inner container doesn't inherit the Docker configuration from | ||
| # the host. | ||
| # On these new Kokoro instances, the standard Docker driver doesn't support the | ||
| # multi-platform manifest lists that Skaffold builds for its hybrid tests. | ||
| .PHONY: integration-in-docker | ||
| integration-in-docker: skaffold-builder-ci | ||
| docker run --privileged --rm mirror.gcr.io/tonistiigi/binfmt --install all | ||
| docker run --rm \ | ||
| -v /var/run/docker.sock:/var/run/docker.sock \ | ||
| -v $(HOME)/.config/gcloud:/root/.config/gcloud \ | ||
| -v $(GOOGLE_APPLICATION_CREDENTIALS):$(GOOGLE_APPLICATION_CREDENTIALS) \ | ||
| -v $(CURDIR)/hack/maven/settings.xml:/root/.m2/settings.xml \ | ||
| -v $(HOME)/.docker:/root/.docker \ | ||
| -e GCP_ONLY=$(GCP_ONLY) \ | ||
| -e GCP_PROJECT=$(GCP_PROJECT) \ | ||
| -e AR_REGION=$(AR_REGION) \ | ||
| -e GKE_CLUSTER_NAME=$(GKE_CLUSTER_NAME) \ | ||
| -e GKE_ZONE=$(GKE_ZONE) \ | ||
| -e DOCKER_CONFIG=/root/.docker \ | ||
| -e GOOGLE_APPLICATION_CREDENTIALS=$(GOOGLE_APPLICATION_CREDENTIALS) \ | ||
| -e DOCKER_BUILDKIT=1 \ | ||
| -e INTEGRATION_TEST_ARGS=$(INTEGRATION_TEST_ARGS) \ | ||
| -e IT_PARTITION=$(IT_PARTITION) \ | ||
| gcr.io/$(GCP_PROJECT)/skaffold-builder \ | ||
| make integration-tests | ||
| -e MAVEN_OPTS \ | ||
| -e GRADLE_USER_HOME \ | ||
| $(SKAFFOLD_BUILDER_IMAGE) \ | ||
| sh -c "gcloud auth configure-docker us-central1-docker.pkg.dev -q && \ | ||
| if [ \"\$${GKE_CLUSTER_NAME}\" = \"presubmit-hybrid\" ]; then \ | ||
| echo 'Using docker-container driver for hybrid tests'; \ | ||
| docker buildx rm skaffold-builder || true; \ | ||
| docker buildx create --use --name skaffold-builder --driver docker-container --driver-opt network=host --platform linux/amd64,linux/arm64 --bootstrap; \ | ||
| BUILDER=skaffold-builder; \ | ||
| else \ | ||
| echo 'Using default driver for standard tests'; \ | ||
| docker buildx use default; \ | ||
| BUILDER=default; \ | ||
| fi && \ | ||
| export BUILDX_BUILDER=\$$BUILDER && \ | ||
| echo 'DEBUG: Current buildx builder:'; docker buildx ls && \ | ||
| echo \"DEBUG: BUILDX_BUILDER variable is set to: \$$BUILDX_BUILDER\" && \ | ||
| echo 'DEBUG: Active gcloud account:'; gcloud auth list && \ | ||
| BUILDX_BUILDER=\$$BUILDER make integration-tests" | ||
|
|
||
|
|
||
|
|
||
| .PHONY: submit-build-trigger | ||
| submit-build-trigger: | ||
| gcloud builds submit . \ | ||
| --project=$(GCP_PROJECT) \ | ||
| --config=deploy/cloudbuild.yaml \ | ||
| --substitutions="_RELEASE_BUCKET=$(RELEASE_BUCKET),COMMIT_SHA=$(COMMIT)" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ build: | |
| gitCommit: {} | ||
| local: | ||
| concurrency: 1 | ||
| useDockerCLI: true | ||
| manifests: | ||
| rawYaml: | ||
| - k8s-* | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new logic for
GCP_PROJECT=skaffold-ci-cdrelies onAR_REGIONandGKE_REGIONvariables. However, these variables are not defined with default values, nor are there any checks to ensure they are set. If they are not provided in the environment, they will be empty, leading to malformed values forIMAGE_REPO_BASEandGKE_LOCATION_FLAG, which can cause silent failures or hard-to-debug issues. It's safer to add checks to ensure these required variables are set.