Skip to content

Commit 9b8a2d2

Browse files
author
Simon Emms
committed
[kots]: add database to preflight checks
1 parent 612041c commit 9b8a2d2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

install/kots/manifests/kots-preflight.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@ metadata:
77
name: gitpod
88
spec:
99
collectors:
10+
- run:
11+
collectorName: database
12+
image: bitnami/mysql:5.7
13+
name: database
14+
command:
15+
- /bin/bash
16+
- -c
17+
args:
18+
- |
19+
set -e
20+
21+
if [ '{{repl (ConfigOptionEquals "db_incluster" "1") }}' = "true" ]; then
22+
# In cluster database
23+
echo "pass"
24+
exit 0
25+
elif [ '{{repl and (ConfigOptionEquals "db_incluster" "0") (ConfigOptionEquals "db_cloudsql_enabled" "0") }}' = "true" ]; then
26+
# External database - suppress CLI output
27+
result=$(mysql \
28+
--connect-timeout=5 \
29+
--user="{{repl ConfigOption "db_username" }}" \
30+
--password="{{repl ConfigOption "db_password" }}" \
31+
--host="{{repl ConfigOption "db_host" }}" \
32+
--port="{{repl ConfigOption "db_port" }}" \
33+
--execute="SELECT 1 + 1")
34+
35+
echo "pass"
36+
exit 0
37+
fi
1038
- run:
1139
collectorName: "kernel"
1240
image: alpine/semver
@@ -151,3 +179,13 @@ spec:
151179
message: No default storage class found
152180
- pass:
153181
message: Default storage class found
182+
- textAnalyze:
183+
checkName: Database connection is valid
184+
fileName: database/database.log
185+
regex: pass
186+
outcomes:
187+
- pass:
188+
when: "true"
189+
message: Database connection is valid
190+
- fail:
191+
message: Database connection is invalid. Please check your settings and that the database is accessible from your cluster

0 commit comments

Comments
 (0)