-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
103 lines (88 loc) · 3.79 KB
/
justfile
File metadata and controls
103 lines (88 loc) · 3.79 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
91
92
93
94
95
96
97
98
99
100
101
102
103
set shell := ["bash", "-uc"]
default:
@just --list
@echo 'Suggested workflow'
@echo 'Provision the VMs: `just provision`'
@echo 'Configure the Cluster: `just configure`'
@echo 'Check the state: `just ssh-master`'
@echo '- or -'
@echo 'Check the ArgoCD state: `just argocd`'
requirements:
@echo "gcloud"
@echo "terraform"
@echo "ansible"
login:
gcloud auth login
setup_project project:
@echo 'Setting GCP project as {{ project }}'
gcloud config set project {{ project }}
[working-directory: 'terraform']
provision:
@echo 'Applying terraform resources...'
terraform plan -out plan.out
terraform apply plan.out
[working-directory: 'terraform']
stop:
@echo 'Destroying all resources...'
terraform destroy
[working-directory: 'ansible']
configure:
@echo 'Preparing Ansible playbook...'
ssh-add -D
gcloud secrets versions access latest --secret=ssh-private-key-secret-name > /tmp/ansible-key
@chmod 0600 /tmp/ansible-key
ansible-playbook -i inventories/inventory.gcp.yml playbooks/cluster.yml
[working-directory: 'ansible']
hosts:
@echo 'Echoing all hosts...'
ssh-add -D
gcloud secrets versions access latest --secret=ssh-private-key-secret-name > /tmp/ansible-key
@chmod 0600 /tmp/ansible-key
ansible-inventory -i inventories/inventory.gcp.yml --graph
ssh-master:
gcloud secrets versions access latest --secret=ssh-private-key-secret-name > /tmp/ansible-key
@chmod 0600 /tmp/ansible-key
@ssh-add /tmp/ansible-key
@ssh debian@"$(ansible-inventory -i ansible/inventories/inventory.gcp.yml --graph \
| grep -A 1 "@_master" \
| tail -n 1 \
| sed 's/.*--//; s/ //g')"
grafana:
@echo "Grafana will be available on localhost:3000..."
gcloud secrets versions access latest --secret=ssh-private-key-secret-name > /tmp/ansible-key
@chmod 0600 /tmp/ansible-key
@ssh-add /tmp/ansible-key
@ssh -tL 3000:localhost:3000 debian@"$(ansible-inventory -i ansible/inventories/inventory.gcp.yml --graph \
| grep -A 1 "@_master" \
| tail -n 1 \
| sed 's/.*--//; s/ //g')" 'kubectl get secret -n monitoring kube-prometheus-stack-grafana -o jsonpath="{.data.admin-password}" | base64 -d && kubectl port-forward -n monitoring svc/kube-prometheus-stack-grafana 3000:80'
grafana-pw:
@ssh -tL 8080:localhost:8080 debian@"$(ansible-inventory -i ansible/inventories/inventory.gcp.yml --graph \
| grep -A 1 "@_master" \
| tail -n 1 \
| sed 's/.*--//; s/ //g')" 'kubectl -n argocd get secret kube-prometheus-stack-grafana -o jsonpath="{.data.admin-password}" | base64 -d'
argocd:
@echo "ArgoCD will be available on localhost:8080..."
gcloud secrets versions access latest --secret=ssh-private-key-secret-name > /tmp/ansible-key
@chmod 0600 /tmp/ansible-key
@ssh-add /tmp/ansible-key
@ssh -tL 8080:localhost:8080 debian@"$(ansible-inventory -i ansible/inventories/inventory.gcp.yml --graph \
| grep -A 1 "@_master" \
| tail -n 1 \
| sed 's/.*--//; s/ //g')" 'kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d && kubectl port-forward svc/argocd-server -n argocd 8080:443'
argocd-pw:
@ssh -tL 8080:localhost:8080 debian@"$(ansible-inventory -i ansible/inventories/inventory.gcp.yml --graph \
| grep -A 1 "@_master" \
| tail -n 1 \
| sed 's/.*--//; s/ //g')" 'kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d'
traefik:
@echo "Traefik will be available on localhost:8080/dashboard..."
gcloud secrets versions access latest --secret=ssh-private-key-secret-name > /tmp/ansible-key
@chmod 0600 /tmp/ansible-key
@ssh-add /tmp/ansible-key
@ssh -tL 8080:localhost:8080 debian@"$(ansible-inventory -i ansible/inventories/inventory.gcp.yml --graph \
| grep -A 1 "@_master" \
| tail -n 1 \
| sed 's/.*--//; s/ //g')" ' kubectl port-forward -n traefik svc/traefik 8080:80'
cleanup:
rm -f /tmp/ansible-key plan.out