blob: 78b1c7d069ab6e0ecda34bfc19212a3efe097cb9 [file] [log] [blame]
Jeremy Ronquillo5263c732020-10-13 09:42:19 -07001# Copyright 2018-present Open Networking Foundation
2#
Andy Bavier2c427732022-02-03 15:16:46 -07003# SPDX-License-Identifier: Apache-2.0
Jeremy Ronquillo5263c732020-10-13 09:42:19 -07004
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -07005SHELL := /bin/bash
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -07006MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
Andy Bavier99f31c82022-04-14 16:16:26 -07007BUILD ?= $(MAKEDIR)/build
8M ?= $(BUILD)/milestones
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
Andy Bavierebf479c2021-09-08 15:47:58 -070013
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700144G_CORE_VALUES ?= $(MAKEDIR)/sd-core-4g-values.yaml
155G_CORE_VALUES ?= $(MAKEDIR)/sd-core-5g-values.yaml
Andy Bavierebf479c2021-09-08 15:47:58 -070016OAISIM_VALUES ?= $(MAKEDIR)/oaisim-values.yaml
Andy Bavier794566f2022-02-04 16:10:18 -070017ROC_VALUES ?= $(MAKEDIR)/roc-values.yaml
Andy Bavier794566f2022-02-04 16:10:18 -070018ROC_4G_MODELS ?= $(MAKEDIR)/roc-4g-models.json
19ROC_5G_MODELS ?= $(MAKEDIR)/roc-5g-models.json
Osman Amjad488a0222022-01-12 11:58:43 -060020TEST_APP_VALUES?= $(MAKEDIR)/5g-test-apps-values.yaml
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070021
Hyunsun Moon8c3fe402021-10-04 18:06:07 -070022KUBESPRAY_VERSION ?= release-2.17
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -070023DOCKER_VERSION ?= '20.10'
Hyunsun Mooncbdac112022-03-19 22:01:27 -060024HELM_VERSION ?= v3.6.3
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -070025KUBECTL_VERSION ?= v1.23.0
26
27RKE2_K8S_VERSION ?= v1.23.4+rke2r1
28K8S_VERSION ?= v1.20.11
Hyunsun Mooncbdac112022-03-19 22:01:27 -060029
30ENABLE_ROUTER ?= true
31ENABLE_OAISIM ?= true
32ENABLE_GNBSIM ?= true
Amit Wankhede01b20c32021-12-01 12:45:58 +053033ENABLE_SUBSCRIBER_PROXY ?= false
Andy Baviercd93a202022-01-10 18:03:26 -080034GNBSIM_COLORS ?= true
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070035
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -070036K8S_INSTALL := rke2
Andy Bavier99f31c82022-04-14 16:16:26 -070037CTR_CMD := sudo /var/lib/rancher/rke2/bin/ctr --address /run/k3s/containerd/containerd.sock --namespace k8s.io
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -070038
Hyunsun Mooncbdac112022-03-19 22:01:27 -060039DATA_IFACE ?= data
40ifeq ($(DATA_IFACE), data)
41 RAN_SUBNET := 192.168.251.0/24
42else
43 RAN_SUBNET := $(shell ip route | grep $${DATA_IFACE} | awk '/kernel/ {print $$1}')
Andy Bavier99f31c82022-04-14 16:16:26 -070044 DATA_IFACE_PATH := $(shell find /*/systemd/network -maxdepth 1 -not -type d -name '*$(DATA_IFACE).network' -print)
45 DATA_IFACE_CONF ?= $(shell basename $(DATA_IFACE_PATH)).d
Hyunsun Mooncbdac112022-03-19 22:01:27 -060046endif
Hyunsun Moon4e5795a2022-04-07 09:27:12 -070047
Andy Bavier99f31c82022-04-14 16:16:26 -070048# systemd-networkd and systemd configs
49LO_NETCONF := /etc/systemd/network/20-aiab-lo.network
50OAISIM_NETCONF := $(LO_NETCONF) /etc/systemd/network/10-aiab-enb.netdev /etc/systemd/network/20-aiab-enb.network
51ROUTER_POD_NETCONF := /etc/systemd/network/10-aiab-dummy.netdev /etc/systemd/network/20-aiab-dummy.network
52ROUTER_HOST_NETCONF := /etc/systemd/network/10-aiab-access.netdev /etc/systemd/network/20-aiab-access.network /etc/systemd/network/10-aiab-core.netdev /etc/systemd/network/20-aiab-core.network /etc/systemd/network/$(DATA_IFACE_CONF)/macvlan.conf
53UE_NAT_CONF := /etc/systemd/system/aiab-ue-nat.service
54
Hyunsun Moon4e5795a2022-04-07 09:27:12 -070055NODE_IP ?= $(shell ip route get 8.8.8.8 | grep -oP 'src \K\S+')
56ifndef NODE_IP
57$(error NODE_IP is not set)
58endif
59
Hyunsun Mooncbdac112022-03-19 22:01:27 -060060MME_IP ?=
61
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070062HELM_GLOBAL_ARGS ?=
Andy Baviereda466b2021-08-27 15:00:36 -070063
64# Allow installing local charts or specific versions of published charts.
65# E.g., to install the Aether 1.5 release:
66# CHARTS=release-1.5 make test
67# Default is to install from the local charts.
68CHARTS ?= local
69CONFIGFILE := configs/$(CHARTS)
70include $(CONFIGFILE)
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070071
72cpu_family := $(shell lscpu | grep 'CPU family:' | awk '{print $$3}')
73cpu_model := $(shell lscpu | grep 'Model:' | awk '{print $$2}')
74os_vendor := $(shell lsb_release -i -s)
75os_release := $(shell lsb_release -r -s)
Andy Bavier9ee69d02022-02-11 10:31:21 -070076USER := $(shell whoami)
77
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -070078.PHONY: 4g-core 5g-core oaisim test reset-test reset-ue reset-5g-test node-prep clean
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070079
80$(M):
81 mkdir -p $(M)
82
83$(M)/system-check: | $(M)
84 @if [[ $(cpu_family) -eq 6 ]]; then \
85 if [[ $(cpu_model) -lt 60 ]]; then \
86 echo "FATAL: haswell CPU or newer is required."; \
87 exit 1; \
88 fi \
89 else \
90 echo "FATAL: unsupported CPU family."; \
91 exit 1; \
92 fi
93 @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \
Hyunsun7b640512020-10-27 19:49:51 -050094 if [[ ! $(os_release) =~ (18.04) ]]; then \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070095 echo "WARN: $(os_vendor) $(os_release) has not been tested."; \
96 fi; \
97 if dpkg --compare-versions 4.15 gt $(shell uname -r); then \
98 echo "FATAL: kernel 4.15 or later is required."; \
99 echo "Please upgrade your kernel by running" \
100 "apt install --install-recommends linux-generic-hwe-$(os_release)"; \
101 exit 1; \
102 fi \
103 else \
104 echo "FAIL: unsupported OS."; \
105 exit 1; \
106 fi
107 touch $@
108
Andy Bavier99f31c82022-04-14 16:16:26 -0700109$(M)/interface-check: | $(M)
110ifeq ($(DATA_IFACE_CONF), .d)
111 @echo
112 @echo FATAL: Could not find systemd-networkd config for interface $(DATA_IFACE), exiting now!; exit 1
113endif
114 touch $@
115
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700116ifeq ($(K8S_INSTALL),kubespray)
Andy Bavier99f31c82022-04-14 16:16:26 -0700117$(M)/setup: | $(M) $(M)/interface-check
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700118 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
Hyunsun Moon82e47c22021-06-28 12:30:20 -0500119 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 -0700120 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700121endif
122
123ifeq ($(K8S_INSTALL),rke2)
Andy Bavier99f31c82022-04-14 16:16:26 -0700124$(M)/setup: | $(M) $(M)/interface-check
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700125 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
126 sudo apt update; sudo apt install -y software-properties-common python3 python3-pip python3-venv jq httpie ipvsadm apparmor apparmor-utils
127 systemctl list-units --full -all | grep "docker.service" || sudo apt install -y docker.io
128 sudo adduser $(USER) docker || true
129 touch $@
130endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700131
132$(BUILD)/kubespray: | $(M)/setup
133 mkdir -p $(BUILD)
134 cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
135
136$(VENV)/bin/activate: | $(M)/setup
Hyunsun Moon82e47c22021-06-28 12:30:20 -0500137 python3 -m venv $(VENV)
Wei-Yu Chen7edb7e72021-07-28 11:37:55 +0800138 source "$(VENV)/bin/activate" && \
139 python -m pip install -U pip && \
140 deactivate
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700141
142$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
143 source "$(VENV)/bin/activate" && \
144 pip install -r $(BUILD)/kubespray/requirements.txt
145 touch $@
146
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700147ifeq ($(K8S_INSTALL),kubespray)
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700148$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
149 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
150 ansible-playbook -b -i inventory/local/hosts.ini \
151 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
152 -e "{'docker_version' : $(DOCKER_VERSION)}" \
153 -e "{'docker_iptables_enabled' : True}" \
154 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun84f0f172020-09-23 15:40:08 -0500155 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700156 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600157 -e "{'kube_pods_subnet' : 192.168.84.0/24, 'kube_service_addresses' : 192.168.85.0/24}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700158 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
159 -e "{'kubeadm_enabled': True}" \
160 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600161 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*, --node-ip=$(NODE_IP)]}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700162 -e "{'dns_min_replicas' : 1}" \
163 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
164 cluster.yml
165 mkdir -p $(HOME)/.kube
166 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
167 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
168 kubectl wait pod -n kube-system --for=condition=Ready --all
Andy Bavier9ee69d02022-02-11 10:31:21 -0700169 sudo adduser $(USER) docker
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700170 touch $@
171
172$(M)/helm-ready: | $(M)/k8s-ready
Woojoong Kim8425cb32021-01-08 16:18:53 -0800173 helm repo add incubator https://charts.helm.sh/incubator
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700174 helm repo add cord https://charts.opencord.org
Andy Baviereda466b2021-08-27 15:00:36 -0700175 helm repo add atomix https://charts.atomix.io
176 helm repo add onosproject https://charts.onosproject.org
Andy Bavier9ee69d02022-02-11 10:31:21 -0700177 helm repo add aether https://charts.aetherproject.org
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700178 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700179endif
180
181ifeq ($(K8S_INSTALL),rke2)
182$(M)/k8s-ready: | $(M)/setup
183 sudo mkdir -p /etc/rancher/rke2/
184 [ -d /usr/local/etc/emulab ] && [ ! -e /var/lib/rancher ] && sudo ln -s /var/lib/rancher /mnt/extra/rancher || true # that link gets deleted on cleanup
185 echo "cni: multus,calico" >> config.yaml
186 echo "cluster-cidr: 192.168.84.0/24" >> config.yaml
187 echo "service-cidr: 192.168.85.0/24" >> config.yaml
188 echo "kubelet-arg:" >> config.yaml
189 echo "- --allowed-unsafe-sysctls="net.*"" >> config.yaml
190 echo "- --node-ip="$(NODE_IP)"" >> config.yaml
191 echo "pause-image: k8s.gcr.io/pause:3.3" >> config.yaml
192 echo "kube-proxy-arg:" >> config.yaml
193 echo "- --metrics-bind-address="0.0.0.0:10249"" >> config.yaml
194 echo "- --proxy-mode="ipvs"" >> config.yaml
195 echo "kube-apiserver-arg:" >> config.yaml
196 echo "- --service-node-port-range="2000-36767"" >> config.yaml
197 sudo mv config.yaml /etc/rancher/rke2/
198 curl -sfL https://get.rke2.io | sudo INSTALL_RKE2_VERSION=$(RKE2_K8S_VERSION) sh -
199 sudo systemctl enable rke2-server.service
200 sudo systemctl start rke2-server.service
201 sudo /var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml wait nodes --for=condition=Ready --all --timeout=300s
202 sudo /var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml wait deployment -n kube-system --for=condition=available --all --timeout=300s
203 curl -LO "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
204 sudo chmod +x kubectl
205 sudo mv kubectl /usr/local/bin/
206 kubectl version --client
207 mkdir -p $(HOME)/.kube
208 sudo cp /etc/rancher/rke2/rke2.yaml $(HOME)/.kube/config
209 sudo chown -R $(shell id -u):$(shell id -g) $(HOME)/.kube
210 touch $@
211
212$(M)/helm-ready: | $(M)/k8s-ready
213 curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
214 chmod 700 get_helm.sh
215 sudo DESIRED_VERSION=$(HELM_VERSION) ./get_helm.sh
216 helm repo add incubator https://charts.helm.sh/incubator
217 helm repo add cord https://charts.opencord.org
218 helm repo add atomix https://charts.atomix.io
219 helm repo add onosproject https://charts.onosproject.org
220 helm repo add aether https://charts.aetherproject.org
221 touch $@
222endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700223
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700224/opt/cni/bin/static: | $(M)/k8s-ready
225 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
226 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
227 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
228 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
229
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600230node-prep: | $(M)/helm-ready /opt/cni/bin/static
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700231
Andy Bavier99f31c82022-04-14 16:16:26 -0700232$(M)/router-pod: $(ROUTER_POD_NETCONF)
233 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600234 DATA_IFACE=$(DATA_IFACE) envsubst < $(RESOURCEDIR)/router.yaml | kubectl apply -f -
235 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
236 @touch $@
237
Andy Bavier99f31c82022-04-14 16:16:26 -0700238$(M)/router-host: $(ROUTER_HOST_NETCONF) $(UE_NAT_CONF)
239 sudo systemctl daemon-reload
240 sudo systemctl enable aiab-ue-nat.service
241 sudo systemctl start aiab-ue-nat.service
242 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600243 $(eval oiface := $(shell ip route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600244 @touch $@
245
2464g-core: node-prep
247ifeq ($(ENABLE_ROUTER),true)
248ifeq ($(ENABLE_OAISIM),true)
2494g-core: $(M)/router-pod
250else
2514g-core: $(M)/router-host
252endif
253endif
2544g-core: $(M)/omec
255$(M)/omec:
256 @if [[ "${CHARTS}" == "local" || "${CHARTS}" == "local-sdcore" ]]; then \
257 helm dep up $(SD_CORE_CHART); \
258 else \
259 helm repo update; \
260 fi
261 NODE_IP=${NODE_IP} DATA_IFACE=${DATA_IFACE} RAN_SUBNET=${RAN_SUBNET} envsubst < $(4G_CORE_VALUES) | \
262 helm upgrade --create-namespace --install --wait $(HELM_GLOBAL_ARGS) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700263 --namespace omec \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600264 --values - \
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700265 sd-core \
266 $(SD_CORE_CHART)
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600267 @if [[ "${ENABLE_OAISIM}" == "false" ]]; then \
268 $(eval mme_ip := $(shell ip -4 -o addr show $${DATA_IFACE} | awk '{print $$4}' | cut -d'/' -f1)) \
269 echo "Your MME IP is $(mme_ip)"; \
270 fi
271 @touch $@
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700272
Hyunsun Mooncbdac112022-03-19 22:01:27 -06002735g-core: node-prep
274ifeq ($(ENABLE_ROUTER),true)
275ifeq ($(ENABLE_GNBSIM),true)
2765g-core: $(M)/router-pod
277else
2785g-core: $(M)/router-host
279endif
280endif
2815g-core: $(M)/5g-core
282$(M)/5g-core:
283 @if [[ "${CHARTS}" == "local" || "${CHARTS}" == "local-sdcore" ]]; then \
284 helm dep up $(SD_CORE_CHART); \
285 else \
286 helm repo update; \
287 fi
288 NODE_IP=${NODE_IP} DATA_IFACE=${DATA_IFACE} RAN_SUBNET=${RAN_SUBNET} envsubst < $(5G_CORE_VALUES) | \
289 helm upgrade --create-namespace --install --wait $(HELM_GLOBAL_ARGS) \
Badhrinath3e081e22020-12-02 15:02:08 -0600290 --namespace omec \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600291 --values - \
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700292 sd-core \
293 $(SD_CORE_CHART)
Badhrinath3e081e22020-12-02 15:02:08 -0600294 touch $@
295
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700296# UE images includes kernel module, ue_ip.ko
297# which should be built in the exactly same kernel version of the host machine
298$(BUILD)/openairinterface: | $(M)/setup
299 mkdir -p $(BUILD)
300 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
301
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700302ifeq ($(K8S_INSTALL),kubespray)
303download-ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
Andy Bavier9ee69d02022-02-11 10:31:21 -0700304 sg docker -c "docker pull ${OAISIM_UE_IMAGE} && \
305 docker tag ${OAISIM_UE_IMAGE} omecproject/lte-uesoftmodem:1.1.0"
Andy Bavierd6de5612021-11-08 10:39:17 -0700306 touch $(M)/ue-image
307
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700308$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
309 cd $(BUILD)/openairinterface; \
Andy Bavier9ee69d02022-02-11 10:31:21 -0700310 sg docker -c "docker build . --target lte-uesoftmodem \
Hyunsun7b640512020-10-27 19:49:51 -0500311 --build-arg build_base=omecproject/oai-base:1.1.0 \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700312 --file Dockerfile.ue \
Andy Bavier9ee69d02022-02-11 10:31:21 -0700313 --tag omecproject/lte-uesoftmodem:1.1.0"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700314 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700315endif
316
317ifeq ($(K8S_INSTALL),rke2)
318download-ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
319 sg docker -c "docker pull ${OAISIM_UE_IMAGE} && \
320 docker tag ${OAISIM_UE_IMAGE} omecproject/lte-uesoftmodem:1.1.0 && \
321 docker save -o /tmp/lte-uesoftmodem.tar omecproject/lte-uesoftmodem:1.1.0"
322 $(CTR_CMD) images import /tmp/lte-uesoftmodem.tar
323 touch $(M)/ue-image
324
325$(M)/ue-image: $(M)/k8s-ready $(BUILD)/openairinterface
326 cd $(BUILD)/openairinterface; \
327 sg docker -c "docker build . --target lte-uesoftmodem \
328 --build-arg build_base=omecproject/oai-base:1.1.0 \
329 --file Dockerfile.ue \
330 --tag omecproject/lte-uesoftmodem:1.1.0 && \
331 docker save -o /tmp/lte-uesoftmodem.tar omecproject/lte-uesoftmodem:1.1.0"
332 $(CTR_CMD) images import /tmp/lte-uesoftmodem.tar
333 touch $@
334endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700335
Andy Bavier99f31c82022-04-14 16:16:26 -0700336/etc/systemd/%:
337 @sudo mkdir -p $(@D)
338 @sed 's/DATA_IFACE/$(DATA_IFACE)/g' $(MAKEDIR)/systemd/$(@F) > /tmp/$(@F)
339 @sudo cp /tmp/$(@F) $@
340 echo "Installed $@"
Andy Bavier9ee69d02022-02-11 10:31:21 -0700341
Andy Bavier99f31c82022-04-14 16:16:26 -0700342oaisim-standalone: | $(M)/helm-ready $(M)/ue-image $(LO_NETCONF)
343 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600344 @ip link show $(DATA_IFACE) > /dev/null || (echo DATA_IFACE is not set or does not exist; exit 1)
345 @if [[ "${MME_IP}" == "" ]]; then \
346 echo MME_IP is not set; \
347 exit 1; \
348 else \
349 ping -c 3 $(MME_IP) > /dev/null || (echo MME $(MME_IP) is not reachable; exit 1) \
350 fi
351 sudo ip route add 192.168.252.0/24 via $(MME_IP)
Andy Bavier7b01b682022-03-17 13:26:55 -0700352 helm repo update
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600353 helm upgrade --create-namespace --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(OAISIM_VALUES) \
354 --set config.enb.networks.s1u.interface=$(DATA_IFACE) \
355 --set config.enb.networks.s1_mme.interface=$(DATA_IFACE) \
356 --set config.enb.mme.address=$(MME_IP) \
357 --set config.enb.mme.isLocal=false \
358 --set images.pullPolicy=IfNotPresent
Andy Bavier7b01b682022-03-17 13:26:55 -0700359 kubectl rollout status -n omec statefulset ue
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600360 @echo "Test: registration"
Andy Bavier7b01b682022-03-17 13:26:55 -0700361 @timeout 60s bash -c \
362 "until ip addr show oip1 | grep -q inet; \
363 do \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600364 echo 'Waiting for UE 1 gets IP address'; \
365 sleep 3; \
Andy Bavier7b01b682022-03-17 13:26:55 -0700366 done"
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600367 @echo "Test: ping from UE to 8.8.8.8"
368 ping -I oip1 8.8.8.8 -c 3
369 @touch $(M)/oaisim $(M)/omec
Andy Bavier7b01b682022-03-17 13:26:55 -0700370
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600371oaisim: | $(M)/oaisim
Andy Bavier99f31c82022-04-14 16:16:26 -0700372$(M)/oaisim: | $(M)/ue-image $(M)/router-pod $(OAISIM_NETCONF)
373 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600374 helm upgrade --create-namespace --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(OAISIM_VALUES) \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700375 --set images.pullPolicy=IfNotPresent
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700376 kubectl rollout status -n omec statefulset ue
377 @timeout 60s bash -c \
378 "until ip addr show oip1 | grep -q inet; \
379 do \
380 echo 'Waiting for UE 1 gets IP address'; \
381 sleep 3; \
382 done"
383 touch $@
384
Andy Bavierebf479c2021-09-08 15:47:58 -0700385roc: $(M)/roc
386$(M)/roc: $(M)/helm-ready
387 kubectl get namespace aether-roc 2> /dev/null || kubectl create namespace aether-roc
388 helm repo update
389 if [ "$(CHARTS)" == "local" ]; then helm dep up $(AETHER_ROC_UMBRELLA_CHART); fi
390 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
391 --namespace kube-system \
392 --values $(ROC_VALUES) \
393 atomix-controller \
394 $(ATOMIX_CONTROLLER_CHART)
395 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
396 --namespace kube-system \
397 --values $(ROC_VALUES) \
398 atomix-raft-storage \
399 $(ATOMIX_RAFT_STORAGE_CHART)
400 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
401 --namespace kube-system \
402 --values $(ROC_VALUES) \
403 onos-operator \
404 $(ONOS_OPERATOR_CHART)
405 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
406 --namespace aether-roc \
407 --values $(ROC_VALUES) \
408 aether-roc-umbrella \
409 $(AETHER_ROC_UMBRELLA_CHART)
410 touch $@
411
412# Load the ROC 4G models. Disable loading network slice from SimApp.
413roc-4g-models: $(M)/roc
414 sed -i 's/provision-network-slice: true/provision-network-slice: false/' $(4G_CORE_VALUES)
415 sed -i 's/# syncUrl/syncUrl/' $(4G_CORE_VALUES)
Amit Wankhede01b20c32021-12-01 12:45:58 +0530416 if [ "${ENABLE_SUBSCRIBER_PROXY}" == "true" ] ; then \
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600417 sed -i 's/# sub-proxy-endpt:/sub-proxy-endpt:/' $(4G_CORE_VALUES) ; \
418 sed -i 's/# addr: sub/ addr: sub/' $(4G_CORE_VALUES) ; \
419 sed -i 's/# port: 5000/ port: 5000/' $(4G_CORE_VALUES) ; \
Amit Wankhede01b20c32021-12-01 12:45:58 +0530420 fi
Andy Bavierebf479c2021-09-08 15:47:58 -0700421 $(eval ONOS_CLI_POD := $(shell kubectl -n aether-roc get pods -l name=onos-cli -o name))
422 echo "ONOS CLI pod: ${ONOS_CLI_POD}"
423 until kubectl -n aether-roc exec ${ONOS_CLI_POD} -- \
424 curl -s -f -L -X PATCH "http://aether-roc-api:8181/aether-roc-api" \
425 --header 'Content-Type: application/json' \
426 --data-raw "$$(cat ${ROC_4G_MODELS})"; do sleep 5; done
427
428# Load the ROC 5G models. Disable loading network slice from SimApp.
429roc-5g-models: $(M)/roc
430 sed -i 's/provision-network-slice: true/provision-network-slice: false/' $(5G_CORE_VALUES)
431 sed -i 's/# syncUrl/syncUrl/' $(5G_CORE_VALUES)
Amit Wankhede01b20c32021-12-01 12:45:58 +0530432 if [ "${ENABLE_SUBSCRIBER_PROXY}" == "true" ] ; then \
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600433 sed -i 's/# sub-proxy-endpt:/sub-proxy-endpt:/' $(5G_CORE_VALUES) ; \
434 sed -i 's/# addr: sub/ addr: sub/' $(5G_CORE_VALUES) ; \
435 sed -i 's/# port: 5000/ port: 5000/' $(5G_CORE_VALUES) ; \
Amit Wankhede01b20c32021-12-01 12:45:58 +0530436 fi
Andy Bavierebf479c2021-09-08 15:47:58 -0700437 $(eval ONOS_CLI_POD := $(shell kubectl -n aether-roc get pods -l name=onos-cli -o name))
438 echo "ONOS CLI pod: ${ONOS_CLI_POD}"
439 until kubectl -n aether-roc exec ${ONOS_CLI_POD} -- \
440 curl -s -f -L -X PATCH "http://aether-roc-api:8181/aether-roc-api" \
441 --header 'Content-Type: application/json' \
442 --data-raw "$$(cat ${ROC_5G_MODELS})"; do sleep 5; done
443
444roc-clean:
445 @echo "This could take 2-3 minutes..."
446 sed -i 's/provision-network-slice: false/provision-network-slice: true/' $(4G_CORE_VALUES)
447 sed -i 's/ syncUrl/ # syncUrl/' $(4G_CORE_VALUES)
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600448 sed -i 's/ sub-proxy-endpt:/ # sub-proxy-endpt:/' $(4G_CORE_VALUES)
449 sed -i 's/ addr: sub/ # addr: sub/' $(4G_CORE_VALUES)
450 sed -i 's/ port: 5000/ # port: 5000/' $(4G_CORE_VALUES)
Andy Bavierebf479c2021-09-08 15:47:58 -0700451 sed -i 's/provision-network-slice: false/provision-network-slice: true/' $(5G_CORE_VALUES)
452 sed -i 's/ syncUrl/ # syncUrl/' $(5G_CORE_VALUES)
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600453 sed -i 's/ sub-proxy-endpt:/ # sub-proxy-endpt:/' $(5G_CORE_VALUES)
454 sed -i 's/ addr: sub/ # addr: sub/' $(5G_CORE_VALUES)
455 sed -i 's/ port: 5000/ # port: 5000/' $(5G_CORE_VALUES)
Andy Bavierebf479c2021-09-08 15:47:58 -0700456 kubectl delete namespace aether-roc || true
457 rm -rf $(M)/roc
458
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600459omec-clean:
460 helm delete -n omec $$(helm -n omec ls -qa) || true
461 @echo ""
462 @echo "Wait for all pods to terminate..."
463 kubectl wait -n omec --for=delete --all=true -l app!=ue pod --timeout=180s || true
464
465router-clean:
466 @kubectl delete net-attach-def router-net 2>/dev/null || true
467 @kubectl delete po router 2>/dev/null || true
468 kubectl wait --for=delete -l app=router pod --timeout=180s 2>/dev/null || true
469 sudo ip link del access || true
470 sudo ip link del core || true
471 $(eval oiface := $(shell ip route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
472 sudo iptables -t nat -D POSTROUTING -s 172.250.0.0/16 -o $(oiface) -j MASQUERADE || true
473 @sudo ip link del data 2>/dev/null || true
474 @cd $(M); rm -f router-pod router-host
475
476oaisim-clean: reset-ue
477 @sudo ip addr del 127.0.0.2/8 dev lo 2>/dev/null || true
478 @sudo ip link del enb 2>/dev/null || true
479 @sudo ip route del 192.168.252.0/24 || true
480 @cd $(M); rm -f oaisim-lo
481
482test: | 4g-core $(M)/oaisim
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700483 @sleep 5
484 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500485 ping -I oip1 192.168.250.1 -c 15
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700486 @echo "Test2: ping from UE to 8.8.8.8"
487 ping -I oip1 8.8.8.8 -c 3
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500488 @echo "Test3: ping from UE to google.com"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700489 ping -I oip1 google.com -c 3
490 @echo "Finished to test"
491
Hyunsun Mooncbdac112022-03-19 22:01:27 -06004925g-test: | 5g-core
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700493 @if [[ "${CHARTS}" == "release-1.6" ]]; then echo "[NOTE] 5G Test not supported for Aether 1.6, exiting..."; exit 1; fi
Andy Bavier0a055a52022-01-07 10:46:17 -0700494 @echo "Test: Registration + UE initiated PDU Session Establishment + User Data packets"
Andy Bavier0e4906f2022-03-03 15:31:48 -0700495 @sleep 60
Andy Bavier0a055a52022-01-07 10:46:17 -0700496 @rm -f /tmp/gnbsim.out
Andy Baviercd93a202022-01-10 18:03:26 -0800497 @if [[ ${GNBSIM_COLORS} == "true" ]]; then \
498 kubectl -n omec exec gnbsim-0 -- ./gnbsim 2>&1 | tee /tmp/gnbsim.out; \
499 else \
500 kubectl -n omec exec gnbsim-0 -- ./gnbsim 2>&1 | sed -u "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tee /tmp/gnbsim.out; \
501 fi
Andy Bavier094d6ef2022-03-08 13:21:52 -0700502 @grep -q "Simulation Result: PASS" /tmp/gnbsim.out
Andy Bavier0a055a52022-01-07 10:46:17 -0700503
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600504reset-test: | oaisim-clean omec-clean router-clean
505 @cd $(M); rm -f omec oaisim 5g-core
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700506
Andy Bavier8819b9f2022-01-28 16:54:06 -0700507reset-ue:
508 helm delete -n omec oaisim || true
509 kubectl wait -n omec --for=delete pod enb-0 || true
510 kubectl wait -n omec --for=delete pod ue-0 || true
511 cd $(M); rm -f oaisim
512
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600513reset-5g-test: omec-clean
Badhrinath3e081e22020-12-02 15:02:08 -0600514 cd $(M); rm -f 5g-core
515
Osman Amjad488a0222022-01-12 11:58:43 -0600516reset-dbtestapp:
517 helm uninstall --namespace omec 5g-test-app
518
Andy Bavier99f31c82022-04-14 16:16:26 -0700519refresh-4g: reset-ue
520 kubectl -n omec delete pod mme-0
521 kubectl wait -n omec --for='condition=ready' pod mme-0 --timeout=300s
522
Osman Amjad488a0222022-01-12 11:58:43 -0600523dbtestapp:
524 helm repo update
525 if [ "$(CHARTS)" == "local" ]; then helm dep up $(5G_TEST_APPS_CHART); fi
526 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
527 --namespace omec \
528 5g-test-app \
529 --values $(TEST_APP_VALUES) \
530 $(5G_TEST_APPS_CHART)
531 @echo "Finished to dbtestapp"
532
Andy Bavier99f31c82022-04-14 16:16:26 -0700533clean-systemd:
534 cd /etc/systemd/network && sudo rm -f 10-aiab* 20-aiab* */macvlan.conf
535 cd /etc/systemd/system && sudo rm -f aiab*.service && sudo systemctl daemon-reload
536
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700537ifeq ($(K8S_INSTALL),rke2)
Andy Bavier5b5ad562022-04-19 13:02:31 -0700538clean: | roc-clean oaisim-clean router-clean clean-systemd
Andy Bavier99f31c82022-04-14 16:16:26 -0700539 sudo /usr/local/bin/rke2-uninstall.sh || true
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700540 sudo rm -rf /usr/local/bin/kubectl
541 rm -rf $(M)
542endif
543
544ifeq ($(K8S_INSTALL),kubespray)
Andy Bavier5b5ad562022-04-19 13:02:31 -0700545clean: | roc-clean oaisim-clean router-clean clean-systemd
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700546 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
Andy Bavier125baa02021-10-26 16:26:44 -0700547 ansible-playbook -b -i inventory/local/hosts.ini reset.yml --extra-vars "reset_confirmation=yes"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700548 @if [ -d /usr/local/etc/emulab ]; then \
549 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
550 sudo rm -rf /mnt/extra/kubelet; \
551 fi
552 rm -rf $(M)
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700553endif