Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. # Build the hyperkube image.
  15. #
  16. # Usage:
  17. # [ARCH=amd64] [REGISTRY="staging-k8s.gcr.io"] make (build|push) VERSION={some_released_version_of_kubernetes}
  18. REGISTRY?=staging-k8s.gcr.io
  19. ARCH?=amd64
  20. OUT_DIR?=_output
  21. BASEIMAGE=k8s.gcr.io/debian-hyperkube-base-$(ARCH):0.12.1
  22. LOCAL_OUTPUT_PATH=$(shell pwd)/../../../$(OUT_DIR)/local/bin/linux/$(ARCH)
  23. DOCKERIZED_OUTPUT_PATH=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)
  24. OUTPUT_PATH?=$(shell test -d $(LOCAL_OUTPUT_PATH) && echo $(LOCAL_OUTPUT_PATH) || echo $(DOCKERIZED_OUTPUT_PATH))
  25. TEMP_DIR:=$(shell mktemp -d -t hyperkubeXXXXXX)
  26. all: build
  27. build:
  28. ifndef VERSION
  29. $(error VERSION is undefined)
  30. endif
  31. cp -r ./* ${TEMP_DIR}
  32. tar -cvzf ${TEMP_DIR}/binaries.tgz -C ${OUTPUT_PATH} kube-apiserver kube-controller-manager \
  33. kube-proxy kube-scheduler kubectl kubelet
  34. chmod a+rx ${TEMP_DIR}/hyperkube
  35. cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
  36. docker build --pull -t ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${TEMP_DIR}
  37. rm -rf "${TEMP_DIR}"
  38. push: build
  39. docker push ${REGISTRY}/hyperkube-${ARCH}:${VERSION}
  40. ifeq ($(ARCH),amd64)
  41. docker rmi ${REGISTRY}/hyperkube:${VERSION} 2>/dev/null || true
  42. docker tag ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${REGISTRY}/hyperkube:${VERSION}
  43. docker push ${REGISTRY}/hyperkube:${VERSION}
  44. endif
  45. .PHONY: build push all