-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (68 loc) · 2.73 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
.PHONY: all $(MAKECMDGOALS)
SHELL := /bin/bash
USER=root
MANAGER_NODE_IP?=$(shell sops --decrypt ./inventory.enc.yaml | grep k8s-manager-01 -A 1 | grep ansible_host | cut -d':' -f2- | tr -d ' ')
RESTORE=./.restore ${USER} ${MANAGER_NODE_IP}
INSTALL=./.install ${USER} ${MANAGER_NODE_IP}
BASENAME=$(shell basename ${PWD})
help: ## Show this help
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/:.*##/;/' | column -t -s';'
rsync_up: ## Sync to management node
rsync -azvP --exclude '.git' --delete . ${USER}@${MANAGER_NODE_IP}:~/${BASENAME}
download_kubeconfig: ## Download kubeconfig from management node to localhost
rsync -avq ${USER}@${MANAGER_NODE_IP}:~/.kube/config kubeconfig.yaml
install: ## Install any component
${INSTALL} ${COMPONENT}
install_foundation: ## Install foundation
${INSTALL} host-dns
${INSTALL} rke2
${INSTALL} multipath
install_tool: ## Install a single tool
${INSTALL} ${TOOL}
install_tools: ## Install all tools
${INSTALL} helm
${INSTALL} helm-secrets
${INSTALL} sops
${INSTALL} azure-cli
${INSTALL} jq
${INSTALL} k9s
${INSTALL} kubectl
${INSTALL} velero-cli
install_app: ## Install a single app
${INSTALL} ${APP}
install_ephemeral_apps: ## Install all ephemeral applications
${INSTALL} cert-manager
${INSTALL} nfs-subdir-external-provisioner
${INSTALL} minio
${INSTALL} velero
${INSTALL} longhorn
${INSTALL} promtail
${INSTALL} loki
${INSTALL} rancher-monitoring
${INSTALL} drone-runner-kube
install_stateful_apps: ## Install stateful applications
${INSTALL} gitea
${INSTALL} gotify
${INSTALL} drone
install_apps: install_ephemeral_apps install_stateful_apps
restore_namespace: ## Restore namespace
${RESTORE} ${NAMESPACE}
backup_cluster: ## Create full backup from schedule including data
./.backup ${USER} ${MANAGER_NODE_IP}
backup_namespace: ## Backup a namespace including data
ssh ${USER}@${MANAGER_NODE_IP} \
velero backup create ${BACKUP_NAME} \
--include-namespaces=${NAMESPACE} \
--default-volumes-to-restic=true
disaster_recovery: install_foundation install_tools install_ephemeral_apps ## Full recovery in case of a disaster
sleep 60
${RESTORE} gitea
${RESTORE} gotify
${RESTORE} drone
${RESTORE} acc
${RESTORE} prd
# Restored but differently
# ${RESTORE} argocd is not included in the with data backup. use the without data one.
clean_install: install_foundation install_tools install_apps ## Full installation from scratch
sops_encrypt: ## Sops encrypt file
sops --encrypt ${DEC_FILE} > `echo ${DEC_FILE} | sed 's/.dec./.enc./'`