blob: a17129b1943b118ac021bdd66e0662d4f37b2357 [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
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070020HELM_GLOBAL_ARGS ?=
Andy Baviereda466b2021-08-27 15:00:36 -070021
22# Allow installing local charts or specific versions of published charts.
23# E.g., to install the Aether 1.5 release:
24# CHARTS=release-1.5 make test
25# Default is to install from the local charts.
26CHARTS ?= local
27CONFIGFILE := configs/$(CHARTS)
28include $(CONFIGFILE)
29include configs/authentication
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070030
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
Hyunsun Moon82e47c22021-06-28 12:30:20 -050077 sudo apt update; sudo apt install -y software-properties-common python3 python3-pip python3-venv jq httpie ipvsadm
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070078 touch $@
79
80$(BUILD)/kubespray: | $(M)/setup
81 mkdir -p $(BUILD)
82 cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
83
84$(VENV)/bin/activate: | $(M)/setup
Hyunsun Moon82e47c22021-06-28 12:30:20 -050085 python3 -m venv $(VENV)
Wei-Yu Chen7edb7e72021-07-28 11:37:55 +080086 source "$(VENV)/bin/activate" && \
87 python -m pip install -U pip && \
88 deactivate
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070089
90$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
91 source "$(VENV)/bin/activate" && \
92 pip install -r $(BUILD)/kubespray/requirements.txt
93 touch $@
94
95$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
96 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
97 ansible-playbook -b -i inventory/local/hosts.ini \
98 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
99 -e "{'docker_version' : $(DOCKER_VERSION)}" \
100 -e "{'docker_iptables_enabled' : True}" \
101 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun84f0f172020-09-23 15:40:08 -0500102 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700103 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
104 -e "{'kube_pods_subnet' : 192.168.0.0/17, 'kube_service_addresses' : 192.168.128.0/17}" \
105 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
106 -e "{'kubeadm_enabled': True}" \
107 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
108 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*]}" \
109 -e "{'dns_min_replicas' : 1}" \
110 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
111 cluster.yml
112 mkdir -p $(HOME)/.kube
113 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
114 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
115 kubectl wait pod -n kube-system --for=condition=Ready --all
116 touch $@
117
118$(M)/helm-ready: | $(M)/k8s-ready
Woojoong Kim8425cb32021-01-08 16:18:53 -0800119 helm repo add incubator https://charts.helm.sh/incubator
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700120 helm repo add cord https://charts.opencord.org
Andy Baviereda466b2021-08-27 15:00:36 -0700121 helm repo add atomix https://charts.atomix.io
122 helm repo add onosproject https://charts.onosproject.org
123 if [ "$(REPO_PASSWORD)" ]; then \
124 helm repo add aether --username ${REPO_USERNAME} --password ${REPO_PASSWORD} https://charts.aetherproject.org; \
125 helm repo add sdran --username ${REPO_USERNAME} --password ${REPO_PASSWORD} https://sdrancharts.onosproject.org; \
126 fi
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700127 touch $@
128
129/opt/cni/bin/simpleovs: | $(M)/k8s-ready
130 sudo cp $(RESOURCEDIR)/simpleovs /opt/cni/bin/
131
132/opt/cni/bin/static: | $(M)/k8s-ready
133 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
134 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
135 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
136 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
137
138# TODO: need to connect ONOS
139$(M)/fabric: | $(M)/setup /opt/cni/bin/simpleovs /opt/cni/bin/static
140 sudo apt install -y openvswitch-switch
141 sudo ovs-vsctl --may-exist add-br br-enb-net
142 sudo ovs-vsctl --may-exist add-port br-enb-net enb -- set Interface enb type=internal
143 sudo ip addr add 192.168.251.4/24 dev enb || true
144 sudo ip link set enb up
145 sudo ethtool --offload enb tx off
146 sudo ip route replace 192.168.252.0/24 via 192.168.251.1 dev enb
147 kubectl apply -f $(RESOURCEDIR)/router.yaml
148 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
Andy Baviereda466b2021-08-27 15:00:36 -0700149 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 -0700150 kubectl delete net-attach-def core-net
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700151 touch $@
152
Andy Baviereda466b2021-08-27 15:00:36 -0700153registry-secret: $(RESOURCEDIR)/aether.registry.yaml
154$(RESOURCEDIR)/aether.registry.yaml:
155 kubectl -n omec create secret docker-registry aether.registry \
156 --docker-server=https://registry.aetherproject.org \
157 --docker-username=${REGISTRY_USERNAME} \
158 --docker-password=${REGISTRY_CLI_SECRET} \
159 --dry-run=client --output=yaml > $@
160
161$(M)/omec: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric $(RESOURCEDIR)/aether.registry.yaml
Scott Baker17b70d12020-09-29 23:26:21 -0700162 kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
Andy Baviereda466b2021-08-27 15:00:36 -0700163 kubectl -n omec get secret aether.registry || kubectl create -f $(RESOURCEDIR)/aether.registry.yaml
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700164 helm repo update
Andy Baviereda466b2021-08-27 15:00:36 -0700165 if [ "$(CHARTS)" == "local" ]; then helm dep up $(OMEC_CONTROL_PLANE_CHART); fi
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700166 helm upgrade --install $(HELM_GLOBAL_ARGS) \
167 --namespace omec \
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700168 --values $(AIABVALUES) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700169 omec-control-plane \
Andy Baviereda466b2021-08-27 15:00:36 -0700170 $(OMEC_CONTROL_PLANE_CHART) && \
Hyunsun7b640512020-10-27 19:49:51 -0500171 kubectl wait pod -n omec --for=condition=Ready -l release=omec-control-plane --timeout=300s && \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700172 helm upgrade --install $(HELM_GLOBAL_ARGS) \
173 --namespace omec \
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700174 --values $(AIABVALUES) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700175 omec-user-plane \
Andy Baviereda466b2021-08-27 15:00:36 -0700176 $(OMEC_USER_PLANE_CHART) && \
Hyunsun7b640512020-10-27 19:49:51 -0500177 kubectl wait pod -n omec --for=condition=Ready -l release=omec-user-plane --timeout=300s
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700178 touch $@
179
Andy Baviereda466b2021-08-27 15:00:36 -0700180$(M)/5g-core: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric $(RESOURCEDIR)/aether.registry.yaml
Badhrinath3e081e22020-12-02 15:02:08 -0600181 kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
Andy Baviereda466b2021-08-27 15:00:36 -0700182 kubectl -n omec get secret aether.registry || kubectl creates -f $(RESOURCEDIR)/aether.registry.yaml
Badhrinath3e081e22020-12-02 15:02:08 -0600183 helm repo update
Andy Baviereda466b2021-08-27 15:00:36 -0700184 if [ "$(CHARTS)" == "local" ]; then helm dep up $(5GC_CONTROL_PLANE_CHART); fi
Badhrinath3e081e22020-12-02 15:02:08 -0600185 helm upgrade --install $(HELM_GLOBAL_ARGS) \
186 --namespace omec \
187 --values $(AIABVALUES) \
Ajay Lotan Thakur980823b2021-06-23 18:55:05 -0500188 sim-app \
Andy Baviereda466b2021-08-27 15:00:36 -0700189 $(OMEC_SUB_PROVISION_CHART) && \
Ajay Lotan Thakur980823b2021-06-23 18:55:05 -0500190 kubectl wait pod -n omec --for=condition=Ready -l release=sim-app --timeout=300s
191 helm upgrade --install $(HELM_GLOBAL_ARGS) \
192 --namespace omec \
193 --values $(AIABVALUES) \
Badhrinath3e081e22020-12-02 15:02:08 -0600194 5g-core-up \
Andy Baviereda466b2021-08-27 15:00:36 -0700195 $(OMEC_USER_PLANE_CHART) && \
Badhrinath3e081e22020-12-02 15:02:08 -0600196 kubectl wait pod -n omec --for=condition=Ready -l release=5g-core-up --timeout=300s
197 helm upgrade --install $(HELM_GLOBAL_ARGS) \
198 --namespace omec \
199 --values $(AIABVALUES) \
200 fgc-core \
Andy Baviereda466b2021-08-27 15:00:36 -0700201 $(5GC_CONTROL_PLANE_CHART) && \
Badhrinath3e081e22020-12-02 15:02:08 -0600202 kubectl wait pod -n omec --for=condition=Ready -l release=fgc-core --timeout=300s && \
203 helm upgrade --install $(HELM_GLOBAL_ARGS) \
204 --namespace omec \
Ajay Lotan Thakurdcc602e2021-05-20 11:16:26 -0600205 --values $(AIABVALUES) \
Badhrinath3e081e22020-12-02 15:02:08 -0600206 5g-ransim-plane \
Andy Baviereda466b2021-08-27 15:00:36 -0700207 $(5G_RAN_SIM_CHART) && \
Badhrinath3e081e22020-12-02 15:02:08 -0600208 kubectl wait pod -n omec --for=condition=Ready -l release=5g-ransim-plane --timeout=300s
209 touch $@
210
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700211# UE images includes kernel module, ue_ip.ko
212# which should be built in the exactly same kernel version of the host machine
213$(BUILD)/openairinterface: | $(M)/setup
214 mkdir -p $(BUILD)
215 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
216
217$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
218 cd $(BUILD)/openairinterface; \
219 sudo docker build . --target lte-uesoftmodem \
Hyunsun7b640512020-10-27 19:49:51 -0500220 --build-arg build_base=omecproject/oai-base:1.1.0 \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700221 --file Dockerfile.ue \
Hyunsun7b640512020-10-27 19:49:51 -0500222 --tag omecproject/lte-uesoftmodem:1.1.0
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700223 touch $@
224
225$(M)/oaisim: | $(M)/ue-image $(M)/omec
226 sudo ip addr add 127.0.0.2/8 dev lo || true
227 $(eval mme_iface=$(shell ip -4 route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
Hyunsun7b640512020-10-27 19:49:51 -0500228 helm upgrade --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(AIABVALUES) \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700229 --set config.enb.networks.s1_mme.interface=$(mme_iface) \
230 --set images.pullPolicy=IfNotPresent
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700231 kubectl rollout status -n omec statefulset ue
232 @timeout 60s bash -c \
233 "until ip addr show oip1 | grep -q inet; \
234 do \
235 echo 'Waiting for UE 1 gets IP address'; \
236 sleep 3; \
237 done"
238 touch $@
239
240test: | $(M)/fabric $(M)/omec $(M)/oaisim
241 @sleep 5
242 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500243 ping -I oip1 192.168.250.1 -c 15
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700244 @echo "Test2: ping from UE to 8.8.8.8"
245 ping -I oip1 8.8.8.8 -c 3
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500246 @echo "Test3: ping from UE to google.com"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700247 ping -I oip1 google.com -c 3
248 @echo "Finished to test"
249
250reset-test:
Scott Baker17b70d12020-09-29 23:26:21 -0700251 helm delete -n omec oaisim || true
252 helm delete -n omec omec-control-plane || true
253 helm delete -n omec omec-user-plane || true
Jeremy Ronquillob2b64ea2020-12-09 13:49:03 -0800254 kubectl delete po router || true
255 cd $(M); rm -f oaisim omec fabric
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700256
Badhrinath3e081e22020-12-02 15:02:08 -0600257reset-5g-test:
Ajay Lotan Thakur980823b2021-06-23 18:55:05 -0500258 helm uninstall -n omec sim-app || true
Badhrinath3e081e22020-12-02 15:02:08 -0600259 helm uninstall -n omec fgc-core || true
260 helm uninstall -n omec 5g-core-up || true
261 helm uninstall -n omec 5g-ransim-plane || true
262 helm uninstall -n omec mongo || true
263 cd $(M); rm -f 5g-core
264
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700265clean: reset-test
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700266 kubectl delete po router || true
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700267 kubectl delete net-attach-def core-net || true
268 sudo ovs-vsctl del-br br-access-net || true
269 sudo ovs-vsctl del-br br-core-net || true
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700270 sudo apt remove --purge openvswitch-switch -y
271 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
272 ansible-playbook -b -i inventory/local/hosts.ini reset.yml
273 @if [ -d /usr/local/etc/emulab ]; then \
274 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
275 sudo rm -rf /mnt/extra/kubelet; \
276 fi
277 rm -rf $(M)