blob: d473186358392ac45b0daa04f5c0e4bc1c06ebf5 [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
Scott Baker17b70d12020-09-29 23:26:21 -070018HELM_VERSION ?= v3.2.4
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070019
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
Badhrinath3e081e22020-12-02 15:02:08 -060036omec: $(M)/system-check $(M)/omec
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070037oaisim: $(M)/oaisim
Badhrinath3e081e22020-12-02 15:02:08 -0600385gc: $(M)/system-check $(M)/5g-core
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070039
Badhrinath3e081e22020-12-02 15:02:08 -060040.PHONY: omec oaisim 5gc test reset-test 5g-core reset-5g-test clean
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070041
42$(M):
43 mkdir -p $(M)
44
45$(M)/system-check: | $(M)
46 @if [[ $(cpu_family) -eq 6 ]]; then \
47 if [[ $(cpu_model) -lt 60 ]]; then \
48 echo "FATAL: haswell CPU or newer is required."; \
49 exit 1; \
50 fi \
51 else \
52 echo "FATAL: unsupported CPU family."; \
53 exit 1; \
54 fi
55 @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \
Hyunsun7b640512020-10-27 19:49:51 -050056 if [[ ! $(os_release) =~ (18.04) ]]; then \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070057 echo "WARN: $(os_vendor) $(os_release) has not been tested."; \
58 fi; \
59 if dpkg --compare-versions 4.15 gt $(shell uname -r); then \
60 echo "FATAL: kernel 4.15 or later is required."; \
61 echo "Please upgrade your kernel by running" \
62 "apt install --install-recommends linux-generic-hwe-$(os_release)"; \
63 exit 1; \
64 fi \
65 else \
66 echo "FAIL: unsupported OS."; \
67 exit 1; \
68 fi
Hyunsun7b640512020-10-27 19:49:51 -050069 @if [[ ! -d "$(WORKSPACE)/cord/aether-helm-charts" ]]; then \
70 echo "FATAL: Please clone aether-helm-charts under $(WORKSPACE)/cord directory."; \
71 exit 1; \
72 fi
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070073 touch $@
74
75$(M)/setup: | $(M)
76 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
Hyunsun2d97a3d2021-06-28 10:51:09 -060077 sudo apt update; sudo apt install -y software-properties-common python3 python3-pip jq httpie ipvsadm
78 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070079 touch $@
80
81$(BUILD)/kubespray: | $(M)/setup
82 mkdir -p $(BUILD)
83 cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
84
85$(VENV)/bin/activate: | $(M)/setup
Hyunsun2d97a3d2021-06-28 10:51:09 -060086 sudo pip3 install virtualenv
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070087 virtualenv $(VENV)
88
89$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
90 source "$(VENV)/bin/activate" && \
91 pip install -r $(BUILD)/kubespray/requirements.txt
92 touch $@
93
94$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
95 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
96 ansible-playbook -b -i inventory/local/hosts.ini \
97 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
98 -e "{'docker_version' : $(DOCKER_VERSION)}" \
99 -e "{'docker_iptables_enabled' : True}" \
100 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun84f0f172020-09-23 15:40:08 -0500101 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700102 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
103 -e "{'kube_pods_subnet' : 192.168.0.0/17, 'kube_service_addresses' : 192.168.128.0/17}" \
104 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
105 -e "{'kubeadm_enabled': True}" \
106 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
107 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*]}" \
108 -e "{'dns_min_replicas' : 1}" \
109 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
110 cluster.yml
111 mkdir -p $(HOME)/.kube
112 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
113 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
114 kubectl wait pod -n kube-system --for=condition=Ready --all
115 touch $@
116
117$(M)/helm-ready: | $(M)/k8s-ready
Woojoong Kim8425cb32021-01-08 16:18:53 -0800118 helm repo add incubator https://charts.helm.sh/incubator
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700119 helm repo add cord https://charts.opencord.org
120 touch $@
121
122/opt/cni/bin/simpleovs: | $(M)/k8s-ready
123 sudo cp $(RESOURCEDIR)/simpleovs /opt/cni/bin/
124
125/opt/cni/bin/static: | $(M)/k8s-ready
126 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
127 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
128 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
129 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
130
131# TODO: need to connect ONOS
132$(M)/fabric: | $(M)/setup /opt/cni/bin/simpleovs /opt/cni/bin/static
133 sudo apt install -y openvswitch-switch
134 sudo ovs-vsctl --may-exist add-br br-enb-net
135 sudo ovs-vsctl --may-exist add-port br-enb-net enb -- set Interface enb type=internal
136 sudo ip addr add 192.168.251.4/24 dev enb || true
137 sudo ip link set enb up
138 sudo ethtool --offload enb tx off
139 sudo ip route replace 192.168.252.0/24 via 192.168.251.1 dev enb
140 kubectl apply -f $(RESOURCEDIR)/router.yaml
141 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
Jeremy Ronquillob2b64ea2020-12-09 13:49:03 -0800142 kubectl -n default exec router ip route add 172.250.0.0/16 via 192.168.250.3
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700143 kubectl delete net-attach-def core-net
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700144 touch $@
145
146$(M)/omec: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
Scott Baker17b70d12020-09-29 23:26:21 -0700147 kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700148 helm repo update
Hyunsun7b640512020-10-27 19:49:51 -0500149 helm dep up $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700150 helm upgrade --install $(HELM_GLOBAL_ARGS) \
151 --namespace omec \
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700152 --values $(AIABVALUES) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700153 omec-control-plane \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700154 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane && \
Hyunsun7b640512020-10-27 19:49:51 -0500155 kubectl wait pod -n omec --for=condition=Ready -l release=omec-control-plane --timeout=300s && \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700156 helm upgrade --install $(HELM_GLOBAL_ARGS) \
157 --namespace omec \
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700158 --values $(AIABVALUES) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700159 omec-user-plane \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700160 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \
Hyunsun7b640512020-10-27 19:49:51 -0500161 kubectl wait pod -n omec --for=condition=Ready -l release=omec-user-plane --timeout=300s
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700162 touch $@
163
Badhrinath3e081e22020-12-02 15:02:08 -0600164$(M)/5g-core: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
165 kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
166 helm repo update
167 helm dep up $(WORKSPACE)/cord/aether-helm-charts/omec/5g-control-plane
168 helm upgrade --install $(HELM_GLOBAL_ARGS) \
169 --namespace omec \
170 --values $(AIABVALUES) \
Ajay Lotan Thakur980823b2021-06-23 18:55:05 -0500171 sim-app \
172 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-sub-provision && \
173 kubectl wait pod -n omec --for=condition=Ready -l release=sim-app --timeout=300s
174 helm upgrade --install $(HELM_GLOBAL_ARGS) \
175 --namespace omec \
176 --values $(AIABVALUES) \
Badhrinath3e081e22020-12-02 15:02:08 -0600177 5g-core-up \
178 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \
179 kubectl wait pod -n omec --for=condition=Ready -l release=5g-core-up --timeout=300s
180 helm upgrade --install $(HELM_GLOBAL_ARGS) \
181 --namespace omec \
182 --values $(AIABVALUES) \
183 fgc-core \
184 $(WORKSPACE)/cord/aether-helm-charts/omec/5g-control-plane && \
185 kubectl wait pod -n omec --for=condition=Ready -l release=fgc-core --timeout=300s && \
186 helm upgrade --install $(HELM_GLOBAL_ARGS) \
187 --namespace omec \
Ajay Lotan Thakurdcc602e2021-05-20 11:16:26 -0600188 --values $(AIABVALUES) \
Badhrinath3e081e22020-12-02 15:02:08 -0600189 5g-ransim-plane \
190 $(WORKSPACE)/cord/aether-helm-charts/omec/5g-ran-sim && \
191 kubectl wait pod -n omec --for=condition=Ready -l release=5g-ransim-plane --timeout=300s
192 touch $@
193
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700194# UE images includes kernel module, ue_ip.ko
195# which should be built in the exactly same kernel version of the host machine
196$(BUILD)/openairinterface: | $(M)/setup
197 mkdir -p $(BUILD)
198 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
199
200$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
201 cd $(BUILD)/openairinterface; \
202 sudo docker build . --target lte-uesoftmodem \
Hyunsun7b640512020-10-27 19:49:51 -0500203 --build-arg build_base=omecproject/oai-base:1.1.0 \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700204 --file Dockerfile.ue \
Hyunsun7b640512020-10-27 19:49:51 -0500205 --tag omecproject/lte-uesoftmodem:1.1.0
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700206 touch $@
207
208$(M)/oaisim: | $(M)/ue-image $(M)/omec
209 sudo ip addr add 127.0.0.2/8 dev lo || true
210 $(eval mme_iface=$(shell ip -4 route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
Hyunsun7b640512020-10-27 19:49:51 -0500211 helm upgrade --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(AIABVALUES) \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700212 --set config.enb.networks.s1_mme.interface=$(mme_iface) \
213 --set images.pullPolicy=IfNotPresent
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700214 kubectl rollout status -n omec statefulset ue
215 @timeout 60s bash -c \
216 "until ip addr show oip1 | grep -q inet; \
217 do \
218 echo 'Waiting for UE 1 gets IP address'; \
219 sleep 3; \
220 done"
221 touch $@
222
223test: | $(M)/fabric $(M)/omec $(M)/oaisim
224 @sleep 5
225 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500226 ping -I oip1 192.168.250.1 -c 15
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700227 @echo "Test2: ping from UE to 8.8.8.8"
228 ping -I oip1 8.8.8.8 -c 3
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500229 @echo "Test3: ping from UE to google.com"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700230 ping -I oip1 google.com -c 3
231 @echo "Finished to test"
232
233reset-test:
Scott Baker17b70d12020-09-29 23:26:21 -0700234 helm delete -n omec oaisim || true
235 helm delete -n omec omec-control-plane || true
236 helm delete -n omec omec-user-plane || true
Jeremy Ronquillob2b64ea2020-12-09 13:49:03 -0800237 kubectl delete po router || true
238 cd $(M); rm -f oaisim omec fabric
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700239
Badhrinath3e081e22020-12-02 15:02:08 -0600240reset-5g-test:
Ajay Lotan Thakur980823b2021-06-23 18:55:05 -0500241 helm uninstall -n omec sim-app || true
Badhrinath3e081e22020-12-02 15:02:08 -0600242 helm uninstall -n omec fgc-core || true
243 helm uninstall -n omec 5g-core-up || true
244 helm uninstall -n omec 5g-ransim-plane || true
245 helm uninstall -n omec mongo || true
246 cd $(M); rm -f 5g-core
247
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700248clean: reset-test
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700249 kubectl delete po router || true
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700250 kubectl delete net-attach-def core-net || true
251 sudo ovs-vsctl del-br br-access-net || true
252 sudo ovs-vsctl del-br br-core-net || true
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700253 sudo apt remove --purge openvswitch-switch -y
254 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
255 ansible-playbook -b -i inventory/local/hosts.ini reset.yml
256 @if [ -d /usr/local/etc/emulab ]; then \
257 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
258 sudo rm -rf /mnt/extra/kubelet; \
259 fi
260 rm -rf $(M)