blob: aa5faf6dc0345b41acd8d39da703d35dbbcd47d5 [file] [log] [blame]
Hyunsun Moon81c8e232019-05-21 03:40:22 -06001SHELL := /bin/bash
2BUILD ?= /tmp/build
3M ?= $(BUILD)/milestones
4MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
5SCRIPTDIR := $(MAKEDIR)../scripts
6RESOURCEDIR := $(MAKEDIR)/resources
7WORKSPACE ?= $(HOME)
8VENV ?= $(BUILD)/venv/ciab
9CIABVALUES ?= $(MAKEDIR)/comac-in-a-box-values.yaml
10
Hyunsun Moon07decd42019-08-19 13:59:52 -060011KUBESPRAY_VERSION ?= release-2.11
12DOCKER_VERSION ?= 18.09
13K8S_VERSION ?= v1.15.3
Hyunsun Moon1fae9d62019-10-19 15:08:20 -060014HELM_VERSION ?= v2.15.0
Hyunsun Moon81c8e232019-05-21 03:40:22 -060015
16# used to start logging/monitoring and other infrastructure charts
17INFRA_CHARTS ?=
18INFRA_PREREQS = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart))
19
20KAFKA_CHART_VERSION ?= 0.13.3
21KAFKA_POD := "pod/cord-kafka-0"
22
Hyunsun Moon81c8e232019-05-21 03:40:22 -060023HELM_GLOBAL_ARGS ?=
24HELM_NEM_ARGS ?= $(HELM_GLOBAL_ARGS)
25HELM_ONOS_ARGS ?= $(HELM_GLOBAL_ARGS)
26
27cpu_family := $(shell lscpu | grep 'CPU family:' | awk '{print $$3}')
28cpu_model := $(shell lscpu | grep 'Model:' | awk '{print $$2}')
29os_vendor := $(shell lsb_release -i -s)
Hyunsun Moonad70fc12019-08-02 16:52:19 -060030os_release := $(shell lsb_release -r -s)
Hyunsun Moon81c8e232019-05-21 03:40:22 -060031
Hyunsun Moondea5dbd2019-10-24 20:24:38 -050032ciab: $(M)/system-check $(M)/platform $(M)/omec
33oaisim: $(M)/oaisim
Hyunsun Moon81c8e232019-05-21 03:40:22 -060034
Hyunsun Moondea5dbd2019-10-24 20:24:38 -050035.PHONY: ciab oaisim test reset-test clean
Hyunsun Moon81c8e232019-05-21 03:40:22 -060036
37$(M):
38 mkdir -p $(M)
39
Hyunsun Moon07decd42019-08-19 13:59:52 -060040$(M)/system-check: | $(M)
Hyunsun Moon81c8e232019-05-21 03:40:22 -060041 @if [[ $(cpu_family) -eq 6 ]]; then \
42 if [[ $(cpu_model) -lt 60 ]]; then \
43 echo "FATAL: haswell CPU or newer is required."; \
44 exit 1; \
45 fi \
46 else \
47 echo "FATAL: unsupported CPU family."; \
48 exit 1; \
49 fi
50 @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \
Hyunsun Moonad70fc12019-08-02 16:52:19 -060051 if [[ ! $(os_release) =~ (16.04) ]]; then \
52 echo "WARN: $(os_vendor) $(os_release) has not been tested."; \
53 fi; \
54 if dpkg --compare-versions 4.15 gt $(shell uname -r); then \
55 echo "FATAL: kernel 4.15 or later is required."; \
56 echo "Please upgrade your kernel by running" \
57 "apt install --install-recommends linux-generic-hwe-$(os_release)"; \
58 exit 1; \
Hyunsun Moon81c8e232019-05-21 03:40:22 -060059 fi \
60 else \
61 echo "FAIL: unsupported OS."; \
62 exit 1; \
63 fi
64 touch $@
65
66$(M)/setup: | $(M)
67 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
68 sudo apt update; sudo apt install -y software-properties-common python-pip jq httpie ipvsadm
69 touch $@
70
71$(BUILD)/kubespray: | $(M)/setup
72 mkdir -p $(BUILD)
73 cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
74
75$(VENV)/bin/activate: | $(M)/setup
76 sudo pip install virtualenv
77 virtualenv $(VENV) --no-site-packages
78
79$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
80 source "$(VENV)/bin/activate" && \
81 pip install -r $(BUILD)/kubespray/requirements.txt
82 touch $@
83
84$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
85 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
86 ansible-playbook -b -i inventory/local/hosts.ini \
87 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
88 -e "{'docker_version' : $(DOCKER_VERSION)}" \
89 -e "{'docker_iptables_enabled' : True}" \
90 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun Moon5d179d42019-08-12 14:18:19 -050091 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable}" \
Hyunsun Moon81c8e232019-05-21 03:40:22 -060092 -e "{'kube_proxy_mode': iptables}" \
Hyunsun Moon5aaf5432019-11-11 15:35:40 -070093 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
Hyunsun Moon81c8e232019-05-21 03:40:22 -060094 -e "{'kube_pods_subnet' : 192.168.0.0/17, 'kube_service_addresses' : 192.168.128.0/17}" \
95 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
96 -e "{'kubeadm_enabled': True}" \
97 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
98 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*]}" \
99 -e "{'dns_min_replicas' : 1}" \
100 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
101 cluster.yml
102 mkdir -p $(HOME)/.kube
103 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
104 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
105 kubectl wait pod -n kube-system --for=condition=Ready --all
106 touch $@
107
108$(M)/helm-ready: | $(M)/k8s-ready
109 helm init --wait --client-only
110 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
111 helm repo add cord https://charts.opencord.org
112 touch $@
113
114$(WORKSPACE)/cord/helm-charts: | $(M)/setup
115 mkdir -p $(WORKSPACE)/cord
116 cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts
117
Doyoung Lee9b0973f2019-08-20 14:47:59 -0700118$(WORKSPACE)/cord/cord-platform: | $(M)/setup
119 mkdir -p $(WORKSPACE)/cord
120 cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/cord-platform
121
Hyunsun Moondea5dbd2019-10-24 20:24:38 -0500122$(M)/platform: | $(M)/helm-ready $(WORKSPACE)/cord/helm-charts $(WORKSPACE)/cord/cord-platform
Doyoung Lee9b0973f2019-08-20 14:47:59 -0700123 cd $(WORKSPACE)/cord/cord-platform && \
124 helm dep update cord-platform && \
Hyunsun Moon1fae9d62019-10-19 15:08:20 -0600125 helm install $(HELM_GLOBAL_ARGS) --name cord-platform cord-platform -f $(CIABVALUES)
Hyunsun Moondea5dbd2019-10-24 20:24:38 -0500126 cd $(WORKSPACE)/cord/helm-charts && \
127 helm dep update comac && \
128 helm install $(HELM_GLOBAL_ARGS) --name comac comac -f $(CIABVALUES)
Doyoung Lee9b0973f2019-08-20 14:47:59 -0700129 touch $@
130
Hyunsun Moon81c8e232019-05-21 03:40:22 -0600131/opt/cni/bin/simpleovs: | $(M)/k8s-ready
132 sudo cp $(RESOURCEDIR)/simpleovs /opt/cni/bin/
133
Hyunsun Moon07decd42019-08-19 13:59:52 -0600134/opt/cni/bin/static: | $(M)/k8s-ready
135 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
136 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
137 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
138 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
139
Hyunsun Moon89886f12019-09-05 22:16:09 -0600140# TODO: need to connect ONOS
141$(M)/fabric: | $(M)/setup /opt/cni/bin/simpleovs
142 sudo apt install -y openvswitch-switch
143 sudo ovs-vsctl --may-exist add-br br-s1u-net
144 sudo ovs-vsctl --may-exist add-port br-s1u-net s1u-enb -- set Interface s1u-enb type=internal
145 sudo ip addr add 119.0.0.4/24 dev s1u-enb || true
146 sudo ip link set s1u-enb up
Hyunsun Moon89886f12019-09-05 22:16:09 -0600147 kubectl apply -f $(RESOURCEDIR)/router.yaml
Doyoung Lee1bb116d2019-09-09 17:29:24 -0700148 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
Hyunsun Moonb9d3f482019-09-07 16:38:28 -0600149 kubectl -n default exec router ip route add 16.0.0.0/8 via 13.1.1.3
Hyunsun Moon89886f12019-09-05 22:16:09 -0600150 kubectl delete net-attach-def sgi-net
151 touch $@
152
153$(M)/omec: | $(M)/helm-ready $(WORKSPACE)/cord/helm-charts /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
Hyunsun Moon07decd42019-08-19 13:59:52 -0600154 cd $(WORKSPACE)/cord/helm-charts/omec; \
155 helm dep up omec-data-plane && \
156 helm dep up omec-control-plane && \
Hyunsun Moon1fae9d62019-10-19 15:08:20 -0600157 helm install $(HELM_GLOBAL_ARGS) --namespace omec --name omec-data-plane omec-data-plane -f $(CIABVALUES) && \
158 helm install $(HELM_GLOBAL_ARGS) --namespace omec --name omec-control-plane omec-control-plane -f $(CIABVALUES)
Hyunsun Moonb9d3f482019-09-07 16:38:28 -0600159 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh omec
Hyunsun Moon81c8e232019-05-21 03:40:22 -0600160 touch $@
161
162# UE images includes kernel module, ue_ip.ko
163# which should be built in the exactly same kernel version of the host machine
164$(BUILD)/openairinterface: | $(M)/setup
165 mkdir -p $(BUILD)
166 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
167
168$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
169 cd $(BUILD)/openairinterface; \
170 sudo docker build . --target lte-uesoftmodem \
171 --build-arg build_base=omecproject/oai-base:1.0.0 \
172 --file Dockerfile.ue \
173 --tag omecproject/lte-uesoftmodem:1.0.0
174 touch $@
175
Hyunsun Moondea5dbd2019-10-24 20:24:38 -0500176$(M)/oaisim: | $(M)/ue-image $(M)/omec
Hyunsun Moon81c8e232019-05-21 03:40:22 -0600177 sudo ip addr add 127.0.0.2/8 dev lo || true
178 $(eval mme_iface=$(shell ip -4 route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
179 cd $(WORKSPACE)/cord/helm-charts; \
Hyunsun Moon1fae9d62019-10-19 15:08:20 -0600180 helm install $(HELM_GLOBAL_ARGS) --namespace omec --name oaisim oaisim -f $(CIABVALUES) \
Hyunsun Moon07decd42019-08-19 13:59:52 -0600181 --set config.enb.networks.s1_mme.interface=$(mme_iface)
Hyunsun Moonb9d3f482019-09-07 16:38:28 -0600182 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh omec
Hyunsun Moon81c8e232019-05-21 03:40:22 -0600183 @timeout 60s bash -c \
184 "until ip addr show oip1 | grep -q inet; \
185 do \
186 echo 'Waiting for UE 1 gets IP address'; \
187 sleep 3; \
188 done"
189 touch $@
190
Hyunsun Moon89886f12019-09-05 22:16:09 -0600191test: | $(M)/fabric $(M)/omec $(M)/oaisim
Hyunsun Moon07decd42019-08-19 13:59:52 -0600192 @timeout 120s bash -c \
Hyunsun Moon9f8b5952019-08-13 19:03:47 -0600193 "until timeout 3 ping -I oip1 13.1.1.254 -c 1 > /dev/null 2>&1; do \
194 echo 'Waiting for DP to be ready'; \
195 done"
Woojoong Kim68b57e72019-10-16 14:19:55 -0700196 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon9f8b5952019-08-13 19:03:47 -0600197 ping -I oip1 13.1.1.254 -c 3
Woojoong Kim68b57e72019-10-16 14:19:55 -0700198 @echo "Test2: ping from UE to 8.8.8.8"
199 ping -I oip1 8.8.8.8 -c 3
200 @echo "Test3: ping from UE to opennetworking.org and google.com"
201 ping -I oip1 opennetworking.org -c 3
202 ping -I oip1 google.com -c 3
203 @echo "Finished to test"
Hyunsun Moon81c8e232019-05-21 03:40:22 -0600204
205reset-test:
Hyunsun Moonad70fc12019-08-02 16:52:19 -0600206 helm delete --purge oaisim || true
Hyunsun Moon07decd42019-08-19 13:59:52 -0600207 helm delete --purge omec-control-plane || true
208 helm delete --purge omec-data-plane || true
Hyunsun Moon89886f12019-09-05 22:16:09 -0600209 cd $(M); rm -f oaisim omec
Hyunsun Moon81c8e232019-05-21 03:40:22 -0600210
211clean: reset-test
212 helm delete --purge $(shell helm ls -q) || true
Hyunsun Moonb9d3f482019-09-07 16:38:28 -0600213 kubectl delete po router || true
214 kubectl delete net-attach-def sgi-net || true
Hyunsun Moon81c8e232019-05-21 03:40:22 -0600215 sudo ovs-vsctl del-br br-s1u-net || true
216 sudo ovs-vsctl del-br br-sgi-net || true
217 sudo apt remove --purge openvswitch-switch -y
218 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
219 ansible-playbook -b -i inventory/local/hosts.ini reset.yml
220 @if [ -d /usr/local/etc/emulab ]; then \
221 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
222 sudo rm -rf /mnt/extra/kubelet; \
223 fi
224 rm -rf $(M)