...
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
15IMAGE=gcr.io/k8s-staging-addon-manager/kube-addon-manager
16ARCH?=amd64
17TEMP_DIR:=$(shell mktemp -d)
18VERSION=v9.1.7
19KUBECTL_VERSION?=v1.27.1
20
21BASEIMAGE=registry.k8s.io/debian-base-$(ARCH):v1.0.1
22
23SUDO=$(if $(filter 0,$(shell id -u)),,sudo)
24
25.PHONY: build push
26
27all: build
28
29build:
30 cp ./* $(TEMP_DIR)
31 curl -sSL --retry 5 https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/$(ARCH)/kubectl > $(TEMP_DIR)/kubectl
32 chmod a+rx $(TEMP_DIR)/kube-addons.sh $(TEMP_DIR)/kube-addons-main.sh $(TEMP_DIR)/kubectl
33
34ifneq ($(ARCH),amd64)
35 # Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
36 $(SUDO) ../../../third_party/multiarch/qemu-user-static/register/register.sh --reset
37endif
38
39 docker build --pull -t $(IMAGE)-$(ARCH):$(VERSION) $(TEMP_DIR) --build-arg BASEIMAGE=$(BASEIMAGE)
40
41push: build
42 docker push $(IMAGE)-$(ARCH):$(VERSION)
43ifeq ($(ARCH),amd64)
44 # Backward compatibility. TODO: deprecate this image tag
45 docker rmi $(IMAGE):$(VERSION) 2>/dev/null || true
46 docker tag $(IMAGE)-$(ARCH):$(VERSION) $(IMAGE):$(VERSION)
47 docker push $(IMAGE):$(VERSION)
48endif
49
50test:
51 cp ./* $(TEMP_DIR)
52 curl -sSL --retry 5 https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/$(ARCH)/kubectl > $(TEMP_DIR)/kubectl
53 chmod a+rx $(TEMP_DIR)/kube-addons.sh $(TEMP_DIR)/kube-addons-test.sh $(TEMP_DIR)/kubectl
54 cd $(TEMP_DIR) && KUBECTL_BIN=$(TEMP_DIR)/kubectl ./kube-addons-test.sh
55
56clean:
57 docker rmi -f $(IMAGE)-$(ARCH):$(VERSION)
View as plain text