k8s.io/kubernetes@v1.29.3/test/e2e_node/conformance/build/Makefile (about)

     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 node-test image.
    16  #
    17  # Usage:
    18  #   [ARCH=amd64] [REGISTRY="staging-k8s.gcr.io"] [BIN_DIR="../../../../_output/bin"] make (build|push) VERSION={some_version_number e.g. 0.1}
    19  
    20  # SYSTEM_SPEC_NAME is the name of the system spec used for the node conformance
    21  # test. The specs are expected to be in SYSTEM_SPEC_DIR.
    22  SYSTEM_SPEC_NAME?=
    23  SYSTEM_SPEC_DIR?=../../system/specs
    24  
    25  # TODO(random-liu): Add this into release progress.
    26  REGISTRY?=staging-k8s.gcr.io
    27  ARCH?=amd64
    28  # BIN_DIR is the directory to find binaries, overwrite with ../../../../_output/bin
    29  # for local development.
    30  BIN_DIR?=../../../../_output/dockerized/bin/linux/${ARCH}
    31  TEMP_DIR:=$(shell mktemp -d)
    32  
    33  BASEIMAGE_amd64=debian:jessie
    34  BASEIMAGE_arm=arm32v7/debian:jessie
    35  BASEIMAGE_arm64=arm64v8/debian:jessie
    36  BASEIMAGE_ppc64le=ppc64le/debian:jessie
    37  
    38  BASEIMAGE?=${BASEIMAGE_${ARCH}}
    39  
    40  IMAGE_NAME:=${REGISTRY}/node-test
    41  COPY_SYSTEM_SPEC_FILE=
    42  SYSTEM_SPEC_FILE_PATH=
    43  ifneq ($(strip $(SYSTEM_SPEC_NAME)),)
    44      IMAGE_NAME:=${IMAGE_NAME}-${SYSTEM_SPEC_NAME}
    45      COPY_SYSTEM_SPEC_FILE="'COPY system-spec.yaml /usr/local/etc/'"
    46      SYSTEM_SPEC_FILE_PATH="'/usr/local/etc/system-spec.yaml'"
    47  endif
    48  
    49  all: build
    50  
    51  build:
    52  
    53  ifndef VERSION
    54      $(error VERSION is undefined)
    55  endif
    56  	cp -r ./* ${TEMP_DIR}
    57  
    58  	cp ${BIN_DIR}/ginkgo ${TEMP_DIR}
    59  	cp ${BIN_DIR}/e2e_node.test ${TEMP_DIR}
    60  ifneq ($(strip $(SYSTEM_SPEC_NAME)),)
    61  	cp ${SYSTEM_SPEC_DIR}/${SYSTEM_SPEC_NAME}.yaml ${TEMP_DIR}/system-spec.yaml
    62  endif
    63  
    64  	cd ${TEMP_DIR} && sed -i.back \
    65  	    "s|BASEIMAGE|${BASEIMAGE}|g;\
    66  	     s|COPY_SYSTEM_SPEC_FILE|${COPY_SYSTEM_SPEC_FILE}|g;\
    67  	     s|SYSTEM_SPEC_NAME|${SYSTEM_SPEC_NAME}|g;\
    68  	     s|SYSTEM_SPEC_FILE_PATH|${SYSTEM_SPEC_FILE_PATH}|g" Dockerfile
    69  
    70  	# Make scripts executable before they are copied into the Docker image. If we make them executable later, in another layer
    71  	# they'll take up twice the space because the new executable binary differs from the old one, but everything is cached in layers.
    72  	cd ${TEMP_DIR} && chmod a+rx \
    73  		e2e_node.test \
    74  		ginkgo
    75  
    76  	docker build --pull -t ${IMAGE_NAME}-${ARCH}:${VERSION} ${TEMP_DIR}
    77  
    78  push: build
    79  	docker push ${IMAGE_NAME}-${ARCH}:${VERSION}
    80  ifeq ($(ARCH),amd64)
    81  	docker tag ${IMAGE_NAME}-${ARCH}:${VERSION} ${IMAGE_NAME}:${VERSION}
    82  	docker push ${IMAGE_NAME}:${VERSION}
    83  endif
    84  
    85  .PHONY: all