This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
/
Makefile
95 lines (70 loc) · 2.85 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
SHELL=/bin/bash
.SHELLFLAGS=-O extglob -o errexit -o pipefail -o nounset -c
.PHONY: config echo-config
IMAGE_NAME?=kubernetes-anywhere
IMAGE_VERSION?=v0.0.1
# sorry windows and non amd64
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS = linux
endif
ifeq ($(UNAME_S),Darwin)
OS = darwin
endif
CONF_TOOL_VERSION = 4.6
KCONFIG_FILES = $(shell find . -name 'Kconfig')
CONFIG_FILE ?= .config
CONFIG_FILE_ABS := $(abspath $(lastword $(CONFIG_FILE)))
export CONFIG_JSON_FILE := $(CONFIG_FILE_ABS).json
CLOUD_PROVIDER = $(shell jq -r '.phase1.cloud_provider' $(CONFIG_JSON_FILE) 2>/dev/null)
BOOTSTRAP_PROVIDER = $(shell jq -r '.phase2.provider' $(CONFIG_JSON_FILE) 2>/dev/null)
CLUSTER_NAME = $(shell jq -r '.phase1.cluster_name' $(CONFIG_JSON_FILE) 2>/dev/null)
CLUSTER_DIR=clusters/$(CLUSTER_NAME)
default:
$(MAKE) deploy
config:
CONFIG_="." kconfig-conf Kconfig
menuconfig:
CONFIG_="." kconfig-mconf Kconfig
$(CONFIG_FILE_ABS): $(KCONFIG_FILES)
$(MAKE) config
$(CONFIG_JSON_FILE): $(CONFIG_FILE_ABS)
util/config_to_json $< > $@
echo-config: $(CONFIG_JSON_FILE)
cat $<
deploy-cluster destroy-cluster: $(CONFIG_JSON_FILE)
$(MAKE) do WHAT=$@
upgrade-master: $(CONFIG_JSON_FILE)
( cd "phase2/$(BOOTSTRAP_PROVIDER)"; ./do $@ )
# For maximum usefulness, use this target with "make -s" to silence any trace output, e.g.:
# $ export KUBECONFIG=$(make -s kubeconfig-path)
kubeconfig-path: $(CONFIG_JSON_FILE)
@$(eval KUBECONFIG_PATH := $(shell pwd)/phase1/$(CLOUD_PROVIDER)/$(CLUSTER_DIR)/kubeconfig.json)
@if [ ! -e "$(KUBECONFIG_PATH)" ]; then \
echo "Cannot find kubeconfig file. Have you started a cluster with \"make deploy\" yet?" > /dev/stderr; \
exit 1; \
fi
@echo $(KUBECONFIG_PATH)
validate-cluster-up: $(CONFIG_JSON_FILE)
KUBECONFIG="$$(pwd)/phase1/$(CLOUD_PROVIDER)/$(CLUSTER_DIR)/kubeconfig.json" ./util/validate
validate-node-ready: $(CONFIG_JSON_FILE)
KUBECONFIG="$$(pwd)/phase1/$(CLOUD_PROVIDER)/$(CLUSTER_DIR)/kubeconfig.json" NODE_READINESS_CHECK=y ./util/validate
addons: $(CONFIG_JSON_FILE)
KUBECONFIG="$$(pwd)/phase1/$(CLOUD_PROVIDER)/$(CLUSTER_DIR)/kubeconfig.json" ./phase3/do deploy
deploy: | deploy-cluster validate-cluster-up addons validate-node-ready
destroy: | destroy-cluster
do:
( cd "phase1/$(CLOUD_PROVIDER)"; ./do $(WHAT) )
docker-build:
docker build -t $(IMAGE_NAME):$(IMAGE_VERSION) .
docker-dev: docker-build
$(info Starting Kubernetes Anywhere deployment shell in a container)
docker run -it --rm --env="PS1=[container]:\w> " --net=host --volume="`pwd`:/opt/kubernetes-anywhere" $(IMAGE_NAME):$(IMAGE_VERSION) /bin/bash
docker-push: docker-build
docker push $(IMAGE_NAME):$(IMAGE_VERSION)
clean:
rm -rf phase1/*/clusters/*
rm -rf phase3/clusters/*
fmt:
for f in $$(find . -name '*.jsonnet'); do jsonnet fmt -i -n 2 $$(f); done;
# for f in $$(find . -name '*.json'); do jq -S '.' "$$(f)" | ex -sc "wq!$$(f)" /dev/stdin; done;