blob: 1bf539364d05137256069c2bf7c26326517f4d92 [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
77 sudo apt update; sudo apt install -y software-properties-common python-pip jq httpie ipvsadm
78 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
85 sudo pip install virtualenv
86 virtualenv $(VENV)
87
88$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
89 source "$(VENV)/bin/activate" && \
90 pip install -r $(BUILD)/kubespray/requirements.txt
91 touch $@
92
93$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
94 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
95 ansible-playbook -b -i inventory/local/hosts.ini \
96 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
97 -e "{'docker_version' : $(DOCKER_VERSION)}" \
98 -e "{'docker_iptables_enabled' : True}" \
99 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun84f0f172020-09-23 15:40:08 -0500100 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700101 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
102 -e "{'kube_pods_subnet' : 192.168.0.0/17, 'kube_service_addresses' : 192.168.128.0/17}" \
103 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
104 -e "{'kubeadm_enabled': True}" \
105 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
106 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*]}" \
107 -e "{'dns_min_replicas' : 1}" \
108 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
109 cluster.yml
110 mkdir -p $(HOME)/.kube
111 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
112 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
113 kubectl wait pod -n kube-system --for=condition=Ready --all
114 touch $@
115
116$(M)/helm-ready: | $(M)/k8s-ready
Woojoong Kim8425cb32021-01-08 16:18:53 -0800117 helm repo add incubator https://charts.helm.sh/incubator
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700118 helm repo add cord https://charts.opencord.org
119 touch $@
120
121/opt/cni/bin/simpleovs: | $(M)/k8s-ready
122 sudo cp $(RESOURCEDIR)/simpleovs /opt/cni/bin/
123
124/opt/cni/bin/static: | $(M)/k8s-ready
125 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
126 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
127 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
128 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
129
130# TODO: need to connect ONOS
131$(M)/fabric: | $(M)/setup /opt/cni/bin/simpleovs /opt/cni/bin/static
132 sudo apt install -y openvswitch-switch
133 sudo ovs-vsctl --may-exist add-br br-enb-net
134 sudo ovs-vsctl --may-exist add-port br-enb-net enb -- set Interface enb type=internal
135 sudo ip addr add 192.168.251.4/24 dev enb || true
136 sudo ip link set enb up
137 sudo ethtool --offload enb tx off
138 sudo ip route replace 192.168.252.0/24 via 192.168.251.1 dev enb
139 kubectl apply -f $(RESOURCEDIR)/router.yaml
140 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
Jeremy Ronquillob2b64ea2020-12-09 13:49:03 -0800141 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 -0700142 kubectl delete net-attach-def core-net
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700143 touch $@
144
145$(M)/omec: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
Scott Baker17b70d12020-09-29 23:26:21 -0700146 kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700147 helm repo update
Hyunsun7b640512020-10-27 19:49:51 -0500148 helm dep up $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane
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-control-plane \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700153 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane && \
Hyunsun7b640512020-10-27 19:49:51 -0500154 kubectl wait pod -n omec --for=condition=Ready -l release=omec-control-plane --timeout=300s && \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700155 helm upgrade --install $(HELM_GLOBAL_ARGS) \
156 --namespace omec \
Jeremy Ronquillod3cab742020-08-24 11:49:00 -0700157 --values $(AIABVALUES) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700158 omec-user-plane \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700159 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \
Hyunsun7b640512020-10-27 19:49:51 -0500160 kubectl wait pod -n omec --for=condition=Ready -l release=omec-user-plane --timeout=300s
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700161 touch $@
162
Badhrinath3e081e22020-12-02 15:02:08 -0600163$(M)/5g-core: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
164 kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
165 helm repo update
166 helm dep up $(WORKSPACE)/cord/aether-helm-charts/omec/5g-control-plane
167 helm upgrade --install $(HELM_GLOBAL_ARGS) \
168 --namespace omec \
169 --values $(AIABVALUES) \
170 5g-core-up \
171 $(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \
172 kubectl wait pod -n omec --for=condition=Ready -l release=5g-core-up --timeout=300s
173 helm upgrade --install $(HELM_GLOBAL_ARGS) \
174 --namespace omec \
175 --values $(AIABVALUES) \
176 fgc-core \
177 $(WORKSPACE)/cord/aether-helm-charts/omec/5g-control-plane && \
178 kubectl wait pod -n omec --for=condition=Ready -l release=fgc-core --timeout=300s && \
179 helm upgrade --install $(HELM_GLOBAL_ARGS) \
180 --namespace omec \
181 5g-ransim-plane \
182 $(WORKSPACE)/cord/aether-helm-charts/omec/5g-ran-sim && \
183 kubectl wait pod -n omec --for=condition=Ready -l release=5g-ransim-plane --timeout=300s
184 touch $@
185
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700186# UE images includes kernel module, ue_ip.ko
187# which should be built in the exactly same kernel version of the host machine
188$(BUILD)/openairinterface: | $(M)/setup
189 mkdir -p $(BUILD)
190 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
191
192$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
193 cd $(BUILD)/openairinterface; \
194 sudo docker build . --target lte-uesoftmodem \
Hyunsun7b640512020-10-27 19:49:51 -0500195 --build-arg build_base=omecproject/oai-base:1.1.0 \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700196 --file Dockerfile.ue \
Hyunsun7b640512020-10-27 19:49:51 -0500197 --tag omecproject/lte-uesoftmodem:1.1.0
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700198 touch $@
199
200$(M)/oaisim: | $(M)/ue-image $(M)/omec
201 sudo ip addr add 127.0.0.2/8 dev lo || true
202 $(eval mme_iface=$(shell ip -4 route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
Hyunsun7b640512020-10-27 19:49:51 -0500203 helm upgrade --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(AIABVALUES) \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700204 --set config.enb.networks.s1_mme.interface=$(mme_iface) \
205 --set images.pullPolicy=IfNotPresent
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700206 kubectl rollout status -n omec statefulset ue
207 @timeout 60s bash -c \
208 "until ip addr show oip1 | grep -q inet; \
209 do \
210 echo 'Waiting for UE 1 gets IP address'; \
211 sleep 3; \
212 done"
213 touch $@
214
215test: | $(M)/fabric $(M)/omec $(M)/oaisim
216 @sleep 5
217 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500218 ping -I oip1 192.168.250.1 -c 15
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700219 @echo "Test2: ping from UE to 8.8.8.8"
220 ping -I oip1 8.8.8.8 -c 3
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500221 @echo "Test3: ping from UE to google.com"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700222 ping -I oip1 google.com -c 3
223 @echo "Finished to test"
224
225reset-test:
Scott Baker17b70d12020-09-29 23:26:21 -0700226 helm delete -n omec oaisim || true
227 helm delete -n omec omec-control-plane || true
228 helm delete -n omec omec-user-plane || true
Jeremy Ronquillob2b64ea2020-12-09 13:49:03 -0800229 kubectl delete po router || true
230 cd $(M); rm -f oaisim omec fabric
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700231
Badhrinath3e081e22020-12-02 15:02:08 -0600232reset-5g-test:
233 helm uninstall -n omec fgc-core || true
234 helm uninstall -n omec 5g-core-up || true
235 helm uninstall -n omec 5g-ransim-plane || true
236 helm uninstall -n omec mongo || true
237 cd $(M); rm -f 5g-core
238
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700239clean: reset-test
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700240 kubectl delete po router || true
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700241 kubectl delete net-attach-def core-net || true
242 sudo ovs-vsctl del-br br-access-net || true
243 sudo ovs-vsctl del-br br-core-net || true
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700244 sudo apt remove --purge openvswitch-switch -y
245 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
246 ansible-playbook -b -i inventory/local/hosts.ini reset.yml
247 @if [ -d /usr/local/etc/emulab ]; then \
248 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
249 sudo rm -rf /mnt/extra/kubelet; \
250 fi
251 rm -rf $(M)