github.com/yrj2011/jx-test-infra@v0.0.0-20190529031832-7a2065ee98eb/dind/build-node.sh (about) 1 #!/bin/bash 2 3 # Copyright 2018 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -o errexit 18 set -o nounset 19 set -o pipefail 20 21 TOOL_ROOT=${TOOL_ROOT:-"$(pwd)"} 22 KUBE_ROOT=${KUBE_ROOT:-"../../kubernetes"} 23 echo $TOOL_ROOT 24 echo $KUBE_ROOT 25 26 # Create a tmpdir to build the docker images from. 27 NODE_DIR=$(mktemp -d) 28 echo "Building node docker image from ${NODE_DIR}" 29 30 # make bazel-release doesn't produce everything we need, and it does a lot we don't need. 31 cd ${KUBE_ROOT} 32 33 # Build the debs 34 bazel build //build/debs:debs --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 35 36 # Build the docker containers 37 bazel build //build:docker-artifacts --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 38 39 # Build the addons configs. 40 bazel build //cluster/addons:addon-srcs --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 41 42 cd - 43 44 # Get debs needed for kubernetes node. Docker's build context rejects symlinks. 45 cp ${KUBE_ROOT}/bazel-bin/build/debs/kubernetes-cni.deb ${NODE_DIR} 46 cp ${KUBE_ROOT}/bazel-bin/build/debs/kubelet.deb ${NODE_DIR} 47 cp ${KUBE_ROOT}/bazel-bin/build/debs/kubeadm.deb ${NODE_DIR} 48 cp ${KUBE_ROOT}/bazel-bin/build/debs/kubectl.deb ${NODE_DIR} 49 50 # Get the docker images for components. Docker's build context rejects symlinks. 51 cp ${KUBE_ROOT}/bazel-bin/build/kube-proxy.tar ${NODE_DIR} 52 cp ${KUBE_ROOT}/bazel-bin/build/kube-controller-manager.tar ${NODE_DIR} 53 cp ${KUBE_ROOT}/bazel-bin/build/kube-scheduler.tar ${NODE_DIR} 54 cp ${KUBE_ROOT}/bazel-bin/build//kube-apiserver.tar ${NODE_DIR} 55 56 # Get version info in a file. Kubeadm version and docker tags might vary slightly. 57 cat ${KUBE_ROOT}/bazel-out/stable-status.txt | grep STABLE_BUILD_SCM_REVISION | awk '{print $2}' > ${NODE_DIR}/source_version 58 cat ${KUBE_ROOT}/bazel-out/stable-status.txt | grep STABLE_DOCKER_TAG | awk '{print $2}' > ${NODE_DIR}/docker_version 59 60 # Get the metrics-server addon config. This is needed for HPA tests. 61 mkdir -p ${NODE_DIR}/cluster/addons/metrics-server/ 62 cp ${KUBE_ROOT}/bazel-kubernetes/cluster/addons/metrics-server/* ${NODE_DIR}/cluster/addons/metrics-server/ 63 rm ${NODE_DIR}/cluster/addons/metrics-server/OWNERS 64 65 # Get the startup scripts. 66 cp ${TOOL_ROOT}/init-wrapper.sh ${NODE_DIR} 67 cp ${TOOL_ROOT}/start.sh ${NODE_DIR} 68 cp ${TOOL_ROOT}/node/Dockerfile ${NODE_DIR}/Dockerfile 69 cp ${TOOL_ROOT}/node/Makefile ${NODE_DIR}/Makefile 70 71 # Create the dind-node container 72 cd ${NODE_DIR} 73 make build K8S_VERSION=$(cat docker_version) 74 cd - 75 76 rm -rf ${NODE_DIR}