Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | SHELL := /bin/bash |
| 16 | BUILD ?= /tmp |
| 17 | M ?= $(BUILD)/milestones |
| 18 | MYDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) |
| 19 | |
| 20 | HELM_VERSION ?= "2.10.0" |
| 21 | HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe" |
| 22 | HELM_PLATFORM ?= "linux-amd64" |
| 23 | |
| 24 | KAFKA_CHART_VERSION ?= 0.8.8 |
| 25 | |
Gilles Depatie | 493ea24 | 2019-05-21 14:38:08 -0400 | [diff] [blame] | 26 | ponsim: $(M)/voltha-running $(M)/simtype-ponsim $(M)/voltha-simtype-running |
| 27 | bbsim: $(M)/voltha-running $(M)/simtype-bbsim $(M)/voltha-simtype-running |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 28 | |
| 29 | $(M)/setup: |
| 30 | echo "MYDIR = ${MYDIR}" |
| 31 | mkdir -p $(M) |
| 32 | sudo apt update |
| 33 | sudo apt install -y httpie jq software-properties-common |
| 34 | sudo swapoff -a |
| 35 | touch $@ |
| 36 | |
| 37 | /usr/bin/docker: | $(M)/setup |
| 38 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88 |
| 39 | sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable" |
| 40 | sudo apt update |
| 41 | sudo apt install -y "docker-ce=17.06*" |
| 42 | |
| 43 | /usr/bin/kubeadm: | $(M)/setup /usr/bin/docker |
| 44 | curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - |
| 45 | echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list |
| 46 | sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list |
| 47 | sudo apt update |
Andy Bavier | b6b5e7a | 2019-04-17 14:20:19 -0700 | [diff] [blame] | 48 | sudo apt install -y "kubeadm=1.12.7-*" "kubelet=1.12.7-*" "kubectl=1.12.7-*" |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 49 | |
| 50 | /usr/local/bin/helm: |
| 51 | curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz" |
| 52 | echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c - |
| 53 | cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm |
| 54 | sudo chmod a+x /usr/local/bin/helm |
| 55 | rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM} |
| 56 | |
| 57 | $(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm |
| 58 | sudo kubeadm init --pod-network-cidr=192.168.0.0/16 |
| 59 | mkdir -p $(HOME)/.kube |
| 60 | sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config |
| 61 | sudo chown $(id -u):$(id -g) $(HOME)/.kube/config |
Andy Bavier | b6b5e7a | 2019-04-17 14:20:19 -0700 | [diff] [blame] | 62 | kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml |
| 63 | kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 64 | kubectl taint nodes --all node-role.kubernetes.io/master- |
| 65 | touch $@ |
| 66 | |
| 67 | $(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm |
| 68 | kubectl create serviceaccount --namespace kube-system tiller |
| 69 | kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| 70 | helm init --service-account tiller |
| 71 | until helm ls >& /dev/null; \ |
| 72 | do \ |
| 73 | echo "Waiting for Helm to be ready"; \ |
| 74 | sleep 5; \ |
| 75 | done |
| 76 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 77 | touch $@ |
| 78 | |
| 79 | $(HOME)/cord/helm-charts: | $(M)/setup |
| 80 | mkdir -p $(HOME)/cord |
| 81 | cd $(HOME)/cord; git clone https://gerrit.opencord.org/helm-charts |
| 82 | |
| 83 | $(M)/kafka: | $(HOME)/cord/helm-charts $(M)/helm-init |
| 84 | cd $(HOME)/cord/helm-charts && \ |
| 85 | helm upgrade --install cord-kafka --version $(KAFKA_CHART_VERSION) -f examples/kafka-single.yaml incubator/kafka |
| 86 | touch $@ |
| 87 | |
| 88 | $(M)/kafka-running: | $(M)/kafka |
| 89 | kubectl wait pod/cord-kafka-0 --for condition=Ready --timeout=180s |
| 90 | touch $@ |
| 91 | |
| 92 | $(M)/onos: | $(M)/kafka-running |
Kailash Khalasi | 200f3df | 2018-12-13 07:12:30 -0800 | [diff] [blame] | 93 | cd $(HOME)/cord/helm-charts; helm upgrade --install onos onos -f configs/seba-ponsim.yaml --set images.onos.repository=voltha-onos,images.onos.tag=latest,images.onos.pullPolicy=Never |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 94 | touch $@ |
| 95 | |
Gilles Depatie | 23faed0 | 2018-11-22 13:53:23 -0500 | [diff] [blame] | 96 | $(M)/voltha: | $(M)/kafka-running $(M)/etcd-operator-ready $(M)/onos |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 97 | cd $(HOME)/cord/helm-charts; helm dep up voltha |
Gilles Depatie | 23faed0 | 2018-11-22 13:53:23 -0500 | [diff] [blame] | 98 | cd $(HOME)/cord/helm-charts; helm upgrade --install voltha voltha -f configs/seba-ponsim.yaml --set images.vcore.repository=voltha-voltha,images.vcore.tag=latest,images.vcore.pullPolicy=Never,images.envoy_for_etcd.repository=voltha-envoy,images.envoy_for_etcd.tag=latest,images.envoy_for_etcd.pullPolicy=Never,images.netconf.repository=voltha-netconf,images.netconf.tag=latest,images.netconf.pullPolicy=Never,images.ofagent.repository=voltha-ofagent,images.ofagent.tag=latest,images.ofagent.pullPolicy=Never,images.vcli.repository=voltha-cli,images.vcli.tag=latest,images.vcli.pullPolicy=Never |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 99 | touch $@ |
| 100 | |
Kailash | 3f4e1c0 | 2018-11-14 09:43:48 -0800 | [diff] [blame] | 101 | $(M)/etcd-operator-ready: | $(HOME)/cord/helm-charts $(M)/helm-init |
| 102 | cd $(HOME)/cord/helm-charts; helm upgrade --install etcd-operator stable/etcd-operator -f configs/seba-ponsim.yaml |
| 103 | until kubectl get crd | grep etcdclusters; \ |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 104 | do \ |
Kailash | 3f4e1c0 | 2018-11-14 09:43:48 -0800 | [diff] [blame] | 105 | echo "Waiting for etcdclusters CRD to be available"; \ |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 106 | sleep 5; \ |
| 107 | done |
| 108 | touch $@ |
| 109 | |
Kailash | 3f4e1c0 | 2018-11-14 09:43:48 -0800 | [diff] [blame] | 110 | $(M)/voltha-running: | $(M)/voltha |
| 111 | timeout 180s bash -c "until kubectl get pod|grep etcd-cluster|grep 1/1; do echo 'Waiting for etcd-cluster to be ready'; sleep 10; done" |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 112 | $(HOME)/cord/helm-charts/scripts/wait_for_pods.sh voltha |
| 113 | touch $@ |
| 114 | |
Gilles Depatie | 493ea24 | 2019-05-21 14:38:08 -0400 | [diff] [blame] | 115 | $(M)/simtype-bbsim: | $(M)/voltha-running |
Gilles Depatie | ea42371 | 2019-04-12 16:39:12 -0400 | [diff] [blame] | 116 | cd $(HOME)/cord/helm-charts; helm upgrade --install bbsim bbsim -f configs/seba-ponsim.yaml --set images.bbsim.repository=voltha/voltha-bbsim,images.bbsim.tag=latest,images.bbsim.pullPolicy=Never |
| 117 | touch $@ |
| 118 | |
Gilles Depatie | 493ea24 | 2019-05-21 14:38:08 -0400 | [diff] [blame] | 119 | $(M)/simtype-ponsim: | $(M)/voltha-running |
Andy Bavier | 7e215ed | 2019-06-12 13:26:21 -0700 | [diff] [blame] | 120 | cd $(HOME)/cord/helm-charts; helm upgrade --install ponnet ponnet |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 121 | $(HOME)/cord/helm-charts/scripts/wait_for_pods.sh kube-system |
Andy Bavier | 7e215ed | 2019-06-12 13:26:21 -0700 | [diff] [blame] | 122 | cd $(HOME)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f configs/seba-ponsim.yaml --set images.olt.repository=voltha-ponsim,images.olt.tag=latest,images.olt.pullPolicy=Never,images.onu.repository=voltha-ponsim,images.onu.tag=latest,images.onu.pullPolicy=Never,images.rg.repository=voltha-tester,images.rg.tag=latest,images.rg.pullPolicy=Never |
Andy Bavier | 86b1f48 | 2019-06-12 13:29:43 -0700 | [diff] [blame] | 123 | $(HOME)/cord/helm-charts/scripts/wait_for_pods.sh voltha |
| 124 | echo 8 > /tmp/group_fwd_mask |
| 125 | for bridge in /sys/class/net/pon*; \ |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 126 | do \ |
Andy Bavier | 86b1f48 | 2019-06-12 13:29:43 -0700 | [diff] [blame] | 127 | echo Setting up forwarding on `basename $$bridge`; \ |
| 128 | sudo cp /tmp/group_fwd_mask $$bridge/bridge/group_fwd_mask; \ |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 129 | done |
Andy Bavier | 86b1f48 | 2019-06-12 13:29:43 -0700 | [diff] [blame] | 130 | rm /tmp/group_fwd_mask |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 131 | touch $@ |
Gilles Depatie | 1be639b | 2018-12-06 10:51:08 -0500 | [diff] [blame] | 132 | |
Andy Bavier | 86b1f48 | 2019-06-12 13:29:43 -0700 | [diff] [blame] | 133 | $(M)/voltha-simtype-running: |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 134 | $(HOME)/cord/helm-charts/scripts/wait_for_pods.sh |
Gilles Depatie | 1be639b | 2018-12-06 10:51:08 -0500 | [diff] [blame] | 135 | until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \ |
| 136 | do \ |
| 137 | sleep 5; \ |
| 138 | done |
| 139 | http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535 |
| 140 | timeout 1m bash -c "until http GET http://127.0.0.1:30125/health|jq '.state'|grep -q HEALTHY; do echo 'Waiting for VOLTHA to be HEALTHY'; sleep 10; done" |
| 141 | echo "[passed] VOLTHA is HEALTHY" |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 142 | touch $@ |
| 143 | echo "Voltha Test Framework Ready!" |
| 144 | |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 145 | remove-chart-milestones: |
| 146 | cd $(M); sudo rm -f setup kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \ |
Andy Bavier | 86b1f48 | 2019-06-12 13:29:43 -0700 | [diff] [blame] | 147 | voltha-running simtype-ponsim simtype-bbsim voltha-simtype-running |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 148 | remove-kube-milestones: |
| 149 | cd $(M); sudo rm -f kubeadm helm-init |
| 150 | |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 151 | teardown-charts: remove-chart-milestones |
| 152 | helm delete --purge $(shell helm ls -q) |
| 153 | |
| 154 | reset-kubeadm: remove-chart-milestones remove-kube-milestones |
Andy Bavier | b6b5e7a | 2019-04-17 14:20:19 -0700 | [diff] [blame] | 155 | sudo kubeadm reset -f || true |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 156 | sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X |
Andy Bavier | 7e215ed | 2019-06-12 13:26:21 -0700 | [diff] [blame] | 157 | sudo rm -f /var/lib/cni/networks/pon*/* || true |
| 158 | sudo rm -f /var/lib/cni/networks/nni*/* || true |
Andy Bavier | b6b5e7a | 2019-04-17 14:20:19 -0700 | [diff] [blame] | 159 | sudo rm -f /var/lib/cni/networks/k8s-pod-network/* || true |
Andy Bavier | 86b1f48 | 2019-06-12 13:29:43 -0700 | [diff] [blame] | 160 | for br in /sys/class/net/pon*; do sudo ip link delete `basename $$br` type bridge; done || true |
| 161 | for br in /sys/class/net/nni*; do sudo ip link delete `basename $$br` type bridge; done || true |