-
Notifications
You must be signed in to change notification settings - Fork 8
/
common.mk
54 lines (42 loc) · 1.3 KB
/
common.mk
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
include $(BASEDIR)/env.mk
include $(BASEDIR)/db.mk
setup: db-setup
# The first host in the index
# is the default host
#
HOST := $(shell [ -f $(DBIDX)/HOSTS ] && cat $(DBIDX)/HOSTS | head -1)
DOMAIN := $(HOST)
MASTER_IP ?= $(shell dig +short $(HOST))
KUBECONFIG := $(DATADIR)/db/config/kube/$(HOST)
K3S_VERSION := v0.9.0
SSHUSER := root
RELEASE := kernel
KC := KUBECONFIG=$(KUBECONFIG)
KCTL := $(KC) kubectl
SSH_KEY ?= $(HOME)/.ssh/id_rsa
ALL_HOSTS = $(shell [ -f $(DBIDX)/HOSTS ] && cat $(DBIDX)/HOSTS)
# helpers
# a literal space.
space :=
space +=
comma := ,
# Joins elements of the list in arg 2 with the given separator.
# 1. Element separator.
# 2. The list.
join-with = $(subst $(space),$1,$(strip $2))
kube-config: kube-config-path
k3sup install --ip $(MASTER_IP) --user $(SSHUSER) --ssh-key $(SSH_KEY) --skip-install --local-path $(KUBECONFIG) --k3s-version=$(K3S_VERSION)
kube-config-path:
@mkdir -p $(DBCFG)/kube
@echo $(KUBECONFIG)
checkaction:
@echo "Are you sure? This action is not reversable [y/N] " && read ans && [ $${ans:-N} = y ]
showhost:
@echo $(HOST)
showip:
@echo $(MASTER_IP)
ssh:
ssh -o StrictHostKeyChecking=no $(SSHUSER)@$(MASTER_IP)
hosts:
@echo $(DB_HOSTS)
.PHONY: .PHONY setup clean kube-config kube-config-path checkaction showip