...

Text file src/k8s.io/kubernetes/test/conformance/image/Makefile

Documentation: k8s.io/kubernetes/test/conformance/image

     1# Copyright 2016 The Kubernetes Authors.
     2#
     3# Licensed under the Apache License, Version 2.0 (the "License");
     4# you may not use this file except in compliance with the License.
     5# You may obtain a copy of the License at
     6#
     7#     http://www.apache.org/licenses/LICENSE-2.0
     8#
     9# Unless required by applicable law or agreed to in writing, software
    10# distributed under the License is distributed on an "AS IS" BASIS,
    11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12# See the License for the specific language governing permissions and
    13# limitations under the License.
    14
    15# Build the conformance image.
    16#
    17# Usage:
    18#   [ARCH=amd64] [REGISTRY="registry.k8s.io"] make (build|push) VERSION={some_released_version_of_kubernetes}
    19
    20REGISTRY?=registry.k8s.io
    21ARCH?=amd64
    22OUT_DIR?=_output
    23
    24LOCAL_OUTPUT_PATH=$(shell pwd)/../../../$(OUT_DIR)/local/bin/linux/$(ARCH)
    25DOCKERIZED_OUTPUT_PATH=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)
    26
    27GINKGO_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/ginkgo && echo $(LOCAL_OUTPUT_PATH)/ginkgo || echo $(DOCKERIZED_OUTPUT_PATH)/ginkgo)
    28KUBECTL_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/kubectl && echo $(LOCAL_OUTPUT_PATH)/kubectl || echo $(DOCKERIZED_OUTPUT_PATH)/kubectl)
    29E2E_TEST_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/e2e.test && echo $(LOCAL_OUTPUT_PATH)/e2e.test || echo $(DOCKERIZED_OUTPUT_PATH)/e2e.test)
    30E2E_GO_RUNNER_BIN?=$(shell test -f $(LOCAL_OUTPUT_PATH)/go-runner && echo $(LOCAL_OUTPUT_PATH)/go-runner || echo $(DOCKERIZED_OUTPUT_PATH)/go-runner)
    31
    32CLUSTER_DIR?=$(shell pwd)/../../../cluster/
    33
    34# This is defined in root Makefile, but some build contexts do not refer to them
    35KUBE_BASE_IMAGE_REGISTRY?=registry.k8s.io
    36BASE_IMAGE_VERSION?=bookworm-v1.0.2
    37RUNNERIMAGE?=${KUBE_BASE_IMAGE_REGISTRY}/build-image/debian-base-${ARCH}:${BASE_IMAGE_VERSION}
    38
    39TEMP_DIR:=$(shell mktemp -d -t conformance-XXXXXX)
    40
    41all: build
    42
    43build:
    44
    45ifndef VERSION
    46    $(error VERSION is undefined)
    47endif
    48	cp -r ./* ${TEMP_DIR}
    49
    50	cp ${GINKGO_BIN} ${TEMP_DIR}
    51	cp ${KUBECTL_BIN} ${TEMP_DIR}
    52	cp ${E2E_TEST_BIN} ${TEMP_DIR}
    53	cp ${E2E_GO_RUNNER_BIN} ${TEMP_DIR}/gorunner
    54	cp -r ${CLUSTER_DIR} ${TEMP_DIR}/cluster
    55
    56	chmod a+rx ${TEMP_DIR}/ginkgo
    57	chmod a+rx ${TEMP_DIR}/kubectl
    58	chmod a+rx ${TEMP_DIR}/e2e.test
    59	chmod a+rx ${TEMP_DIR}/gorunner
    60
    61	DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build \
    62		--platform linux/${ARCH} \
    63		--load \
    64		--pull \
    65		-t ${REGISTRY}/conformance-${ARCH}:${VERSION} \
    66		--build-arg RUNNERIMAGE=$(RUNNERIMAGE) \
    67		${TEMP_DIR}
    68	rm -rf "${TEMP_DIR}"
    69
    70push: build
    71	docker push ${REGISTRY}/conformance-${ARCH}:${VERSION}
    72ifeq ($(ARCH),amd64)
    73	docker rmi ${REGISTRY}/conformance:${VERSION} 2>/dev/null || true
    74	docker tag ${REGISTRY}/conformance-${ARCH}:${VERSION} ${REGISTRY}/conformance:${VERSION}
    75	docker push ${REGISTRY}/conformance:${VERSION}
    76endif
    77
    78.PHONY: build push all

View as plain text