forked from GoogleCloudPlatform/gke-cloud-sql-postgres-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.sh
executable file
·61 lines (52 loc) · 1.85 KB
/
validate.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
#!/bin/bash -e
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script is to make sure that the create script ran correctly. It will
# make sure the Cloud SQL instance is up, as well as the GKE cluster and pod
ROOT=$(dirname "${BASH_SOURCE[0]}")
# shellcheck disable=SC1090
source "${ROOT}"/scripts/constants.sh
help() {
echo "./validate.sh INSTANCE_NAME"
}
if [ -z "$CLUSTER_ZONE" ]; then
echo "Make sure that compute/zone is set in gcloud config"
exit 1
fi
INSTANCE_NAME=$(cat "${ROOT}"/.instance)
export INSTANCE_NAME
if [ -z "$INSTANCE_NAME" ] ; then
help
exit 1
fi
if ! gcloud sql instances describe "$INSTANCE_NAME" > /dev/null; then
echo "FAIL: Cloud SQL instance does not exist"
else
echo "Cloud SQL instance exists"
fi
if ! gcloud container clusters describe \
"$CLUSTER_NAME" --zone "$CLUSTER_ZONE" > /dev/null; then
echo "FAIL: GKE cluster does not exist"
else
echo "GKE cluster exists"
fi
# You can look for Kubernetes objects in a variety of ways.
# This method involves giving the 'get' command the same manifest used to
# create the object. It will find an object matching
# the description in the manifest
if ! kubectl --namespace default get -f "$ROOT"/manifests/pgadmin-deployment.yaml > /dev/null; then
echo "FAIL: pgAdmin4 Deployment object does not exist"
else
echo "pgAdmin4 Deployment object exists"
fi