blob: 442190609b3374423336e7728033ac49c5cbb975 [file] [log] [blame]
Andy Bavier35053b62018-09-20 13:45:45 -07001SHELL := /bin/bash
2BUILD ?= /tmp
3M ?= $(BUILD)/milestones
4MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
5WORKSPACE ?= $(HOME)
6SEBAVALUES ?= configs/seba-ponsim.yaml
7
8HELM_VERSION ?= "2.10.0"
9HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe"
10HELM_PLATFORM ?= "linux-amd64"
11
12all: $(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 Baviera7c6a4e2018-09-28 13:29:43 -070043 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 Bavier35053b62018-09-20 13:45:45 -070046 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 Bavierc3a02692018-09-26 15:55:23 -0700111 sudo iptables -P FORWARD ACCEPT
Andy Bavier35053b62018-09-20 13:45:45 -0700112 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
Andy Bavier01449932018-10-01 16:19:40 -0700159run-tests: $(M)/qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700160
Andy Bavier01449932018-10-01 16:19:40 -0700161$(M)/qatests-prereqs:
162 sudo apt install -y python-pip virtualenv
Andy Bavier35053b62018-09-20 13:45:45 -0700163 touch $@
164
Andy Bavier01449932018-10-01 16:19:40 -0700165$(WORKSPACE)/cord/test/cord-tester: | $(M)/setup
166 mkdir -p $(WORKSPACE)/cord/test
167 cd $(WORKSPACE)/cord/test && git clone https://gerrit.opencord.org/cord-tester
Andy Bavier35053b62018-09-20 13:45:45 -0700168
Andy Bavier01449932018-10-01 16:19:40 -0700169$(M)/qatests: $(M)/siab $(M)/qatests-prereqs $(WORKSPACE)/cord/test/cord-tester
170 cd $(WORKSPACE)/cord/test/cord-tester/src/test/cord-api/ && \
Andy Bavierf55e6a12018-10-02 09:19:43 -0700171 WORKSPACE=. bash ./setup_venv.sh && \
Andy Bavier01449932018-10-01 16:19:40 -0700172 source ./venv-cord-tester/bin/activate && \
173 cd Tests/WorkflowValidations/ && \
174 pybot -e notready SIAB.robot
Andy Bavier35053b62018-09-20 13:45:45 -0700175 touch $@
176
177remove-chart-milestones:
178 cd $(M); rm -f kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \
179 voltha-running ponsim mininet nem nem-running ponsim-tosca siab
180
181remove-kube-milestones:
182 cd $(M); rm -f kubeadm helm-init
183
184remove-test-milestones:
Andy Bavier01449932018-10-01 16:19:40 -0700185 cd $(M); rm -f qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700186
187teardown-charts: remove-chart-milestones
188 helm delete --purge $(shell helm ls -q)
189
190reset-kubeadm: remove-chart-milestones remove-kube-milestones
Andy Bavierc3a02692018-09-26 15:55:23 -0700191 sudo kubeadm reset -f
Andy Bavier35053b62018-09-20 13:45:45 -0700192 sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
193