blob: c51a9a4d4dd6bee740ad34c93ea5986828200283 [file] [log] [blame]
Jeremy Ronquillo5263c732020-10-13 09:42:19 -07001# Copyright 2018-present Open Networking Foundation
2#
3# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
4
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -07005SHELL := /bin/bash
6BUILD ?= /tmp/build
7M ?= $(BUILD)/milestones
8MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -07009SCRIPTDIR := $(MAKEDIR)/scripts
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070010RESOURCEDIR := $(MAKEDIR)/resources
11WORKSPACE ?= $(HOME)
Jeremy Ronquillod3cab742020-08-24 11:49:00 -070012VENV ?= $(BUILD)/venv/aiab
13AIABVALUES ?= $(MAKEDIR)/aether-in-a-box-values.yaml
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070014
Hyunsun84f0f172020-09-23 15:40:08 -050015KUBESPRAY_VERSION ?= release-2.14
16DOCKER_VERSION ?= 19.03
17K8S_VERSION ?= v1.18.9
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070018HELM_VERSION ?= v2.16.1
19
20# used to start logging/monitoring and other infrastructure charts
21INFRA_CHARTS ?=
22INFRA_PREREQS = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart))
23
24KAFKA_CHART_VERSION ?= 0.13.3
25KAFKA_POD := "pod/cord-kafka-0"
26
27HELM_GLOBAL_ARGS ?=
28HELM_NEM_ARGS ?= $(HELM_GLOBAL_ARGS)
29HELM_ONOS_ARGS ?= $(HELM_GLOBAL_ARGS)
30
31cpu_family := $(shell lscpu | grep 'CPU family:' | awk '{print $$3}')
32cpu_model := $(shell lscpu | grep 'Model:' | awk '{print $$2}')
33os_vendor := $(shell lsb_release -i -s)
34os_release := $(shell lsb_release -r -s)
35
Jeremy Ronquillod3cab742020-08-24 11:49:00 -070036aiab: $(M)/system-check $(M)/omec
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070037oaisim: $(M)/oaisim
38
Jeremy Ronquillod3cab742020-08-24 11:49:00 -070039.PHONY: aiab oaisim test reset-test clean
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070040
41$(M):
42 mkdir -p $(M)
43
44$(M)/system-check: | $(M)
45 @if [[ $(cpu_family) -eq 6 ]]; then \
46 if [[ $(cpu_model) -lt 60 ]]; then \
47 echo "FATAL: haswell CPU or newer is required."; \
48 exit 1; \
49 fi \
50 else \
51 echo "FATAL: unsupported CPU family."; \
52 exit 1; \
53 fi
54 @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \
55 if [[ ! $(os_release) =~ (16.04) ]]; then \
56 echo "WARN: $(os_vendor) $(os_release) has not been tested."; \
57 fi; \
58 if dpkg --compare-versions 4.15 gt $(shell uname -r); then \
59 echo "FATAL: kernel 4.15 or later is required."; \
60 echo "Please upgrade your kernel by running" \
61 "apt install --install-recommends linux-generic-hwe-$(os_release)"; \
62 exit 1; \
63 fi \
64 else \
65 echo "FAIL: unsupported OS."; \
66 exit 1; \
67 fi
68 touch $@
69
70$(M)/setup: | $(M)
71 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
72 sudo apt update; sudo apt install -y software-properties-common python-pip jq httpie ipvsadm
73 touch $@
74
75$(BUILD)/kubespray: | $(M)/setup
76 mkdir -p $(BUILD)
77 cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
78
79$(VENV)/bin/activate: | $(M)/setup
80 sudo pip install virtualenv
81 virtualenv $(VENV)
82
83$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
84 source "$(VENV)/bin/activate" && \
85 pip install -r $(BUILD)/kubespray/requirements.txt
86 touch $@
87
88$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
89 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
90 ansible-playbook -b -i inventory/local/hosts.ini \
91 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
92 -e "{'docker_version' : $(DOCKER_VERSION)}" \
93 -e "{'docker_iptables_enabled' : True}" \
94 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun84f0f172020-09-23 15:40:08 -050095 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070096 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
97 -e "{'kube_pods_subnet' : 192.168.0.0/17, 'kube_service_addresses' : 192.168.128.0/17}" \
98 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
99 -e "{'kubeadm_enabled': True}" \
100 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
101 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*]}" \
102 -e "{'dns_min_replicas' : 1}" \
103 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
104 cluster.yml
105 mkdir -p $(HOME)/.kube
106 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
107 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
108 kubectl wait pod -n kube-system --for=condition=Ready --all
109 touch $@
110
111$(M)/helm-ready: | $(M)/k8s-ready
112 helm init --wait --client-only
113 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
114 helm repo add cord https://charts.opencord.org
115 touch $@
116
117/opt/cni/bin/simpleovs: | $(M)/k8s-ready
118 sudo cp $(RESOURCEDIR)/simpleovs /opt/cni/bin/
119
120/opt/cni/bin/static: | $(M)/k8s-ready
121 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
122 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
123 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
124 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
125
126# TODO: need to connect ONOS
127$(M)/fabric: | $(M)/setup /opt/cni/bin/simpleovs /opt/cni/bin/static
128 sudo apt install -y openvswitch-switch
129 sudo ovs-vsctl --may-exist add-br br-enb-net
130 sudo ovs-vsctl --may-exist add-port br-enb-net enb -- set Interface enb type=internal
131 sudo ip addr add 192.168.251.4/24 dev enb || true
132 sudo ip link set enb up
133 sudo ethtool --offload enb tx off
134 sudo ip route replace 192.168.252.0/24 via 192.168.251.1 dev enb
135 kubectl apply -f $(RESOURCEDIR)/router.yaml
136 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
Hyunsun84f0f172020-09-23 15:40:08 -0500137 kubectl -n default exec router ip route add 10.250.0.0/16 via 192.168.250.3
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700138 kubectl delete net-attach-def core-net
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700139 touch $@
140
141$(M)/omec: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
142 helm repo update
143 helm upgrade --install $(HELM_GLOBAL_ARGS) \
144 --namespace omec \
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700145 --values $(AIABVALUES) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700146 omec-control-plane \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700147 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane && \
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500148 kubectl wait pod -n omec --for=condition=Ready -l release=omec-control-plane --timeout=300s && \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700149 helm upgrade --install $(HELM_GLOBAL_ARGS) \
150 --namespace omec \
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700151 --values $(AIABVALUES) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700152 omec-user-plane \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700153 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500154 kubectl wait pod -n omec --for=condition=Ready -l release=omec-user-plane --timeout=300s
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700155 touch $@
156
157# UE images includes kernel module, ue_ip.ko
158# which should be built in the exactly same kernel version of the host machine
159$(BUILD)/openairinterface: | $(M)/setup
160 mkdir -p $(BUILD)
161 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
162
163$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
164 cd $(BUILD)/openairinterface; \
165 sudo docker build . --target lte-uesoftmodem \
166 --build-arg build_base=omecproject/oai-base:1.0.0 \
167 --file Dockerfile.ue \
168 --tag omecproject/lte-uesoftmodem:1.0.0
169 touch $@
170
171$(M)/oaisim: | $(M)/ue-image $(M)/omec
172 sudo ip addr add 127.0.0.2/8 dev lo || true
173 $(eval mme_iface=$(shell ip -4 route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700174 helm upgrade --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(AIABVALUES) \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700175 --set config.enb.networks.s1_mme.interface=$(mme_iface) \
176 --set images.pullPolicy=IfNotPresent
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700177 kubectl rollout status -n omec statefulset ue
178 @timeout 60s bash -c \
179 "until ip addr show oip1 | grep -q inet; \
180 do \
181 echo 'Waiting for UE 1 gets IP address'; \
182 sleep 3; \
183 done"
184 touch $@
185
186test: | $(M)/fabric $(M)/omec $(M)/oaisim
187 @sleep 5
188 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500189 ping -I oip1 192.168.250.1 -c 15
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700190 @echo "Test2: ping from UE to 8.8.8.8"
191 ping -I oip1 8.8.8.8 -c 3
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500192 @echo "Test3: ping from UE to google.com"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700193 ping -I oip1 google.com -c 3
194 @echo "Finished to test"
195
196reset-test:
197 helm delete --purge oaisim || true
198 helm delete --purge omec-control-plane || true
199 helm delete --purge omec-user-plane || true
Jeremy Ronquillo7ba47332020-09-21 16:47:21 -0700200 kubectl delete po router || true
201 cd $(M); rm -f oaisim omec fabric
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700202
203clean: reset-test
204 helm delete --purge $(shell helm ls -q) || true
205 kubectl delete po router || true
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700206 kubectl delete net-attach-def core-net || true
207 sudo ovs-vsctl del-br br-access-net || true
208 sudo ovs-vsctl del-br br-core-net || true
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700209 sudo apt remove --purge openvswitch-switch -y
210 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
211 ansible-playbook -b -i inventory/local/hosts.ini reset.yml
212 @if [ -d /usr/local/etc/emulab ]; then \
213 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
214 sudo rm -rf /mnt/extra/kubelet; \
215 fi
216 rm -rf $(M)