blob: e14d7a9de64251be62c40f6ab4c7ebf3816de4fe [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)
Andy Bavier6ce277e2018-10-02 10:29:21 -07006VIRTUALENV ?= $(WORKSPACE)/cord/test
Andy Bavier35053b62018-09-20 13:45:45 -07007SEBAVALUES ?= configs/seba-ponsim.yaml
8
9HELM_VERSION ?= "2.10.0"
10HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe"
11HELM_PLATFORM ?= "linux-amd64"
12
13all: $(M)/siab
14
15$(M)/setup:
16 mkdir -p $(M)
17 sudo apt update
18 sudo apt install -y httpie jq software-properties-common
19 sudo swapoff -a
20 touch $@
21
22/usr/bin/docker: | $(M)/setup
23 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
24 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable"
25 sudo apt update
26 sudo apt install -y "docker-ce=17.03*"
27
28/usr/bin/kubeadm: | $(M)/setup /usr/bin/docker
29 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
30 echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list
31 sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list
32 sudo apt update
33 sudo apt install -y "kubeadm=1.11.3-*" "kubelet=1.11.3-*" "kubectl=1.11.3-*"
34
35/usr/local/bin/helm:
36 curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz"
37 echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c -
38 cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
39 sudo chmod a+x /usr/local/bin/helm
40 rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM}
41
42$(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm
43 sudo kubeadm init --pod-network-cidr=192.168.0.0/16
Andy Baviera7c6a4e2018-09-28 13:29:43 -070044 mkdir -p $(HOME)/.kube
45 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
46 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
Andy Bavier35053b62018-09-20 13:45:45 -070047 kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
48 kubectl taint nodes --all node-role.kubernetes.io/master-
49 touch $@
50
51$(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm
52 kubectl create serviceaccount --namespace kube-system tiller
53 kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
54 helm init --service-account tiller
55 until helm ls >& /dev/null; \
56 do \
57 echo "Waiting for Helm to be ready"; \
58 sleep 5; \
59 done
60 touch $@
61
62$(WORKSPACE)/cord/helm-charts: | $(M)/setup
63 mkdir -p $(WORKSPACE)/cord
64 cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts
65
66$(M)/kafka: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init
67 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
68 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install cord-kafka -f examples/kafka-single.yaml incubator/kafka
69 touch $@
70
71$(M)/kafka-running: | $(M)/kafka
72 kubectl wait pod/cord-kafka-0 --for condition=Ready --timeout=180s
73 touch $@
74
75# Dependency on NEM is there to force ordering for parallel install
76# The idea is to install VOLTHA / ONOS / Mininet while NEM is initializing
77$(M)/onos: | $(M)/kafka-running $(M)/nem
78 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install onos onos -f configs/onos.yaml -f $(SEBAVALUES)
79 touch $@
80
81$(M)/voltha: | $(M)/kafka-running
82 cd $(WORKSPACE)/cord/helm-charts; helm dep up voltha
83 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install voltha -f $(SEBAVALUES) \
84 --set etcd-operator.customResources.createEtcdClusterCRD=false \
85 voltha
86 touch $@
87
88$(M)/etcd-operator-ready: | $(M)/voltha
89 until kubectl api-versions | grep etcd.database.coreos.com/v1beta2; \
90 do \
91 echo "Waiting for etcd.database.coreos.com/v1beta2 to be available"; \
92 sleep 5; \
93 done
94 until kubectl api-resources | grep EtcdCluster; \
95 do \
96 echo "Waiting for EtcdCluster API resource to be available"; \
97 sleep 5; \
98 done
99 touch $@
100
101$(M)/etcd-cluster: | $(M)/etcd-operator-ready
102 cd $(WORKSPACE)/cord/helm-charts; helm upgrade voltha -f $(SEBAVALUES) \
103 --set etcd-operator.customResources.createEtcdClusterCRD=true \
104 voltha
105 touch $@
106
107$(M)/voltha-running: | $(M)/etcd-cluster
108 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh voltha
109 touch $@
110
111$(M)/ponsim: | $(M)/voltha
Andy Bavierc3a02692018-09-26 15:55:23 -0700112 sudo iptables -P FORWARD ACCEPT
Andy Bavier35053b62018-09-20 13:45:45 -0700113 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponnet ponnet
114 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh kube-system
115 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f $(SEBAVALUES)
116 touch $@
117
118$(M)/pon0_fwd: | $(M)/ponsim
119 echo 8 > /tmp/pon0_group_fwd_mask
120 until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \
121 do \
122 echo "waiting for pon0..."; \
123 sleep 5; \
124 done
125 rm /tmp/pon0_group_fwd_mask
126 touch $@
127
128$(M)/mininet: | $(M)/onos $(M)/ponsim $(M)/pon0_fwd
129 sudo modprobe openvswitch
130 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install mininet mininet
131 touch $@
132
133$(M)/nem: $(M)/kafka-running
134 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-core
135 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install xos-core xos-core
136 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/att-workflow
137 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install att-workflow xos-profiles/att-workflow -f $(SEBAVALUES)
138 touch $@
139
140$(M)/nem-running: $(M)/nem
141 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
142 touch $@
143
144$(M)/ponsim-tosca: $(M)/nem-running
145 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"
146 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"
147 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod
148 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
149 touch $@
150
151$(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca
152 until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \
153 do \
154 sleep 5; \
155 done
156 http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535
157 touch $@
158 echo "SEBA-in-a-Box installation finished!"
159
Andy Bavier01449932018-10-01 16:19:40 -0700160run-tests: $(M)/qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700161
Andy Bavier01449932018-10-01 16:19:40 -0700162$(M)/qatests-prereqs:
163 sudo apt install -y python-pip virtualenv
Andy Bavier35053b62018-09-20 13:45:45 -0700164 touch $@
165
Andy Bavier01449932018-10-01 16:19:40 -0700166$(WORKSPACE)/cord/test/cord-tester: | $(M)/setup
167 mkdir -p $(WORKSPACE)/cord/test
168 cd $(WORKSPACE)/cord/test && git clone https://gerrit.opencord.org/cord-tester
Andy Bavier35053b62018-09-20 13:45:45 -0700169
Andy Bavier01449932018-10-01 16:19:40 -0700170$(M)/qatests: $(M)/siab $(M)/qatests-prereqs $(WORKSPACE)/cord/test/cord-tester
171 cd $(WORKSPACE)/cord/test/cord-tester/src/test/cord-api/ && \
Andy Bavier6ce277e2018-10-02 10:29:21 -0700172 WORKSPACE=$(VIRTUALENV) bash ./setup_venv.sh && \
173 source $(VIRTUALENV)/venv-cord-tester/bin/activate && \
Andy Bavier01449932018-10-01 16:19:40 -0700174 cd Tests/WorkflowValidations/ && \
175 pybot -e notready SIAB.robot
Andy Bavier35053b62018-09-20 13:45:45 -0700176 touch $@
177
178remove-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
182remove-kube-milestones:
183 cd $(M); rm -f kubeadm helm-init
184
185remove-test-milestones:
Andy Bavier01449932018-10-01 16:19:40 -0700186 cd $(M); rm -f qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700187
188teardown-charts: remove-chart-milestones
189 helm delete --purge $(shell helm ls -q)
190
191reset-kubeadm: remove-chart-milestones remove-kube-milestones
Andy Bavierc3a02692018-09-26 15:55:23 -0700192 sudo kubeadm reset -f
Andy Bavier35053b62018-09-20 13:45:45 -0700193 sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
194