-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-plan-new-deploy.sh
executable file
·135 lines (112 loc) · 3.97 KB
/
1-plan-new-deploy.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
#!/bin/bash
#KUBECONFIG=/root/ostest-working/kubeconfig
usage() {
echo "Usage: $0 [-h] [-d] path_to_install_yamls"
echo " -h Display this help message"
echo " -d Enable debug mode"
echo " path_to_install_yamls path to install_yamls"
}
while getopts "dh" opt; do
case ${opt} in
d)
set -x
;;
h)
usage
exit 0
;;
\?)
echo "Invalid Option: -$OPTARG" 1>&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ "$#" -ne 1 ]; then
usage
exit 1
fi
install_yaml_dir=$(realpath "$1")
# shellcheck source=common.sh
. common.sh
# sets project
. common-ospdo.sh
echo "Remove OSPdO NNCPs from the other two nodes which are not running the controller VM"
for i in br-ctlplane br-ex br-osp; do
oc patch -n "$OSPDO_NAMESPACE" osnetconfig openstacknetconfig --type json -p '[{"op": "replace", "path": "/spec/attachConfigurations/'$i'/nodeNetworkConfigurationPolicy/nodeSelector", "value": {"kubernetes.io/hostname": "'"$CONTROLLER_NODE"'"} } ]'
done
# Get the names of the other two nodes that we will use for NG
NG_NODES=$(oc get nodes -o name -l kubernetes.io/hostname!="$CONTROLLER_NODE" | sed 's#node/##g' | tr '\n' ' ')
OSP18_NODE1=$(echo "${NG_NODES}" | cut -d ' ' -f 1)
export OSP18_NODE1
OSP18_NODE2=$(echo "${NG_NODES}" | cut -d ' ' -f 2)
export OSP18_NODE2
OSP18_NODE3=$(echo "${NG_NODES}" | cut -d ' ' -f 3)
export OSP18_NODE3
echo "Label nodes..."
oc label nodes "${OSP18_NODE1}" type=openstack || {
echo "Failed to label node1"
exit 1
}
oc label nodes "${OSP18_NODE2}" type=openstack || {
echo "Failed to label node2"
exit 1
}
oc get namespace ${OSP18_NAMESPACE} 2>/dev/null || {
oc create namespace ${OSP18_NAMESPACE} || {
echo "Failed to create namespace ${OSP18_NAMESPACE}"
exit 1
}
}
echo "Apply nncp..."
# create and apply custom NNCPs for OSP 18
# the NNCPs should obey the labels applied above
envsubst <yamls/node1-nncp.yaml | oc apply -f - || {
echo "Failed to set apply node1-nncp.yaml"
exit 1
}
envsubst <yamls/node2-nncp.yaml | oc apply -f - || {
echo "Failed to set apply node2-nncp.yaml"
exit 1
}
echo "Apply NetworkAttachmentDefinition"
envsubst <yamls/nads.yaml | oc apply -f - || {
echo "Failed to apply net-attach-defs..."
exit 1
}
# Install the OSP 18 operators
(cd "$install_yaml_dir" || exit && BMO_SETUP=false NETWORK_ISOLATION=false NAMESPACE="$OSP18_NAMESPACE" make openstack)
# install_yaml doesn't install metallb with the above parameters
# install it now
if [ "$(oc get pod -n $OSPDO_NAMESPACE --no-headers=true -l component=speaker -n metallb-system | wc -l)" -ne 3 ]; then
# Install metallb
(cd "$install_yaml_dir" || exit && BMO_SETUP=false NETWORK_ISOLATION=false make metallb)
fi
# Make sure OVNKubernetes IPForwarding is enabled
oc patch network.operator cluster -n $OSPDO_NAMESPACE -p '{"spec":{"defaultNetwork":{"ovnKubernetesConfig":{"gatewayConfig":{"ipForwarding": "Global"}}}}}' --type=merge || {
echo "Failed to patch network.operator"
exit 1
}
envsubst <yamls/ipaddresspools.yaml | oc apply -f - || {
echo "Failed to apply ipaddresspool"
exit 1
}
envsubst <yamls/l2advertisement.yaml | oc apply -f - || {
echo "Failed to apply l2advertisement"
exit 1
}
envsubst <yamls/netconfig.yaml | oc apply -f - || {
echo "Failed to apply netconfig"
exit 1
}
# Extract passwords from OSPdO
oc get secret tripleo-passwords -n $OSPDO_NAMESPACE -o json | jq -r '.data["tripleo-overcloud-passwords.yaml"]' | base64 -d >"${PASSWORD_FILE}" || {
echo "ERROR: Failed to extract passwords from OSPdO"
exit 1
}
# oc rsh openstackclient cat ./home/cloud-admin/.config/openstack/clouds.yaml
# oc run mariadb-client -q --image ${MARIADB_IMAGE}\
# -it --rm --restart=Never --overrides="$RUN_OVERRIDES" /bin/bash
# -it --rm --restart=Never --overrides="$RUN_OVERRIDES" /bin/bash
# permissions were wrong on the rabbitmq-cell1 pods mnesia folder for some reason
# changing the permission caused it to work