-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy-catalog-services.sh
executable file
·127 lines (113 loc) · 3.79 KB
/
deploy-catalog-services.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
#!/bin/bash
if [ -z `printenv TF_VAR_dns_zone` ]; then
echo "Stopping because TF_VAR_dns_zone is undefined"
exit 1
fi
if [ -z `printenv DNS_TYPE` ]; then
echo "Stopping because DNS_TYPE is undefined"
exit 1
fi
DNS_TYPE_values=("external-dns" "manual" "ionos_dnsaas")
found=false
for value in "${DNS_TYPE_values[@]}"
do
if [ "$value" == "${DNS_TYPE}" ] ; then
echo "${DNS_TYPE} is in the array"
found=true
fi
done
if [ $found == false ] ; then
echo "Stopping because DNS_TYPE is not valid"
exit 1
fi
if [ -z `printenv TF_VAR_kubeconfig` ]; then
echo "Stopping because TF_VAR_kubeconfig is undefined"
exit 1
fi
# This script is used to build the cloud landscape for the federated catalogue.
terraform -chdir=terraform init && terraform -chdir=terraform refresh && terraform -chdir=terraform plan && terraform -chdir=terraform apply -auto-approve
if [ $DNS_TYPE == 'ionos_dnsaas' ]; then
if [ -z `printenv IONOS_DNS_ZONE_ID` ]; then
DNS_ZONE_ID=$(curl -X "POST" \
-H "accept: application/json" \
-H "Authorization: Bearer $IONOS_TOKEN" \
-H "Content-Type: application/json" \
-d "{ \
\"properties\": { \
\"description\": \"Federated Catalogue DNS zone\", \
\"enabled\": true, \
\"zoneName\": \"$TF_VAR_dns_zone\"
} \
}" \
"https://dns.de-fra.ionos.com/zones" |jq -r '.id')
if [ $? != 0 ]; then
echo "DNS zone creation failed"
exit 1
fi
else
DNS_ZONE_ID=$IONOS_DNS_ZONE_ID
echo "Zone ID: $DNS_ZONE_ID"
fi
INGRESS_CONTROLLER_IP=$(kubectl --kubeconfig=$TF_VAR_kubeconfig -n nginx-ingress get svc nginx-ingress-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
if [ $? != 0 ]; then
echo "Getting ingress controller ip failed"
exit 1
fi
curl -X "POST" \
-H "accept: application/json" \
-H "Authorization: Bearer $IONOS_TOKEN" \
-H "Content-Type: application/json" \
-d "{ \
\"properties\": { \
\"name\": \"fc\", \
\"type\": \"A\", \
\"content\": \"$INGRESS_CONTROLLER_IP\", \
\"ttl\": 3600, \
\"prio\": 0, \
\"disabled\": false \
} \
}" \
"https://dns.de-fra.ionos.com/zones/$DNS_ZONE_ID/records"
if [ $? != 0 ]; then
echo "DNS record creation failed"
exit 1
fi
curl -X "POST" \
-H "accept: application/json" \
-H "Authorization: Bearer $IONOS_TOKEN" \
-H "Content-Type: application/json" \
-d "{ \
\"properties\": { \
\"name\": \"fc-demo-portal\", \
\"type\": \"A\", \
\"content\": \"$INGRESS_CONTROLLER_IP\", \
\"ttl\": 3600, \
\"prio\": 0, \
\"disabled\": false \
} \
}" \
"https://dns.de-fra.ionos.com/zones/$DNS_ZONE_ID/records"
if [ $? != 0 ]; then
echo "DNS record creation failed"
exit 1
fi
curl -X "POST" \
-H "accept: application/json" \
-H "Authorization: Bearer $IONOS_TOKEN" \
-H "Content-Type: application/json" \
-d "{ \
\"properties\": { \
\"name\": \"fc-key-server\", \
\"type\": \"A\", \
\"content\": \"$INGRESS_CONTROLLER_IP\", \
\"ttl\": 3600, \
\"prio\": 0, \
\"disabled\": false \
} \
}" \
"https://dns.de-fra.ionos.com/zones/$DNS_ZONE_ID/records"
if [ $? != 0 ]; then
echo "DNS record creation failed"
exit 1
fi
fi