-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06-storage-up
executable file
·197 lines (181 loc) · 7.69 KB
/
06-storage-up
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
# Copyright 2017 Charter DNA Team (CTEC).
#
# 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
#
# http://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.
#
### Declare colors to use during the running of this script:
declare -r GREEN="\033[0;32m"
declare -r RED="\033[0;31m"
declare -r YELLOW="\033[0;33m"
function echo_green {
echo -e "${GREEN}$1"; tput sgr0
}
function echo_red {
echo -e "${RED}$1"; tput sgr0
}
function echo_yellow {
echo -e "${YELLOW}$1"; tput sgr0
}
### PREPARE THE ENVIRONMENT:
source /opt/demo/.bootkube_env
echo_yellow "\nVariables used during the storage deployment:"
printf "HOST_SUB_CIDR: ${HOST_SUB_CIDR}
CEPH_CLUSTER_NETWORK: ${CEPH_CLUSTER_NETWORK}
CEPH_PUBLIC_NETWORK: ${CEPH_PUBLIC_NETWORK} \n \n"
### APPLY DEVELOPMENT RBAC POLICY:
echo_yellow "\nReplacing RBAC policies for OpenStack-Helm. WARNING: SECURITY RISK!!!"
kubectl replace -f /opt/demo/deploy-rbac/demo.yaml
### PREPARE DEPENDENCIES:
echo_yellow "\nInstalling Ceph host-level prerequisites:"
pkg="python-minimal ceph-common"
for pkg in $pkg; do
if sudo dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
echo -e "${pkg} is already installed"
else
sudo apt-get update && sudo apt-get -qq install ${pkg}
echo "Successfully installed ${pkg}"
fi
done
### LABEL THE NODES:
echo_yellow "\nLabeling the nodes for the following: openstack-control-plane, ceph-mon, ceph-osd, ceph-mds, ceph-rgw"
kubectl label nodes openstack-control-plane=enabled --all --overwrite=true
kubectl label nodes ceph-mon=enabled --all --overwrite=true
kubectl label nodes ceph-osd=enabled --all --overwrite=true
kubectl label nodes ceph-mds=enabled --all --overwrite=true
kubectl label nodes ceph-rgw=enabled --all --overwrite=true
### BRING UP CEPH STORAGE:
echo_yellow "\nInstalling the Ceph Helm chart into the ceph namespace:"
helm install --namespace=ceph $HELM_REPO/ceph --name=ceph \
--set endpoints.identity.namespace=openstack \
--set endpoints.object_store.namespace=ceph \
--set endpoints.ceph_mon.namespace=ceph \
--set ceph.rgw_keystone_auth=$CEPH_RGW_KEYSTONE_ENABLED \
--set network.public=$CEPH_PUBLIC_NETWORK \
--set network.cluster=$CEPH_CLUSTER_NETWORK \
--set deployment.storage_secrets=true \
--set deployment.ceph=true \
--set deployment.rbd_provisioner=true \
--set deployment.client_secrets=false \
--set deployment.rgw_keystone_user_and_endpoints=false \
--set conf.ceph.config.global.osd_pool_default_pg_num=16 \
--set conf.ceph.config.global.osd_pool_default_pgp_num=16 \
--set bootstrap.enabled=true
### RUN VARIOUS CEPH CHECKS BEFORE CONTINUING:
echo -e -n "Waiting for all Ceph Monitors to be in a running state..."
while true; do
running_count=$(sudo kubectl --kubeconfig=/etc/kubernetes/kubeconfig get pods -n ceph --no-headers 2>/dev/null | grep "1/1" | grep "ceph-mon" | wc -l)
### Expect all components to be out of a "ContainerCreating" state before collecting log data (this includes CrashLoopBackOff states):
if [ "$running_count" -ge 2 ]; then
break
fi
echo -n "."
sleep 1
done
echo_green "SUCCESS"
echo_green "CEPH MONITORS READY!"
echo ""
echo -e -n "Waiting for all Ceph OSDs to be in a running state..."
while true; do
running_count=$(sudo kubectl --kubeconfig=/etc/kubernetes/kubeconfig get pods -n ceph --no-headers 2>/dev/null | grep "1/1" | grep "ceph-osd" | wc -l)
### Expect all components to be out of a "ContainerCreating" state before collecting log data (this includes CrashLoopBackOff states):
if [ "$running_count" -ge 1 ]; then
break
fi
echo -n "."
sleep 1
done
echo_green "SUCCESS"
echo_green "CEPH OSDs READY!"
echo ""
echo -e -n "Waiting for all Ceph RADOS Gateway to be in a running state..."
while true; do
running_count=$(sudo kubectl --kubeconfig=/etc/kubernetes/kubeconfig get pods -n ceph --no-headers 2>/dev/null | grep "1/1" | grep "ceph-rgw" | wc -l)
### Expect all components to be out of a "ContainerCreating" state before collecting log data (this includes CrashLoopBackOff states):
if [ "$running_count" -ge 1 ]; then
break
fi
echo -n "."
sleep 1
done
echo_green "SUCCESS"
echo_green "CEPH RGW READY!"
echo ""
### INSTALL CEPH KEYS:
echo_yellow "\nActivating the openstack namespace for Ceph storage:"
helm install --namespace=openstack $HELM_REPO/ceph --name=ceph-openstack-config \
--set endpoints.identity.namespace=openstack \
--set endpoints.object_store.namespace=ceph \
--set endpoints.ceph_mon.namespace=ceph \
--set ceph.rgw_keystone_auth=$CEPH_RGW_KEYSTONE_ENABLED \
--set network.public=$CEPH_PUBLIC_NETWORK \
--set network.cluster=$CEPH_CLUSTER_NETWORK \
--set deployment.storage_secrets=false \
--set deployment.ceph=false \
--set deployment.rbd_provisioner=false \
--set deployment.client_secrets=true \
--set deployment.rgw_keystone_user_and_endpoints=false
echo -e -n "Waiting for all Ceph Keys to be activated in the openstack namespace..."
while true; do
running_count=$(sudo kubectl --kubeconfig=/etc/kubernetes/kubeconfig get pods -n ceph --no-headers 2>/dev/null | grep "Running" | grep "ceph" | wc -l)
### Expect all components to be out of a "ContainerCreating" state before collecting log data (this includes CrashLoopBackOff states):
if [ "$running_count" -ge 6 ]; then
break
fi
echo -n "."
sleep 1
done
echo_green "SUCCESS"
echo_green "OPENSTACK CEPH STORAGE READY!"
echo ""
echo_yellow "\nActivating the monitoring namespace for Ceph storage:"
helm install --namespace=monitoring $HELM_REPO/ceph --name=ceph-monitoring-config \
--set endpoints.identity.namespace=openstack \
--set endpoints.object_store.namespace=ceph \
--set endpoints.ceph_mon.namespace=ceph \
--set ceph.rgw_keystone_auth=$CEPH_RGW_KEYSTONE_ENABLED \
--set network.public=$CEPH_PUBLIC_NETWORK \
--set network.cluster=$CEPH_CLUSTER_NETWORK \
--set deployment.storage_secrets=false \
--set deployment.ceph=false \
--set deployment.rbd_provisioner=false \
--set deployment.client_secrets=true \
--set deployment.rgw_keystone_user_and_endpoints=false
echo -e -n "Waiting for all Ceph Keys to be activated in the monitoring namespace..."
while true; do
running_count=$(sudo kubectl --kubeconfig=/etc/kubernetes/kubeconfig get pods -n ceph --no-headers 2>/dev/null | grep "Running" | grep "ceph" | wc -l)
### Expect all components to be out of a "ContainerCreating" state before collecting log data (this includes CrashLoopBackOff states):
if [ "$running_count" -ge 6 ]; then
break
fi
echo -n "."
sleep 1
done
echo_green "SUCCESS"
echo_green "MONITORING CEPH STORAGE READY!"
echo ""
echo -e -n "Deploying NFS default storageclass to default namespace for dynamic provisioning..."
helm install --name default-nfs --set storageclass.name=default local/nfs-provisioner
while true; do
running_count=$(sudo kubectl --kubeconfig=/etc/kubernetes/kubeconfig get pods -n default --no-headers 2>/dev/null | grep "Running" | grep "nfs-provisioner" | wc -l)
### Expect all components to be out of a "ContainerCreating" state before collecting log data (this includes CrashLoopBackOff states):
if [ "$running_count" -ge 1 ]; then
break
fi
echo -n "."
sleep 1
done
echo_green "SUCCESS"
echo_green "DEFAULT NFS STORAGE READY!"
echo ""
kubectl patch storageclass default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
exit