-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (63 loc) · 2.21 KB
/
Makefile
File metadata and controls
90 lines (63 loc) · 2.21 KB
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
.PHONY: about ping facts lint requirements
# Tips: https://tech.davis-hansson.com/p/make
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
PLAY_CMD=ansible-playbook
# Load the env settings so they can be read into the Ansible config
-include ./.env
.EXPORT_ALL_VARIABLES: ;
############################
default: host-bootstrap cluster-install cluster-bootstrap lab-bootstrap
dev: cluster-install-dev cluster-bootstrap lab-bootstrap
k3s: cluster-install
############################
about:
> @echo "Kubernetes Homelab Cluster"
ping: about
> @echo "Ping test as default deploy user"
> ansible cluster -m ping
facts: about
> @echo "Gather facts on cluster"
> ansible cluster -m setup
requirements:
> ansible-galaxy collection install -r requirements.yml --upgrade
lint:
> ansible-lint
############################
host-bootstrap: about lint
> @echo "Bootstrapping inventory hosts as $${BOOTSTRAP_USER}"
> $(PLAY_CMD) src/00-playbook-bootstrap.yml -u $${BOOTSTRAP_USER} --private-key=$${BOOTSTRAP_SSH_KEY_FILE} --ask-pass #-K --check
############################
cluster-install: about lint
> @echo "Install Kubernetes"
> $(PLAY_CMD) src/01-playbook-k3s-install.yml
cluster-upgrade: about lint
> @echo "Upgrade Kubernetes"
> $(PLAY_CMD) src/01a-playbook-k3s-upgrade.yml
cluster-bootstrap: about lint
> @echo "Configuring Kubernetes cluster-wide services"
> $(PLAY_CMD) src/02-playbook-services.yml
lab-bootstrap: about lint
> @echo "Start the lab Kubernetes cluster-wide services"
> $(PLAY_CMD) src/03-playbook-the-lab.yml
teardown: about lint
> @echo "Tear down the Kubernetes cluster"
> $(PLAY_CMD) src/99-playbook-k3s-teardown.yml
############################
cluster-install-dev: about
> @echo "Start k3d Dev Cluster"
> k3d cluster start homelab-dev || k3d cluster create --config src/k3d-dev.yaml
> k3d kubeconfig get homelab-dev > src/kubeconfig.yaml
############################
reboot:
> $(PLAY_CMD) src/50-playbook-reboot.yml
############################
clean:
> k3d cluster delete homelab-dev