-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy-drupal.sh
114 lines (91 loc) · 3.41 KB
/
deploy-drupal.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
#!/bin/bash
set -e
echo === Deploy Drupal and MySQL ===
echo Set the name of the new site:
read sitename
echo Your new Drupal site name is $sitename
echo Set the port of the new site:
read port
echo Your Drupal PORT is $port
echo Generating random MySQL Password
password=$(openssl rand -base64 16)
echo Starting deploy Drupal instance...
sleep 3
echo ==== Deploy MYSQL Instance Namespace ====
if cat mysql/namespace.yml | sed "s/{{sitename}}/$sitename/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ==== Deploy MYSQL Instance Secrets ====
if cat mysql/secret.yml | sed "s/{{sitename}}/$sitename/g" | sed "s/{{password}}/$password/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ==== Deploy MYSQL Instance Storage ====
if cat mysql/storage.yml | sed "s/{{sitename}}/$sitename/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ==== Deploy MYSQL Instance Service ====
if cat mysql/service.yml | sed "s/{{sitename}}/$sitename/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ==== Deploy MYSQL Instance Deployment ====
if cat mysql/deployment.yml | sed "s/{{sitename}}/$sitename/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ===== Starting Drupal Deployment =====
echo ===== Deploy Namespace =====
if cat drupal/namespace.yml | sed "s/{{sitename}}/$sitename/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ==== Deploy Storage ====
if cat drupal/storage.yml | sed "s/{{sitename}}/$sitename/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ==== Deploy Service ====
if cat drupal/service.yml | sed "s/{{sitename}}/$sitename/g" | sed "s/{{port}}/$port/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
sleep 3
echo ==== Final Deployment ====
if cat drupal/deployment.yml | sed "s/{{sitename}}/$sitename/g" | microk8s.kubectl apply -f -; then
echo “Success”
else
echo “Failure, exit status: $?”
fi
echo Checking current deployment information
microk8s.kubectl get pod -n $sitename -o wide
microk8s.kubectl get svc -n $sitename -o wide
microk8s.kubectl get pvc -n $sitename -o wide
echo ===== DATABASE INFORMATION FOR DRUPAL SETUP =====
DATABASE_NAME=$(microk8s.kubectl get deploy $sitename-mysql -n $sitename -o jsonpath='{.spec.template.spec.containers[*].env[1].value}')
MYSQL_PASSWORD=$(microk8s.kubectl get secret $sitename-mysql-secret -n $sitename -o jsonpath='{.data.password}' | base64 -d)
SERVICE_HOST_NAME=$(microk8s.kubectl get svc -n $sitename -o jsonpath='{.items[0].metadata.name}')
MYSQL_PORT=$(microk8s.kubectl get svc $sitename-mysql-service -n $sitename -o jsonpath='{.spec.ports[*].port}')
#IF Use password with clear text: MYSQL_PASSWORD=$(microk8s.kubectl get deploy $sitename-mysql -n $sitename -o jsonpath='{.spec.template.spec.containers[*].env[0].value}')
echo Database Name is : $DATABASE_NAME
echo Database username is : root
echo Password is : $MYSQL_PASSWORD
echo Host MySQL is : $SERVICE_HOST_NAME
echo MySQL Port is : $MYSQL_PORT