-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathauto-install.sh
executable file
·166 lines (133 loc) · 5.72 KB
/
auto-install.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
set -e
source ./aws-env-vars
#####################################
# Set your environment variables here
#####################################
# Random suffix generator
generate_random_suffix() {
tr -dc 'a-z0-9' </dev/urandom | head -c 5
}
# S3 Buckets
LOKI_BUCKET="s3-bucket-loki-$(generate_random_suffix)"
LOKI_SECRET_NAMESPACE=openshift-logging
TEMPO_BUCKET="s3-bucket-tempo-$(generate_random_suffix)"
TEMPO_SECRET_NAMESPACE=openshift-tempo
DEPLOY_GENERATOR_APPS=true
#####################################
## Do not modify anything from this line
#####################################
# Print environment variables
echo -e "\n=============="
echo -e "ENVIRONMENT VARIABLES:"
echo -e " * LOKI_BUCKET: $LOKI_BUCKET"
echo -e " * LOKI_SECRET_NAMESPACE: $LOKI_SECRET_NAMESPACE"
echo -e " * TEMPO_BUCKET: $TEMPO_BUCKET"
echo -e " * TEMPO_SECRET_NAMESPACE: $TEMPO_SECRET_NAMESPACE"
echo -e "==============\n"
# Check if the user is logged in
if ! oc whoami &> /dev/null; then
echo -e "Checked. You are not logged in. Please log in and run the script again."
exit 1
else
echo -e "Checked. You are correctly logged in. Continue..."
if ! oc project &> /dev/null; then
echo -e "Current project does not exist, moving to project Default."
oc project default
fi
fi
# Check if aws cli is installed
if ! which aws &> /dev/null; then
echo "You need the AWS CLI to run this Quickstart, please, refer to the official documentation:"
echo -e "\thttps://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"
exit 1
else
echo -e "Checked. You have aws cli installed. Continue..."
fi
# Label Infra nodes
echo -e "\nLabel all worker nodes for simplicity. Not for production use"
for node in $(oc get nodes -l node-role.kubernetes.io/worker -o name); do
oc label $node node-role.kubernetes.io/infra=
done
echo -e "\n=================="
echo -e "= LOGGING ="
echo -e "==================\n"
# Create the Logging Bucket Secret
echo -e "Create the Logging Bucket and Secret"
# Create an AWS S3 Bucket to store logs
./prerequisites/aws-create-bucket.sh $LOKI_BUCKET
# Check if the Loki secret exists in the specified namespace
if ! oc get secret s3-bucket-loki -n $LOKI_SECRET_NAMESPACE &>/dev/null; then
echo "Secret 's3-bucket-loki' not found in namespace '$LOKI_SECRET_NAMESPACE'. Creating it now..."
oc process -f prerequisites/aws-s3-secret-loki.yaml \
--param-file aws-env-vars --ignore-unknown-parameters=true \
-p SECRET_NAMESPACE=$LOKI_SECRET_NAMESPACE \
-p SECRET_NAME="s3-bucket-loki" \
-p AWS_S3_BUCKET=$LOKI_BUCKET | oc apply -f -
else
echo "Secret 's3-bucket-loki' already exists in namespace '$LOKI_SECRET_NAMESPACE'. Skipping creation."
fi
echo -e "\n=================="
echo -e "= TRACING ="
echo -e "==================\n"
echo -e "Create the Tempo Bucket and Secret"
# Create an AWS S3 Bucket to store traces
./prerequisites/aws-create-bucket.sh $TEMPO_BUCKET
# Check if the secret exists in the specified namespace
if ! oc get secret s3-bucket-tempo -n $TEMPO_SECRET_NAMESPACE &>/dev/null; then
echo "Secret 's3-bucket-tempo' not found in namespace '$TEMPO_SECRET_NAMESPACE'. Creating it now..."
oc process -f prerequisites/aws-s3-secret-tempo.yaml \
--param-file aws-env-vars --ignore-unknown-parameters=true \
-p SECRET_NAMESPACE=$TEMPO_SECRET_NAMESPACE \
-p SECRET_NAME="s3-bucket-tempo" \
-p AWS_S3_BUCKET=$TEMPO_BUCKET | oc apply -f -
else
echo "Secret 's3-bucket-tempo' already exists in namespace '$TEMPO_SECRET_NAMESPACE'. Skipping creation."
fi
if [[ "$DEPLOY_GENERATOR_APPS" =~ ^([Tt]rue|[Yy]es|[1])$ ]]; then
oc apply -f application-ocp-dist-tracing-gen.yaml
fi
echo -e "\n=================="
echo -e "= INFRA ALERTING ="
echo -e "==================\n"
if [ -f ./gmail-app-vars ]; then
# Create the Quarkus Obs Alerting Pass
echo -e "Create the Quarkus Obs Alerting Pass"
source ./gmail-app-vars
SECRET_NAMESPACE=quarkus-observability
# Check if the alert routing secret exists in the specified namespace
if ! oc get secret alert-routing-to-mail -n $SECRET_NAMESPACE &>/dev/null; then
echo "Secret 'alert-routing-to-mail' not found in namespace '$SECRET_NAMESPACE'. Creating it now..."
oc process -f prerequisites/secret-alert-routing-to-mail.yaml \
-p SECRET_NAMESPACE=$SECRET_NAMESPACE \
-p SECRET_NAME="alert-routing-to-mail" \
-p AUTH_PASSWORD=$GMAIL_PASSWORD | oc apply -f -
else
echo "Secret 'alert-routing-to-mail' already exists in namespace '$SECRET_NAMESPACE'. Skipping creation."
fi
else
echo -e "\The file with Gmail vars is missing. Skipping creation of the Alerts secret"
fi
echo -e "\n======================="
echo -e "= CONSOLELINKS ="
echo -e "=======================\n"
ROUTE_SUFIX=$(oc get route console -n openshift-console -o jsonpath='{.spec.host}' | sed 's/^console-openshift-console\.//')
# Create the ConsoleLink to Grafana
oc process -f prerequisites/consolelink.yaml \
-p NAME=openshift-tempo-tempo \
-p SPEC_HREF="https://tempo-tempo-gateway-openshift-tempo.$ROUTE_SUFIX/dev" \
-p SPEC_TEXT="Jaeger UI - Dev" \
-p SECTION="Observability" \
-p IMAGE_URL="https://api.nuget.org/v3-flatcontainer/jaeger/1.0.3/icon" | oc apply -f -
# Create the ConsoleLink to Tempo
oc process -f prerequisites/consolelink.yaml \
-p NAME=grafana-grafana \
-p SPEC_HREF="https://grafana-route-grafana.$ROUTE_SUFIX" \
-p SPEC_TEXT="Grafana" \
-p SECTION="Observability" \
-p IMAGE_URL="https://img.icons8.com/fluency/256/grafana.png" | oc apply -f -
echo -e "\n=================="
echo -e "= GITOPS ="
echo -e "==================\n"
echo -e "Trigger the app of apps creation"
oc apply -f app-of-apps.yaml