Skip to content

Commit 8284140

Browse files
committed
Migrate Skaffold presubmits to new Kokoro instance
1 parent e181e60 commit 8284140

File tree

2 files changed

+63
-26
lines changed

2 files changed

+63
-26
lines changed

Makefile

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ GCP_PROJECT ?= k8s-skaffold
3434
GKE_CLUSTER_NAME ?= integration-tests
3535
GKE_ZONE ?= us-central1-a
3636

37+
# Set registry/auth/cluster location based on GCP_PROJECT
38+
ifeq ($(GCP_PROJECT),skaffold-ci-cd)
39+
# Presubmit environment: skaffold-ci-cd project with Artifact Registry
40+
IMAGE_REPO_BASE := $(AR_REGION)-docker.pkg.dev/$(GCP_PROJECT)/skaffold-images
41+
GCLOUD_AUTH_CONFIG := $(AR_REGION)-docker.pkg.dev
42+
GKE_LOCATION_FLAG := --region $(GKE_REGION)
43+
$(info Using Artifact Registry config for project: $(GCP_PROJECT))
44+
else
45+
# k8s-skaffold project with GCR
46+
IMAGE_REPO_BASE := gcr.io/$(GCP_PROJECT)
47+
GCLOUD_AUTH_CONFIG := gcr.io
48+
GKE_LOCATION_FLAG := --zone $(GKE_ZONE)
49+
$(info Using GCR config for project: $(GCP_PROJECT))
50+
endif
51+
3752
SUPPORTED_PLATFORMS = linux-amd64 darwin-amd64 windows-amd64.exe linux-arm64 darwin-arm64
3853
BUILD_PACKAGE = $(REPOPATH)/v2/cmd/skaffold
3954

@@ -142,9 +157,16 @@ integration-tests:
142157
ifeq ($(GCP_ONLY),true)
143158
gcloud container clusters get-credentials \
144159
$(GKE_CLUSTER_NAME) \
145-
--zone $(GKE_ZONE) \
160+
$(GKE_LOCATION_FLAG) \
146161
--project $(GCP_PROJECT)
147-
gcloud auth configure-docker us-central1-docker.pkg.dev
162+
163+
# Conditional Docker authentication: ONLY when GCR is used
164+
ifneq ($(GCP_PROJECT),skaffold-ci-cd)
165+
@echo "Configuring Docker for GCR: $(GCLOUD_AUTH_CONFIG)"
166+
gcloud auth configure-docker $(GCLOUD_AUTH_CONFIG) -q
167+
else
168+
@echo "Docker auth is handled in the build script for skaffold-ci-cd"
169+
endif
148170
endif
149171
@ GCP_ONLY=$(GCP_ONLY) GKE_CLUSTER_NAME=$(GKE_CLUSTER_NAME) ./hack/gotest.sh -v $(REPOPATH)/v2/integration -timeout 50m $(INTEGRATION_TEST_ARGS)
150172

@@ -157,17 +179,17 @@ release: $(BUILD_DIR)/VERSION
157179
--build-arg VERSION=$(VERSION) \
158180
-f deploy/skaffold/Dockerfile \
159181
--target release \
160-
-t gcr.io/$(GCP_PROJECT)/skaffold:$(VERSION) \
161-
-t gcr.io/$(GCP_PROJECT)/skaffold:latest \
182+
-t $(IMAGE_REPO_BASE)/skaffold:$(VERSION) \
183+
-t $(IMAGE_REPO_BASE)/skaffold:latest \
162184
.
163185

164186
.PHONY: release-build
165187
release-build:
166188
docker build \
167189
-f deploy/skaffold/Dockerfile \
168190
--target release \
169-
-t gcr.io/$(GCP_PROJECT)/skaffold:edge \
170-
-t gcr.io/$(GCP_PROJECT)/skaffold:$(COMMIT) \
191+
-t $(IMAGE_REPO_BASE)/skaffold:edge \
192+
-t $(IMAGE_REPO_BASE)/skaffold:$(COMMIT) \
171193
.
172194

173195
.PHONY: release-lts
@@ -176,53 +198,58 @@ release-lts: $(BUILD_DIR)/VERSION
176198
--build-arg VERSION=$(VERSION) \
177199
-f deploy/skaffold/Dockerfile.lts \
178200
--target release \
179-
-t gcr.io/$(GCP_PROJECT)/skaffold:lts \
180-
-t gcr.io/$(GCP_PROJECT)/skaffold:$(VERSION)-lts \
181-
-t gcr.io/$(GCP_PROJECT)/skaffold:$(SCANNING_MARKER)-lts \
201+
-t $(IMAGE_REPO_BASE)/skaffold:lts \
202+
-t $(IMAGE_REPO_BASE)/skaffold:$(VERSION)-lts \
203+
-t $(IMAGE_REPO_BASE)/skaffold:$(SCANNING_MARKER)-lts \
182204
.
183205

184206
.PHONY: release-lts-build
185207
release-lts-build:
186208
docker build \
187209
-f deploy/skaffold/Dockerfile.lts \
188210
--target release \
189-
-t gcr.io/$(GCP_PROJECT)/skaffold:edge-lts \
190-
-t gcr.io/$(GCP_PROJECT)/skaffold:$(COMMIT)-lts \
211+
-t $(IMAGE_REPO_BASE)/skaffold:edge-lts \
212+
-t $(IMAGE_REPO_BASE)/skaffold:$(COMMIT)-lts \
191213
.
192214

193215
.PHONY: clean
194216
clean:
195217
rm -rf $(BUILD_DIR) hack/bin $(EMBEDDED_FILES_CHECK) fs/assets/schemas_generated/
196218

219+
# Runs a script to calculate a hash/digest of the build dependencies. Store it
220+
# in DEPS_DIGEST. Then push the dependency image to GCR/AR.
197221
.PHONY: build_deps
198222
build_deps:
199223
$(eval DEPS_DIGEST := $(shell ./hack/skaffold-deps-sha1.sh))
200224
docker build \
201225
-f deploy/skaffold/Dockerfile.deps \
202-
-t gcr.io/$(GCP_PROJECT)/build_deps:$(DEPS_DIGEST) \
226+
-t $(IMAGE_REPO_BASE)/build_deps:$(DEPS_DIGEST) \
203227
deploy/skaffold
204-
docker push gcr.io/$(GCP_PROJECT)/build_deps:$(DEPS_DIGEST)
228+
docker push $(IMAGE_REPO_BASE)/build_deps:$(DEPS_DIGEST)
229+
205230

206231
skaffold-builder-ci:
207232
docker build \
208-
--cache-from gcr.io/$(GCP_PROJECT)/build_deps \
233+
--cache-from $(IMAGE_REPO_BASE)/build_deps:$(DEPS_DIGEST) \
209234
-f deploy/skaffold/Dockerfile.deps \
210-
-t gcr.io/$(GCP_PROJECT)/build_deps \
235+
-t $(IMAGE_REPO_BASE)/build_deps \
211236
.
212237
time docker build \
213238
-f deploy/skaffold/Dockerfile \
214239
--target builder \
215-
-t gcr.io/$(GCP_PROJECT)/skaffold-builder \
240+
--cache-from $(IMAGE_REPO_BASE)/build_deps \
241+
-t $(IMAGE_REPO_BASE)/skaffold-builder \
216242
.
217243

218244
.PHONY: skaffold-builder
219245
skaffold-builder:
220246
time docker build \
221247
-f deploy/skaffold/Dockerfile \
222248
--target builder \
223-
-t gcr.io/$(GCP_PROJECT)/skaffold-builder \
249+
-t $(IMAGE_REPO_BASE)/skaffold-builder \
224250
.
225251

252+
# Run integration tests within a local kind (Kubernetes IN Docker) cluster.
226253
.PHONY: integration-in-kind
227254
integration-in-kind: skaffold-builder
228255
echo '{}' > /tmp/docker-config
@@ -236,8 +263,12 @@ integration-in-kind: skaffold-builder
236263
-e KUBECONFIG=/tmp/kind-config \
237264
-e INTEGRATION_TEST_ARGS=$(INTEGRATION_TEST_ARGS) \
238265
-e IT_PARTITION=$(IT_PARTITION) \
266+
-e GCP_PROJECT=$(GCP_PROJECT) \
267+
-e AR_REGION=$(AR_REGION) \
268+
-e GKE_REGION=$(GKE_REGION) \
269+
-e GKE_ZONE=$(GKE_ZONE) \
239270
--network kind \
240-
gcr.io/$(GCP_PROJECT)/skaffold-builder \
271+
$(IMAGE_REPO_BASE)/skaffold-builder \
241272
sh -eu -c ' \
242273
if ! kind get clusters | grep -q kind; then \
243274
trap "kind delete cluster" 0 1 2 15; \
@@ -246,7 +277,7 @@ integration-in-kind: skaffold-builder
246277
TERM=dumb kind create cluster --config /tmp/kind-config.yaml; \
247278
fi; \
248279
kind get kubeconfig --internal > /tmp/kind-config; \
249-
make integration \
280+
make GCP_PROJECT=$(GCP_PROJECT) AR_REGION=$(AR_REGION) GKE_REGION=$(GKE_REGION) GKE_ZONE=$(GKE_ZONE) integration \
250281
'
251282

252283
.PHONY: integration-in-k3d
@@ -262,7 +293,11 @@ integration-in-k3d: skaffold-builder
262293
-v $(CURDIR)/hack/maven/settings.xml:/root/.m2/settings.xml \
263294
-e INTEGRATION_TEST_ARGS=$(INTEGRATION_TEST_ARGS) \
264295
-e IT_PARTITION=$(IT_PARTITION) \
265-
gcr.io/$(GCP_PROJECT)/skaffold-builder \
296+
-e GCP_PROJECT=$(GCP_PROJECT) \
297+
-e AR_REGION=$(AR_REGION) \
298+
-e GKE_REGION=$(GKE_REGION) \
299+
-e GKE_ZONE=$(GKE_ZONE) \
300+
$(IMAGE_REPO_BASE)/skaffold-builder \
266301
sh -eu -c ' \
267302
if ! k3d cluster list | grep -q k3s-default; then \
268303
trap "k3d cluster delete" 0 1 2 15; \
@@ -273,30 +308,31 @@ integration-in-k3d: skaffold-builder
273308
--network k3d \
274309
--volume /tmp/k3d:/etc/rancher/k3s; \
275310
fi; \
276-
make integration \
311+
make GCP_PROJECT=$(GCP_PROJECT) AR_REGION=$(AR_REGION) GKE_REGION=$(GKE_REGION) GKE_ZONE=$(GKE_ZONE) integration \
277312
'
278313

279314
.PHONY: integration-in-docker
280315
integration-in-docker: skaffold-builder-ci
281316
docker run --rm \
282317
-v /var/run/docker.sock:/var/run/docker.sock \
283318
-v $(HOME)/.config/gcloud:/root/.config/gcloud \
284-
-v $(GOOGLE_APPLICATION_CREDENTIALS):$(GOOGLE_APPLICATION_CREDENTIALS) \
285319
-v $(CURDIR)/hack/maven/settings.xml:/root/.m2/settings.xml \
286320
-e GCP_ONLY=$(GCP_ONLY) \
287321
-e GCP_PROJECT=$(GCP_PROJECT) \
288322
-e GKE_CLUSTER_NAME=$(GKE_CLUSTER_NAME) \
289323
-e GKE_ZONE=$(GKE_ZONE) \
324+
-e GKE_REGION=$(GKE_REGION) \
290325
-e DOCKER_CONFIG=/root/.docker \
291-
-e GOOGLE_APPLICATION_CREDENTIALS=$(GOOGLE_APPLICATION_CREDENTIALS) \
292326
-e INTEGRATION_TEST_ARGS=$(INTEGRATION_TEST_ARGS) \
293327
-e IT_PARTITION=$(IT_PARTITION) \
294-
gcr.io/$(GCP_PROJECT)/skaffold-builder \
328+
-e DOCKER_NAMESPACE=$(IMAGE_REPO_BASE) \
329+
$(IMAGE_REPO_BASE)/skaffold-builder \
295330
make integration-tests
296331

297332
.PHONY: submit-build-trigger
298333
submit-build-trigger:
299334
gcloud builds submit . \
335+
--project=$(GCP_PROJECT) \
300336
--config=deploy/cloudbuild.yaml \
301337
--substitutions="_RELEASE_BUCKET=$(RELEASE_BUCKET),COMMIT_SHA=$(COMMIT)"
302338

hack/kokoro/presubmit.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
export DOCKER_NAMESPACE=gcr.io/k8s-skaffold
18-
source $KOKORO_GFILE_DIR/common.sh
17+
# Any docker push commands will push images here
18+
export DOCKER_NAMESPACE=us-central1-docker.pkg.dev/skaffold-ci-cd/skaffold-images
1919

20+
# hanges the current directory to where Kokoro has checked out the GitHub repository.
2021
pushd $KOKORO_ARTIFACTS_DIR/github/skaffold >/dev/null
2122
GCP_ONLY=true make integration-in-docker
2223
popd

0 commit comments

Comments
 (0)