Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 1 | #!/bin/bash |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2 | # Copyright 2019 Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # trap ctrl-c and call ctrl_c() |
| 17 | trap ctrl_c INT |
| 18 | |
| 19 | function ctrl_c() { |
| 20 | tput cnorm |
| 21 | echo "" |
| 22 | echo "ctrl-c trapped" |
| 23 | echo "Thank you for trying 'votlha up'" |
| 24 | exit |
| 25 | } |
| 26 | |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 27 | VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev} |
| 28 | KIND_VERSION=${KIND_VERSION:-v0.4.0} |
| 29 | _VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g') |
| 30 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 31 | TYPE=${TYPE:-minimal} |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 32 | |
| 33 | if [ "$TYPE" == "full" ]; then |
| 34 | ONOS_API_PORT=${ONOS_API_PORT:-8182} |
| 35 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102} |
| 36 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556} |
| 37 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023} |
| 38 | else |
| 39 | ONOS_API_PORT=${ONOS_API_PORT:-8181} |
| 40 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101} |
| 41 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555} |
| 42 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022} |
| 43 | fi |
| 44 | |
| 45 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
| 46 | echo "$HOME/.volt/config-$TYPE" |
| 47 | exit |
| 48 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 49 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 50 | if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then |
| 51 | >&2 echo "up or down?" |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | if [ "$1" == "down" ]; then |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 56 | if [ -x ./bin/kind ]; then |
| 57 | exec ./bin/kind delete cluster --name voltha-$TYPE |
| 58 | else |
| 59 | >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye." |
| 60 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 61 | exit |
| 62 | fi |
| 63 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 64 | LOG="install-$TYPE.log" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 65 | date > $LOG |
| 66 | |
| 67 | spin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 68 | PARTS="\ |
| 69 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 70 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 71 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 72 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 73 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 74 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 75 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 76 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 77 | " |
| 78 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 79 | tput civis |
| 80 | while true; do |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 81 | C=$(echo $PARTS | cut '-d ' -f $IDX) |
| 82 | echo -en "$C" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 83 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 84 | if [ $IDX -gt 8 ]; then |
| 85 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 86 | fi |
| 87 | sleep .15 |
| 88 | echo -en "\r" |
| 89 | done |
| 90 | } |
| 91 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 92 | SPIN_PARTS="\ |
| 93 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 94 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 95 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 96 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 97 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 98 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 99 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 100 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 101 | " |
| 102 | IDX=1 |
| 103 | NOT_VERIFIED="\xe2\x9c\x97\x20" |
| 104 | VERIFIED="\xe2\x9c\x93\x20" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 105 | HELM="\xE2\x8E\x88" |
| 106 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 107 | BIRD="\xF0\x9F\x90\xA6" |
| 108 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 109 | PLUG="\xF0\x9F\xa7\xa9" |
| 110 | RESTART="\xf0\x9f\x94\x84" |
| 111 | FORWARD="\xE2\x87\xA8" |
| 112 | INSTALL="\xF0\x9F\x8F\x97" |
| 113 | STOP="\xf0\x9f\x9b\x91" |
| 114 | GO="\xf0\x9f\x9a\x80" |
| 115 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 116 | GEAR="\xe2\x9a\x99" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 117 | bspin() { |
| 118 | tput civis |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 119 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 120 | local INDENT= |
| 121 | if [ "$1" == "-" ]; then |
| 122 | INDENT=" " |
| 123 | shift |
| 124 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 125 | echo -en "$INDENT $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | sspin() { |
| 129 | local INDENT= |
| 130 | if [ "$1" == "-" ]; then |
| 131 | INDENT=" " |
| 132 | shift |
| 133 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 134 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 135 | echo -en "\r$INDENT$C $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 136 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 137 | if [ $IDX -gt 8 ]; then |
| 138 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 139 | fi |
| 140 | } |
| 141 | |
| 142 | espin() { |
| 143 | local INDENT= |
| 144 | if [ "$1" == "-" ]; then |
| 145 | INDENT=" " |
| 146 | shift |
| 147 | fi |
| 148 | echo -e "\r$INDENT$*" |
| 149 | tput cnorm |
| 150 | } |
| 151 | |
| 152 | count_pods() { |
| 153 | local NAMESPACE=$1; shift |
| 154 | local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
| 155 | local COUNT=0 |
| 156 | local PATTERNS=$* |
| 157 | for POD in $PODS; do |
| 158 | local NAME=$(echo $POD | cut -d/ -f 1) |
| 159 | local STATE=$(echo $POD | cut -d/ -f 2) |
| 160 | local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g') |
| 161 | if [ "$STATE" == "Running" ]; then |
| 162 | local TOTAL=$(echo $CONTAINERS | wc -w) |
| 163 | local FOUND=$(echo $CONTAINERS | grep -o true | wc -l) |
| 164 | if [ $TOTAL -eq $FOUND ]; then |
| 165 | for PATTERN in $PATTERNS; do |
| 166 | if [[ $NAME =~ $PATTERN ]]; then |
| 167 | COUNT=$(expr $COUNT + 1) |
| 168 | fi |
| 169 | done |
| 170 | fi |
| 171 | fi |
| 172 | done |
| 173 | echo $COUNT |
| 174 | } |
| 175 | |
| 176 | wait_for_pods() { |
| 177 | local INDENT= |
| 178 | if [ "$1" == "-" ]; then |
| 179 | INDENT=$1; shift |
| 180 | fi |
| 181 | local NAMESPACE=$1; shift |
| 182 | local EXPECT=$1; shift |
| 183 | local RETRY=$1; shift |
| 184 | local MESSAGE=$1; shift |
| 185 | local PATTERNS=$* |
| 186 | local HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 187 | COUNT=$(expr 300 / 15) |
| 188 | bspin $INDENT $MESSAGE |
| 189 | sspin $INDENT |
| 190 | if [ $HAVE -ne $EXPECT ]; then |
| 191 | while [ $HAVE -ne $EXPECT ]; do |
| 192 | sspin $INDENT |
| 193 | COUNT=$(expr $COUNT - 1) |
| 194 | if [ $COUNT -eq 0 ]; then |
| 195 | HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 196 | COUNT=$(expr 300 / 15) |
| 197 | fi |
| 198 | sleep .15 |
| 199 | done |
| 200 | fi |
| 201 | espin $INDENT $VERIFIED |
| 202 | if [ $HAVE -ne $EXPECT ]; then |
| 203 | return 1 |
| 204 | fi |
| 205 | return 0 |
| 206 | } |
| 207 | |
| 208 | helm_install() { |
| 209 | local INDENT= |
| 210 | if [ "$1" == "-" ]; then |
| 211 | INDENT=$1; shift |
| 212 | fi |
| 213 | local NAMESPACE=$1; shift |
| 214 | local NAME=$1; shift |
| 215 | local CHART=$1; shift |
| 216 | local MESSAGE=$* |
| 217 | |
| 218 | COUNT=$(expr 300 / 15) |
| 219 | bspin $INDENT $MESSAGE |
| 220 | (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
| 221 | SUCCESS=$? |
| 222 | while [ $SUCCESS -ne 0 ]; do |
| 223 | sspin $INDENT |
| 224 | COUNT=$(expr $COUNT - 1) |
| 225 | if [ $COUNT -eq 0 ]; then |
| 226 | (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
| 227 | COUNT=$(expr 300 / 15) |
| 228 | fi |
| 229 | sleep .15 |
| 230 | done |
| 231 | espin $INDENT $VERIFIED |
| 232 | } |
| 233 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 234 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 235 | |
| 236 | bspin "Verify GOPATH" |
| 237 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 238 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 239 | espin $VERIFIED |
| 240 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 241 | bspin "Verify kubectl $HELM" |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 242 | if [ -x $GOPATH/bin/kubectl ]; then |
| 243 | espin $VERIFIED |
| 244 | else |
| 245 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 246 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 247 | (set -x; curl -o $GOPATH/bin/kubectl -sSL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(go env GOHOSTOS)/$(go env GOARCH)/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 248 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 249 | espin - $VERIFIED |
| 250 | fi |
| 251 | |
| 252 | # Unclear if kubeadm is required. Leave out for now |
| 253 | #bspin "Verify Kubernetes/kubectl" |
| 254 | #if [ -x $GOPATH/bin/kubeadm ]; then |
| 255 | # espin $VERIFIED |
| 256 | #else |
| 257 | # espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 258 | # bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 259 | # (set -x; curl -o $GOPATH/bin/kubeadm -sSL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(go env GOHOSTOS)/$(go env GOARCH)/kubeadm >>$LOG 2>&1) >>$LOG 2>&1 |
| 260 | # (set -x; chmod 755 $GOPATH/bin/kubeadm >>$LOG 2>&1) >>$LOG 2>&1 |
| 261 | # espin - $VERIFIED |
| 262 | #fi |
| 263 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 264 | bspin "Verify Kubernetes/Kind $HELM" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 265 | if [ -x $GOPATH/bin/kind ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 266 | espin $VERIFIED |
| 267 | else |
| 268 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 269 | bspin - "Download and install Kubernetes/kind $DOWNLOAD" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 270 | (set -x; curl -o $GOPATH/bin/kind -sSL https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$(go env GOHOSTOS)-$(go env GOARCH) >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 7c2be41 | 2019-07-03 06:20:30 +0000 | [diff] [blame] | 271 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 272 | espin - $VERIFIED |
| 273 | fi |
| 274 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 275 | bspin "Verify Helm $HELM" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 276 | if [ -x $GOPATH/bin/helm ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 277 | espin $VERIFIED |
| 278 | else |
| 279 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 280 | bspin - "Download and install Helm $DOWNLOAD" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 281 | (set -x; curl -sSL https://git.io/get_helm.sh | USE_SUDO=false HELM_INSTALL_DIR=$(go env GOPATH)/bin bash >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 282 | espin - $VERIFIED |
| 283 | fi |
| 284 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 285 | bspin "Verify voltctl $HIGH_VOLTAGE" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 286 | if [ -x $GOPATH/bin/voltctl ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 287 | espin $VERIFIED |
| 288 | else |
| 289 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 290 | bspin - "Download and build voltctl $DOWNLOAD" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 291 | (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/ciena/voltctl/releases/download/$VOLTCTL_VERSION/voltctl-$_VOLTCTL_VERSION-$(go env GOHOSTOS)-$(go env GOARCH) >>$LOG 2>&1) >>$LOG 2>&1 |
| 292 | (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 293 | espin - $VERIFIED |
| 294 | fi |
| 295 | |
| 296 | bspin "Verify command PATH" |
| 297 | export PATH=$(go env GOPATH)/bin:$PATH |
| 298 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 299 | |
| 300 | HAVE=$(kind get clusters | grep -c voltha-$TYPE) |
| 301 | bspin "Verify Kubernetes/Kind Cluster" |
| 302 | sspin |
| 303 | if [ $HAVE -eq 0 ]; then |
| 304 | espin $NOT_VERIFIED |
| 305 | kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg |
| 306 | else |
| 307 | espin $VERIFIED |
| 308 | fi |
| 309 | |
| 310 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")" |
| 311 | P="coredns-.* \ |
| 312 | etcd-voltha-$TYPE-control-plane \ |
| 313 | kindnet-.* \ |
| 314 | kube-apiserver-voltha-$TYPE-control-plane \ |
| 315 | kube-controller-manager-voltha-$TYPE-control-plane \ |
| 316 | kube-proxy-.* \ |
| 317 | kube-scheduler-voltha-$TYPE-control-plane" |
| 318 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 319 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 320 | wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 321 | |
| 322 | COUNT=$(count_pods "kube-system" "tiller-deploy-.*") |
| 323 | bspin "Verify Helm" |
| 324 | if [ $(count_pods "kube-system" "tiller-deploy-.*") -ne 1 ]; then |
| 325 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 326 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 327 | bspin - "Initialize Helm" |
| 328 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 329 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 330 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 331 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 332 | espin - $VERIFIED |
| 333 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 334 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 335 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 336 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 337 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 338 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 339 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 340 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 341 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 342 | espin - $VERIFIED |
| 343 | |
| 344 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 345 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 346 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 347 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 348 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 349 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 350 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 351 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 352 | (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>$LOG 2>&1) >>$LOG 2>&1 |
| 353 | espin - $VERIFIED |
| 354 | else |
| 355 | espin $VERIFIED |
| 356 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 357 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 358 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 359 | bspin "Verify ETCD Operator $OLD_KEY" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 360 | if [ $(helm list etcd-operator | grep -c DEPLOYED) -ne 1 ]; then |
| 361 | espin $NOT_VERIFIED |
| 362 | helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator" |
| 363 | else |
| 364 | espin $VERIFIED |
| 365 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 366 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 367 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 368 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 369 | bspin "Verify ONOS installed $BIRD" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 370 | if [ $(helm list onos | grep -c DEPLOYED) -ne 1 ]; then |
| 371 | espin $NOT_VERIFIED |
| 372 | helm_install - default onos onf/onos "Install ONOS" |
| 373 | else |
| 374 | espin $VERIFIED |
| 375 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 376 | wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 377 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 378 | bspin - "Forward ONOS API port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 379 | (set -x; screen -p 0 -X -S onos-ui-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 380 | (set -x; screen -dmS onos-ui-$TYPE kubectl port-forward service/onos-ui $ONOS_API_PORT:8181 >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 381 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 382 | bspin - "Forward ONOS SSH port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 383 | (set -x; screen -p 0 -X -S onos-ssh-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 384 | (set -x; screen -dmS onos-ssh-$TYPE kubectl port-forward service/onos-ssh $ONOS_SSH_PORT:8101 >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 385 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 386 | bspin - "Install required ONOS applications $INSTALL" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 387 | (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
| 388 | espin - $VERIFIED |
| 389 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 390 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 391 | if [ $(helm list voltha | grep -c DEPLOYED) -ne 1 ]; then |
| 392 | espin $NOT_VERIFIED |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 393 | helm_install - voltha voltha onf/voltha "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 394 | else |
| 395 | espin $VERIFIED |
| 396 | fi |
| 397 | VOLTHA="ofagent-.* \ |
| 398 | ro-core.* \ |
| 399 | rw-core.* \ |
| 400 | voltha-api-server-.* \ |
| 401 | voltha-cli-server-.* \ |
| 402 | voltha-etcd-cluster-.* \ |
| 403 | voltha-kafka-.* \ |
| 404 | voltha-zookeeper-.*" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 405 | EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 406 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 407 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 408 | echo -e "Verify Adapters $PLUG" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 409 | bspin - "Verify Simulated Adapters installed" |
| 410 | if [ $(helm list sim | grep -c DEPLOYED) -ne 1 ]; then |
| 411 | espin - $NOT_VERIFIED |
| 412 | helm_install - voltha sim onf/voltha-adapter-simulated "Install Simulated Adapters" |
| 413 | else |
| 414 | espin - $VERIFIED |
| 415 | fi |
| 416 | |
| 417 | bspin - "Verify OpenOLT Adapter installed" |
| 418 | if [ $(helm list open-olt | grep -c DEPLOYED) -ne 1 ]; then |
| 419 | espin - $NOT_VERIFIED |
| 420 | helm_install - voltha open-olt onf/voltha-adapter-openolt "Install OpenOLT Adapter" |
| 421 | else |
| 422 | espin - $VERIFIED |
| 423 | fi |
| 424 | bspin - "Verify OpenONU Adapter installed" |
| 425 | if [ $(helm list open-onu | grep -c DEPLOYED) -ne 1 ]; then |
| 426 | espin - $NOT_VERIFIED |
| 427 | helm_install - voltha open-onu onf/voltha-adapter-openonu "Install OpenONU Adapter" |
| 428 | else |
| 429 | espin - $VERIFIED |
| 430 | fi |
| 431 | |
| 432 | ADAPTERS="adapter-.*" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 433 | wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 434 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 435 | echo -e "Restart VOLTHA API $RESTART" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 436 | API="voltha-api-server-.* ofagent-.*" |
| 437 | (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 438 | wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 439 | (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 440 | wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 441 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 442 | bspin - "Forward VOLTHA API port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 443 | (set -x; screen -p 0 -X -S voltha-api-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 444 | (set -x; screen -dmS voltha-api-$TYPE kubectl port-forward -n voltha service/voltha-api $VOLTHA_API_PORT:55555 >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 445 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 446 | bspin - "Forward VOLTHA SSH port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 447 | (set -x; screen -p 0 -X -S voltha-ssh-$TYPE stuff $'\003' 2>/dev/null >/dev/null >>$LOG 2>&1) >>$LOG 2>&1 |
| 448 | (set -x; screen -dmS voltha-ssh-$TYPE kubectl port-forward -n voltha service/voltha-cli $VOLTHA_SSH_PORT:5022 >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 449 | espin - $VERIFIED |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 450 | |
| 451 | bspin - "Create voltctl configuration file" |
| 452 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 453 | (set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$TYPE 2>>$LOG) >>$LOG 2>&1 |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 454 | espin - $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 455 | |
| 456 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 457 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 458 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 459 | echo "" | tee -a $LOG |
| 460 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG |
Test User | fa30f7f | 2019-07-03 20:35:19 +0000 | [diff] [blame] | 461 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 462 | echo 'export PATH=$GOPATH/bin:$PATH' | tee -a $LOG |
| 463 | echo "" | tee -a $LOG |
| 464 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 465 | |