-
Notifications
You must be signed in to change notification settings - Fork 69
/
demo.sh
executable file
·148 lines (92 loc) · 2.97 KB
/
demo.sh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
##############
# PostgreSQL #
##############
source .env
cat argocd/cnpg.yaml
cp argocd/cnpg.yaml infra/.
git add infra
git commit -m "CPNG"
git push
# Observe CNPG rollout in Argo CD UI
kubectl --namespace cnpg-system get all
cat argocd/backstage-postgresql.yaml
cp argocd/backstage-postgresql.yaml infra/.
git add .
git commit -m "Backstage PostgreSQL"
git push
# Observe PostgreSQL rollout in Argo CD UI
kubectl --namespace backstage get clusters
# The the login credentials for Backstage
export DB_PASS=$(kubectl --namespace backstage \
get secret backstage-app \
--output jsonpath="{.data.password}" | base64 --decode)
# Wait for the DB to be created
kubectl --namespace backstage wait pod backstage-1 \
--for=condition=Ready --timeout=90s
# Repeat the previous command if it errored claiming that the
# Pod does not exist since that probably means that the Pod
# was not yet created.
kubectl exec -it --namespace=backstage backstage-1 -- \
psql -c "\du"
#################
# SealedSecrets #
#################
cat argocd/sealed-secrets-app.yaml
cp argocd/sealed-secrets-app.yaml infra/.
git add infra
git commit -m "Deploy sealed secrets controller"
git push
# Observe SealedSecrets rollout in Argo CD UI
#############
# Backstage #
#############
cat backstage-resources/*.yaml
kubectl --namespace backstage \
create secret generic backstage-secrets \
--from-literal POSTGRES_USER=app \
--from-literal POSTGRES_PASSWORD=$DB_PASS \
--from-literal GITHUB_TOKEN=$GITHUB_TOKEN \
--from-literal ARGOCD_AUTH_TOKEN=$ARGOCD_AUTH_TOKEN_ENCODED \
--dry-run=client --output json
kubectl --namespace backstage \
create secret generic backstage-secrets \
--from-literal POSTGRES_USER=app \
--from-literal POSTGRES_PASSWORD=$DB_PASS \
--from-literal GITHUB_TOKEN=$GITHUB_TOKEN \
--from-literal ARGOCD_AUTH_TOKEN=$ARGOCD_AUTH_TOKEN_ENCODED \
--dry-run=client --output yaml \
| kubeseal --controller-namespace kubeseal --format yaml \
| tee backstage-resources/bs-secret.yaml
cat argocd/backstage.yaml
#yq --inplace \
# ".spec.rules[0].host = \"backstage.$INGRESS_HOST.nip.io\"" \
# backstage-resources/bs-ingress.yaml
cp argocd/backstage.yaml infra/.
git add .
git commit -m "Deploy Backstage"
git push
# Observe the Backstage rollout in ArgoCD
kubectl --namespace backstage get all,secrets
echo "https://$BACKSTAGE_URL"
# Open the URL from the output in a browser
#################
# Deploy An App #
#################
cat users-api/deployment.yaml
cat argocd/users-api.yaml
cp argocd/users-api.yaml apps/.
git add .
git commit -m "deploy users-api"
git push
kubectl get all
##########################
# Add App To The Catalog #
##########################
cat users-api/users-app-component.yaml
cp users-api/users-app-component.yaml catalog/
yq --inplace \
".spec.targets += [\"./users-app-component.yaml\"]" \
catalog/catalog-all.yaml
git add catalog
git commit -m "add users-api to the catalog"
git push