k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/images/kubekins-e2e/Dockerfile (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 # This file creates a build environment for building and running kubernetes 16 # unit and integration tests 17 18 ARG OLD_BAZEL_VERSION 19 FROM launcher.gcr.io/google/bazel:${OLD_BAZEL_VERSION} as old 20 FROM gcr.io/k8s-staging-test-infra/bootstrap:v20240308-3b134c2624 21 22 # hint to kubetest that it is in CI 23 ENV KUBETEST_IN_DOCKER="true" 24 25 # Go standard envs 26 ENV GOPATH /go 27 ENV PATH /usr/local/go/bin:$PATH 28 29 RUN mkdir -p /go/bin 30 ENV PATH $GOPATH/bin:$PATH 31 32 # setup k8s repo symlink 33 RUN mkdir -p /go/src/k8s.io/kubernetes \ 34 && ln -s /go/src/k8s.io/kubernetes /workspace/kubernetes 35 36 # preinstall: 37 # - graphviz package for graphing profiles 38 # - bc for shell to junit 39 # - rpm for building RPMs with Bazel 40 RUN apt-get update && \ 41 apt-get install -y bc \ 42 graphviz \ 43 rpm && \ 44 rm -rf /var/lib/apt/lists/* 45 # preinstall this for kops tests xref kubetest prepareAws(...) 46 # TODO(krzyzacy,justisb,chrislovecnm): remove this 47 RUN pip install --no-cache-dir --break-system-packages awscli 48 49 # install cfssl to prevent https://github.com/kubernetes/kubernetes/issues/55589 50 # The invocation at the end is to prevent download failures downloads as in the bug. 51 # TODO(porridge): bump CFSSL_VERSION to one where cfssljson supports the -version flag and test it as well. 52 ARG CFSSL_VERSION 53 RUN wget -q -O cfssl "https://pkg.cfssl.org/${CFSSL_VERSION}/cfssl_linux-amd64" && \ 54 wget -q -O cfssljson "https://pkg.cfssl.org/${CFSSL_VERSION}/cfssljson_linux-amd64" && \ 55 chmod +x cfssl cfssljson && \ 56 mv cfssl cfssljson /usr/local/bin && \ 57 cfssl version 58 59 # replace kubectl with one from K8S_RELEASE 60 ARG K8S_RELEASE=latest 61 RUN rm -f $(which kubectl) && \ 62 export KUBECTL_VERSION=$(curl -L https://dl.k8s.io/release/${K8S_RELEASE}.txt) && \ 63 wget https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl && \ 64 chmod +x /usr/local/bin/kubectl 65 66 # install go 67 ARG GO_VERSION 68 ENV GO_TARBALL "go${GO_VERSION}.linux-amd64.tar.gz" 69 RUN wget -q "https://go.dev/dl/${GO_TARBALL}" && \ 70 tar xzf "${GO_TARBALL}" -C /usr/local && \ 71 rm "${GO_TARBALL}" 72 73 # install yq 74 ARG YQ_VERSION 75 RUN wget -q "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" \ 76 -O /usr/local/bin/yq && chmod +x /usr/local/bin/yq 77 78 # install bazel 79 ARG BAZEL_VERSION_ARG 80 ENV BAZEL_VERSION=${BAZEL_VERSION_ARG} 81 COPY images/kubekins-e2e/install-bazel.sh / 82 RUN bash /install-bazel.sh 83 84 ARG OLD_BAZEL_VERSION 85 COPY --from=old \ 86 /usr/local/lib/bazel/bin/bazel-real /usr/local/lib/bazel/bin/bazel-${OLD_BAZEL_VERSION} 87 88 # install kind if a version is provided 89 ARG KIND_VERSION 90 RUN if [ -n "${KIND_VERSION}" ]; then \ 91 wget -q -O /usr/local/bin/kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-linux-amd64 && \ 92 chmod +x /usr/local/bin/kind; \ 93 fi 94 95 # install kubetest2 binaries if a version is provided 96 # kubetest2 must be installed from git as the makefile embeds the git short hash and the day it was built. 97 ARG KUBETEST2_VERSION 98 RUN if [ -n "${KUBETEST2_VERSION}" ]; then \ 99 git clone https://github.com/kubernetes-sigs/kubetest2.git /tmp/kubetest2 && \ 100 cd /tmp/kubetest2 && make install-all && rm -rf /tmp/kubetest2; \ 101 fi 102 103 # configure dockerd to use mirror.gcr.io 104 # per instructions at https://cloud.google.com/container-registry/docs/pulling-cached-images 105 ARG DOCKER_REGISTRY_MIRROR_URL=https://mirror.gcr.io 106 RUN [ -n "${DOCKER_REGISTRY_MIRROR_URL}" ] && \ 107 echo "DOCKER_OPTS=\"\${DOCKER_OPTS} --registry-mirror=${DOCKER_REGISTRY_MIRROR_URL}\"" | \ 108 tee --append /etc/default/docker 109 110 # add env we can debug with the image name:tag 111 ARG IMAGE_ARG 112 ENV IMAGE=${IMAGE_ARG} 113 114 # everything below will be triggered on every new image tag ... 115 ADD ["images/kubekins-e2e/kops-e2e-runner.sh", \ 116 "images/kubekins-e2e/kubetest", \ 117 "https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/get-kube.sh", \ 118 "logexporter/cluster/log-dump.sh", \ 119 "logexporter/cluster/logexporter-daemonset.yaml", \ 120 "/workspace/"] 121 ENV LOG_DUMP_SCRIPT_PATH "/workspace/log-dump.sh" 122 RUN ["chmod", "+x", "/workspace/get-kube.sh", "/workspace/log-dump.sh"] 123