Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 1 | SHELL := /bin/bash |
| 2 | BUILD ?= /tmp |
| 3 | M ?= $(BUILD)/milestones |
| 4 | MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) |
| 5 | WORKSPACE ?= $(HOME) |
| 6 | SEBAVALUES ?= configs/seba-ponsim.yaml |
| 7 | |
| 8 | HELM_VERSION ?= "2.10.0" |
| 9 | HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe" |
| 10 | HELM_PLATFORM ?= "linux-amd64" |
| 11 | |
| 12 | all: $(M)/siab |
| 13 | |
| 14 | $(M)/setup: |
| 15 | mkdir -p $(M) |
| 16 | sudo apt update |
| 17 | sudo apt install -y httpie jq software-properties-common |
| 18 | sudo swapoff -a |
| 19 | touch $@ |
| 20 | |
| 21 | /usr/bin/docker: | $(M)/setup |
| 22 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88 |
| 23 | sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable" |
| 24 | sudo apt update |
| 25 | sudo apt install -y "docker-ce=17.03*" |
| 26 | |
| 27 | /usr/bin/kubeadm: | $(M)/setup /usr/bin/docker |
| 28 | curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - |
| 29 | echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list |
| 30 | sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list |
| 31 | sudo apt update |
| 32 | sudo apt install -y "kubeadm=1.11.3-*" "kubelet=1.11.3-*" "kubectl=1.11.3-*" |
| 33 | |
| 34 | /usr/local/bin/helm: |
| 35 | curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz" |
| 36 | echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c - |
| 37 | cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm |
| 38 | sudo chmod a+x /usr/local/bin/helm |
| 39 | rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM} |
| 40 | |
| 41 | $(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm |
| 42 | sudo kubeadm init --pod-network-cidr=192.168.0.0/16 |
Andy Bavier | a7c6a4e | 2018-09-28 13:29:43 -0700 | [diff] [blame^] | 43 | mkdir -p $(HOME)/.kube |
| 44 | sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config |
| 45 | sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 46 | kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml |
| 47 | kubectl taint nodes --all node-role.kubernetes.io/master- |
| 48 | touch $@ |
| 49 | |
| 50 | $(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm |
| 51 | kubectl create serviceaccount --namespace kube-system tiller |
| 52 | kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| 53 | helm init --service-account tiller |
| 54 | until helm ls >& /dev/null; \ |
| 55 | do \ |
| 56 | echo "Waiting for Helm to be ready"; \ |
| 57 | sleep 5; \ |
| 58 | done |
| 59 | touch $@ |
| 60 | |
| 61 | $(WORKSPACE)/cord/helm-charts: | $(M)/setup |
| 62 | mkdir -p $(WORKSPACE)/cord |
| 63 | cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts |
| 64 | |
| 65 | $(M)/kafka: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init |
| 66 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 67 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install cord-kafka -f examples/kafka-single.yaml incubator/kafka |
| 68 | touch $@ |
| 69 | |
| 70 | $(M)/kafka-running: | $(M)/kafka |
| 71 | kubectl wait pod/cord-kafka-0 --for condition=Ready --timeout=180s |
| 72 | touch $@ |
| 73 | |
| 74 | # Dependency on NEM is there to force ordering for parallel install |
| 75 | # The idea is to install VOLTHA / ONOS / Mininet while NEM is initializing |
| 76 | $(M)/onos: | $(M)/kafka-running $(M)/nem |
| 77 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install onos onos -f configs/onos.yaml -f $(SEBAVALUES) |
| 78 | touch $@ |
| 79 | |
| 80 | $(M)/voltha: | $(M)/kafka-running |
| 81 | cd $(WORKSPACE)/cord/helm-charts; helm dep up voltha |
| 82 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install voltha -f $(SEBAVALUES) \ |
| 83 | --set etcd-operator.customResources.createEtcdClusterCRD=false \ |
| 84 | voltha |
| 85 | touch $@ |
| 86 | |
| 87 | $(M)/etcd-operator-ready: | $(M)/voltha |
| 88 | until kubectl api-versions | grep etcd.database.coreos.com/v1beta2; \ |
| 89 | do \ |
| 90 | echo "Waiting for etcd.database.coreos.com/v1beta2 to be available"; \ |
| 91 | sleep 5; \ |
| 92 | done |
| 93 | until kubectl api-resources | grep EtcdCluster; \ |
| 94 | do \ |
| 95 | echo "Waiting for EtcdCluster API resource to be available"; \ |
| 96 | sleep 5; \ |
| 97 | done |
| 98 | touch $@ |
| 99 | |
| 100 | $(M)/etcd-cluster: | $(M)/etcd-operator-ready |
| 101 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade voltha -f $(SEBAVALUES) \ |
| 102 | --set etcd-operator.customResources.createEtcdClusterCRD=true \ |
| 103 | voltha |
| 104 | touch $@ |
| 105 | |
| 106 | $(M)/voltha-running: | $(M)/etcd-cluster |
| 107 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh voltha |
| 108 | touch $@ |
| 109 | |
| 110 | $(M)/ponsim: | $(M)/voltha |
Andy Bavier | c3a0269 | 2018-09-26 15:55:23 -0700 | [diff] [blame] | 111 | sudo iptables -P FORWARD ACCEPT |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 112 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponnet ponnet |
| 113 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh kube-system |
| 114 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f $(SEBAVALUES) |
| 115 | touch $@ |
| 116 | |
| 117 | $(M)/pon0_fwd: | $(M)/ponsim |
| 118 | echo 8 > /tmp/pon0_group_fwd_mask |
| 119 | until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \ |
| 120 | do \ |
| 121 | echo "waiting for pon0..."; \ |
| 122 | sleep 5; \ |
| 123 | done |
| 124 | rm /tmp/pon0_group_fwd_mask |
| 125 | touch $@ |
| 126 | |
| 127 | $(M)/mininet: | $(M)/onos $(M)/ponsim $(M)/pon0_fwd |
| 128 | sudo modprobe openvswitch |
| 129 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install mininet mininet |
| 130 | touch $@ |
| 131 | |
| 132 | $(M)/nem: $(M)/kafka-running |
| 133 | cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-core |
| 134 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install xos-core xos-core |
| 135 | cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/att-workflow |
| 136 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install att-workflow xos-profiles/att-workflow -f $(SEBAVALUES) |
| 137 | touch $@ |
| 138 | |
| 139 | $(M)/nem-running: $(M)/nem |
| 140 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh |
| 141 | touch $@ |
| 142 | |
| 143 | $(M)/ponsim-tosca: $(M)/nem-running |
| 144 | timeout 60s bash -c "until ! http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/serviceinstanceattributes|jq '.items[].backend_status'|grep -v OK; do echo 'waiting for ONOS config to sync'; sleep 5; done" |
| 145 | timeout 60s bash -c "until ! http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/onos/onosapps|jq '.items[].backend_status'|grep -v OK; do echo 'waiting for ONOS apps to sync'; sleep 5; done" |
| 146 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod |
| 147 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh |
| 148 | touch $@ |
| 149 | |
| 150 | $(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca |
| 151 | until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \ |
| 152 | do \ |
| 153 | sleep 5; \ |
| 154 | done |
| 155 | http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535 |
| 156 | touch $@ |
| 157 | echo "SEBA-in-a-Box installation finished!" |
| 158 | |
| 159 | run-tests: $(M)/pingtest |
| 160 | |
| 161 | $(M)/authenticate: $(M)/siab |
| 162 | timeout 60s bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances |jq '.items[0].authentication_state'|grep AWAITING; do echo 'waiting for att-workflow-driver to be in AWAITING state'; sleep 5; done" |
| 163 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- wpa_supplicant -i eth0 -Dwired -c /etc/wpa_supplicant/wpa_supplicant.conf -B |
| 164 | timeout 60s bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances |jq '.items[0].authentication_state'|grep APPROVED; do echo 'waiting for att-workflow-driver to be in APPROVED state'; sleep 5; done" |
| 165 | touch $@ |
| 166 | |
| 167 | $(M)/dhclient: $(M)/authenticate |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 168 | timeout 60s bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/fabric-crossconnect/fabriccrossconnectserviceinstances |jq '.items[0].backend_status'|grep OK; do echo 'waiting for fabric-crossconnect to be synchronized';sleep 5; done" |
| 169 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- dhclient |
| 170 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- dhclient -r |
| 171 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- dhclient |
| 172 | touch $@ |
| 173 | |
| 174 | $(M)/pingtest: $(M)/dhclient |
| 175 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- ping -c 3 172.18.0.10 |
| 176 | touch $@ |
| 177 | |
| 178 | remove-chart-milestones: |
| 179 | cd $(M); rm -f kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \ |
| 180 | voltha-running ponsim mininet nem nem-running ponsim-tosca siab |
| 181 | |
| 182 | remove-kube-milestones: |
| 183 | cd $(M); rm -f kubeadm helm-init |
| 184 | |
| 185 | remove-test-milestones: |
| 186 | cd $(M); rm -f authenticate dhclient pingtest |
| 187 | |
| 188 | teardown-charts: remove-chart-milestones |
| 189 | helm delete --purge $(shell helm ls -q) |
| 190 | |
| 191 | reset-kubeadm: remove-chart-milestones remove-kube-milestones |
Andy Bavier | c3a0269 | 2018-09-26 15:55:23 -0700 | [diff] [blame] | 192 | sudo kubeadm reset -f |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 193 | sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X |
| 194 | |