-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (54 loc) · 1.95 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
get-input = $(shell read -p "$(1): " input; echo $$input)
get-secret = $(shell read -s -p "$(1): " secret; echo $$secret; echo 1>&0)
docker-run := docker run $(shell [ -t 0 ] && echo -it || echo -i) -e DOMAIN_NAME=${DOMAIN_NAME}
export DOMAIN_NAME ?= ${domain}
.PHONY: build
build:
docker build -t kubespray -f Dockerfile .
.PHONY: apply
apply: ## Apply the kubernetes cluster
apply: generate ${DOMAIN_NAME}-private.key build
${docker-run} -v .:/inventory kubespray cluster.yml
.PHONY: reset
reset: ## Reset the kubernetes cluster
reset: generate ${DOMAIN_NAME}-private.key build
${docker-run} -v .:/inventory kubespray reset.yml
.PHONY: ${DOMAIN_NAME}-private.key
${DOMAIN_NAME}-private.key: .FORCE
@chmod 400 $@
.PHONY: .FORCE
.FORCE:
.PHONY: login
login: ## Configure the provider credentials
login: oauth2-clientid ?= $(call get-input,oauth2-clientid)
login: oauth2-client-secret ?= $(call get-secret,oauth2-client-secret)
login: oauth2-user ?= $(call get-input,oauth2-user)
login: oauth2-password ?= $(call get-secret,oauth2-password)
login: ${HOME}/.cntb.yaml
@echo "Logged in"
${HOME}/.cntb.yaml:
@cntb config set-credentials \
--oauth2-clientid='${oauth2-clientid}' \
--oauth2-client-secret='${oauth2-client-secret}' \
--oauth2-user='${oauth2-user}' \
--oauth2-password='${oauth2-password}'
.PHONY: generate
generate: ## Generate the ansible inventory
generate: .cntb .cntb/private-networks.json .cntb/instances.json
@deno -A ./generate.ts
.cntb:
@mkdir -p .cntb
.cntb/private-networks.json:
@cntb get privateNetworks --output json > .cntb/private-networks.json
.cntb/instances.json:
@cntb get instances --output json > .cntb/instances.json
.PHONY: list-nodes
list-nodes: ## List all nodes in the cluster
list-nodes: generate
@echo "Nodes:"
@cat .cntb/instances.json | jq -r '.[] | .displayName' | grep '^${DOMAIN_NAME}-'
.PHONY: test
test: ## Test basic cluster functionalities
test: generate
@echo "Test basic cluster functionalities..."
@deno test -A