blob: b1039083bc28683580e2e621b5856d6093251b5c [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
43 mkdir -p $(WORKSPACE)/.kube
44 sudo cp -f /etc/kubernetes/admin.conf $(WORKSPACE)/.kube/config
45 sudo chown $(shell id -u):$(shell id -g) $(WORKSPACE)/.kube/config
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
111 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponnet ponnet
112 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh kube-system
113 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f $(SEBAVALUES)
114 touch $@
115
116$(M)/pon0_fwd: | $(M)/ponsim
117 echo 8 > /tmp/pon0_group_fwd_mask
118 until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \
119 do \
120 echo "waiting for pon0..."; \
121 sleep 5; \
122 done
123 rm /tmp/pon0_group_fwd_mask
124 touch $@
125
126$(M)/mininet: | $(M)/onos $(M)/ponsim $(M)/pon0_fwd
127 sudo modprobe openvswitch
128 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install mininet mininet
129 touch $@
130
131$(M)/nem: $(M)/kafka-running
132 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-core
133 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install xos-core xos-core
134 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/att-workflow
135 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install att-workflow xos-profiles/att-workflow -f $(SEBAVALUES)
136 touch $@
137
138$(M)/nem-running: $(M)/nem
139 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
140 touch $@
141
142$(M)/ponsim-tosca: $(M)/nem-running
143 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"
144 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"
145 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod
146 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
147 touch $@
148
149$(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca
150 until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \
151 do \
152 sleep 5; \
153 done
154 http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535
155 touch $@
156 echo "SEBA-in-a-Box installation finished!"
157
158run-tests: $(M)/pingtest
159
160$(M)/authenticate: $(M)/siab
161 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"
162 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
163 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"
164 touch $@
165
166$(M)/dhclient: $(M)/authenticate
167 sudo iptables -P FORWARD ACCEPT
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
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:
186 cd $(M); rm -f authenticate dhclient pingtest
187
188teardown-charts: remove-chart-milestones
189 helm delete --purge $(shell helm ls -q)
190
191reset-kubeadm: remove-chart-milestones remove-kube-milestones
192 sudo kubeadm reset
193 sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
194