2016-06-03 00:25:58 +00:00
|
|
|
# Copyright 2016 The Kubernetes Authors.
|
2016-02-03 06:30:10 +00:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2015-12-23 14:07:35 +00:00
|
|
|
# Build the hyperkube image.
|
|
|
|
#
|
|
|
|
# Usage:
|
2016-08-24 22:24:05 +00:00
|
|
|
# [ARCH=amd64] [REGISTRY="gcr.io/google_containers"] make (build|push) VERSION={some_released_version_of_kubernetes}
|
2015-04-03 21:54:09 +00:00
|
|
|
|
2016-06-19 14:15:17 +00:00
|
|
|
REGISTRY?=gcr.io/google_containers
|
2016-04-04 20:33:32 +00:00
|
|
|
ARCH?=amd64
|
2016-11-12 03:12:58 +00:00
|
|
|
TEMP_DIR:=$(shell mktemp -d -t hyperkubeXXXXXX)
|
2017-03-22 22:43:43 +00:00
|
|
|
CNI_RELEASE=0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff
|
2017-01-17 11:36:30 +00:00
|
|
|
CACHEBUST?=1
|
2017-01-27 18:04:24 +00:00
|
|
|
QEMUVERSION=v2.7.0
|
2015-11-23 03:53:45 +00:00
|
|
|
|
2016-05-17 19:31:32 +00:00
|
|
|
UNAME_S:=$(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
SED_CMD?=sed -i ""
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
SED_CMD?=sed -i
|
|
|
|
endif
|
2016-05-20 16:28:13 +00:00
|
|
|
|
2016-04-04 20:33:32 +00:00
|
|
|
ifeq ($(ARCH),amd64)
|
|
|
|
BASEIMAGE?=debian:jessie
|
|
|
|
endif
|
|
|
|
ifeq ($(ARCH),arm)
|
2017-01-27 18:04:24 +00:00
|
|
|
BASEIMAGE?=armhf/debian:jessie
|
2016-04-14 04:29:10 +00:00
|
|
|
QEMUARCH=arm
|
|
|
|
endif
|
|
|
|
ifeq ($(ARCH),arm64)
|
|
|
|
BASEIMAGE?=aarch64/debian:jessie
|
|
|
|
QEMUARCH=aarch64
|
|
|
|
endif
|
|
|
|
ifeq ($(ARCH),ppc64le)
|
|
|
|
BASEIMAGE?=ppc64le/debian:jessie
|
|
|
|
QEMUARCH=ppc64le
|
2016-04-04 20:33:32 +00:00
|
|
|
endif
|
2016-11-18 13:52:21 +00:00
|
|
|
ifeq ($(ARCH),s390x)
|
|
|
|
BASEIMAGE?=s390x/debian:jessie
|
|
|
|
QEMUARCH=s390x
|
|
|
|
endif
|
2015-04-03 21:54:09 +00:00
|
|
|
|
2015-12-08 10:42:54 +00:00
|
|
|
all: build
|
|
|
|
|
|
|
|
build:
|
2016-04-14 04:29:10 +00:00
|
|
|
|
2015-12-23 14:07:35 +00:00
|
|
|
ifndef VERSION
|
|
|
|
$(error VERSION is undefined)
|
|
|
|
endif
|
2016-05-20 16:28:13 +00:00
|
|
|
cp -r ./* ${TEMP_DIR}
|
2016-08-24 22:24:05 +00:00
|
|
|
mkdir -p ${TEMP_DIR}/cni-bin ${TEMP_DIR}/addons ${TEMP_DIR}/addons/singlenode ${TEMP_DIR}/addons/multinode
|
2015-12-29 09:38:20 +00:00
|
|
|
cp ../../saltbase/salt/generate-cert/make-ca-cert.sh ${TEMP_DIR}
|
2016-08-24 22:24:05 +00:00
|
|
|
|
|
|
|
# Singlenode addons
|
2016-12-09 03:47:11 +00:00
|
|
|
cp ../../addons/dns/kubedns-controller.yaml.base ${TEMP_DIR}/addons/singlenode/kubedns-controller.yaml
|
|
|
|
cp ../../addons/dns/kubedns-svc.yaml.base ${TEMP_DIR}/addons/singlenode/kubedns-svc.yaml
|
2017-03-09 00:45:22 +00:00
|
|
|
cp ../../addons/dns/kubedns-sa.yaml ${TEMP_DIR}/addons/singlenode/kubedns-sa.yaml
|
|
|
|
cp ../../addons/dns/kubedns-cm.yaml ${TEMP_DIR}/addons/singlenode/kubedns-cm.yaml
|
2016-08-24 22:24:05 +00:00
|
|
|
cp ../../addons/dashboard/dashboard-controller.yaml ${TEMP_DIR}/addons/singlenode/
|
|
|
|
cp ../../addons/dashboard/dashboard-service.yaml ${TEMP_DIR}/addons/singlenode/
|
|
|
|
|
|
|
|
# Multinode addons; all singlenode addons plus kube-proxy (and soon flannel)
|
|
|
|
cp ${TEMP_DIR}/addons/singlenode/*.yaml ${TEMP_DIR}/addons/multinode/
|
|
|
|
cp kube-proxy-ds.yaml ${TEMP_DIR}/addons/multinode/kube-proxy.yaml
|
|
|
|
|
2015-12-29 09:38:20 +00:00
|
|
|
cp ../../../_output/dockerized/bin/linux/${ARCH}/hyperkube ${TEMP_DIR}
|
2016-05-20 16:28:13 +00:00
|
|
|
|
2016-08-24 22:24:05 +00:00
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|VERSION|${VERSION}|g" addons/singlenode/*.yaml addons/multinode/*.yaml static-pods/*.json
|
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|REGISTRY|${REGISTRY}|g" addons/singlenode/*.yaml addons/multinode/*.yaml static-pods/*.json
|
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|ARCH|${ARCH}|g" addons/singlenode/*.yaml addons/multinode/*.yaml static-pods/*.json
|
2016-04-14 04:29:10 +00:00
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|ARCH|${QEMUARCH}|g" Dockerfile
|
2016-03-13 01:59:08 +00:00
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
|
2017-01-17 11:36:30 +00:00
|
|
|
ifeq ($(CACHEBUST),1)
|
2016-09-28 22:20:02 +00:00
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|CACHEBUST|$(shell uuidgen)|g" Dockerfile
|
2017-01-17 11:36:30 +00:00
|
|
|
endif
|
2016-08-24 22:24:05 +00:00
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|-amd64|-${ARCH}|g" addons/singlenode/*.yaml addons/multinode/*.yaml
|
2016-12-09 03:47:11 +00:00
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|__PILLAR__DNS__SERVER__|10.0.0.10|g" addons/singlenode/kubedns*.yaml addons/multinode/kubedns*.yaml
|
2017-03-08 05:25:09 +00:00
|
|
|
cd ${TEMP_DIR} && sed -i.back "s|__PILLAR__DNS__DOMAIN__|cluster.local|g" addons/singlenode/kubedns*.yaml addons/multinode/kubedns*.yaml
|
2016-08-24 22:24:05 +00:00
|
|
|
cd ${TEMP_DIR} && rm -f addons/singlenode/*.back addons/multinode/*.back static-pods/*.back
|
2016-04-04 20:33:32 +00:00
|
|
|
|
2016-05-16 21:28:24 +00:00
|
|
|
# Make scripts executable before they are copied into the Docker image. If we make them executable later, in another layer
|
|
|
|
# they'll take up twice the space because the new executable binary differs from the old one, but everything is cached in layers.
|
|
|
|
cd ${TEMP_DIR} && chmod a+rx \
|
2016-05-20 16:28:13 +00:00
|
|
|
hyperkube \
|
|
|
|
setup-files.sh \
|
|
|
|
make-ca-cert.sh \
|
|
|
|
copy-addons.sh
|
2016-05-16 21:28:24 +00:00
|
|
|
|
2015-11-23 03:53:45 +00:00
|
|
|
ifeq ($(ARCH),amd64)
|
2016-04-04 20:33:32 +00:00
|
|
|
# When building "normally" for amd64, remove the whole line, it has no part in the amd64 image
|
2016-05-17 19:31:32 +00:00
|
|
|
cd ${TEMP_DIR} && ${SED_CMD} "/CROSS_BUILD_/d" Dockerfile
|
2016-04-04 20:33:32 +00:00
|
|
|
else
|
2016-07-22 22:03:46 +00:00
|
|
|
cd ${TEMP_DIR} && ${SED_CMD} "s/CROSS_BUILD_//g" Dockerfile
|
|
|
|
|
2016-04-04 20:33:32 +00:00
|
|
|
# When cross-building, only the placeholder "CROSS_BUILD_" should be removed
|
|
|
|
# Register /usr/bin/qemu-ARCH-static as the handler for ARM binaries in the kernel
|
|
|
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
2017-01-27 18:04:24 +00:00
|
|
|
curl -sSL --retry 5 https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-${QEMUARCH}-static.tar.gz | tar -xz -C ${TEMP_DIR}
|
2016-08-24 22:24:05 +00:00
|
|
|
endif
|
2016-08-25 23:59:33 +00:00
|
|
|
# Download CNI
|
|
|
|
curl -sSL --retry 5 https://storage.googleapis.com/kubernetes-release/network-plugins/cni-${ARCH}-${CNI_RELEASE}.tar.gz | tar -xz -C ${TEMP_DIR}/cni-bin
|
2015-04-03 21:54:09 +00:00
|
|
|
|
2017-01-10 22:29:47 +00:00
|
|
|
docker build --pull -t ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${TEMP_DIR}
|
2016-08-14 06:07:34 +00:00
|
|
|
rm -rf "${TEMP_DIR}"
|
2016-04-04 20:33:32 +00:00
|
|
|
|
2015-12-08 10:42:54 +00:00
|
|
|
push: build
|
2016-10-10 20:42:29 +00:00
|
|
|
gcloud docker -- push ${REGISTRY}/hyperkube-${ARCH}:${VERSION}
|
2015-12-08 10:42:54 +00:00
|
|
|
ifeq ($(ARCH),amd64)
|
2017-03-07 20:38:26 +00:00
|
|
|
docker rmi ${REGISTRY}/hyperkube:${VERSION} 2>/dev/null || true
|
2016-10-07 21:20:30 +00:00
|
|
|
docker tag ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${REGISTRY}/hyperkube:${VERSION}
|
2016-10-10 20:42:29 +00:00
|
|
|
gcloud docker -- push ${REGISTRY}/hyperkube:${VERSION}
|
2015-12-08 10:42:54 +00:00
|
|
|
endif
|
|
|
|
|
2015-04-03 21:54:09 +00:00
|
|
|
.PHONY: all
|