blob: a606667a6b0717e8b0080940392931ea6f2cf899 [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 Rouzbeh85654e72022-05-23 09:26: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
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -070039PROXY_ENABLED ?= false
40HTTP_PROXY ?= ${http_proxy}
41HTTPS_PROXY ?= ${https_proxy}
42NO_PROXY ?= ${no_proxy}
43
44ONECLOUD ?= false
45
Hyunsun Mooncbdac112022-03-19 22:01:27 -060046DATA_IFACE ?= data
47ifeq ($(DATA_IFACE), data)
48 RAN_SUBNET := 192.168.251.0/24
49else
50 RAN_SUBNET := $(shell ip route | grep $${DATA_IFACE} | awk '/kernel/ {print $$1}')
Andy Bavier99f31c82022-04-14 16:16:26 -070051 DATA_IFACE_PATH := $(shell find /*/systemd/network -maxdepth 1 -not -type d -name '*$(DATA_IFACE).network' -print)
52 DATA_IFACE_CONF ?= $(shell basename $(DATA_IFACE_PATH)).d
Hyunsun Mooncbdac112022-03-19 22:01:27 -060053endif
Hyunsun Moon4e5795a2022-04-07 09:27:12 -070054
Andy Bavier99f31c82022-04-14 16:16:26 -070055# systemd-networkd and systemd configs
56LO_NETCONF := /etc/systemd/network/20-aiab-lo.network
57OAISIM_NETCONF := $(LO_NETCONF) /etc/systemd/network/10-aiab-enb.netdev /etc/systemd/network/20-aiab-enb.network
58ROUTER_POD_NETCONF := /etc/systemd/network/10-aiab-dummy.netdev /etc/systemd/network/20-aiab-dummy.network
59ROUTER_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
60UE_NAT_CONF := /etc/systemd/system/aiab-ue-nat.service
61
Andy Bavier7d5f0552022-05-23 16:01:45 -070062# monitoring
63RANCHER_MONITORING_CRD_CHART := rancher/rancher-monitoring-crd
64RANCHER_MONITORING_CHART := rancher/rancher-monitoring
65MONITORING_VALUES ?= $(MAKEDIR)/monitoring.yaml
66
Hyunsun Moon4e5795a2022-04-07 09:27:12 -070067NODE_IP ?= $(shell ip route get 8.8.8.8 | grep -oP 'src \K\S+')
68ifndef NODE_IP
69$(error NODE_IP is not set)
70endif
71
Hyunsun Mooncbdac112022-03-19 22:01:27 -060072MME_IP ?=
73
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070074HELM_GLOBAL_ARGS ?=
Andy Baviereda466b2021-08-27 15:00:36 -070075
76# Allow installing local charts or specific versions of published charts.
77# E.g., to install the Aether 1.5 release:
78# CHARTS=release-1.5 make test
79# Default is to install from the local charts.
80CHARTS ?= local
81CONFIGFILE := configs/$(CHARTS)
82include $(CONFIGFILE)
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070083
84cpu_family := $(shell lscpu | grep 'CPU family:' | awk '{print $$3}')
85cpu_model := $(shell lscpu | grep 'Model:' | awk '{print $$2}')
86os_vendor := $(shell lsb_release -i -s)
87os_release := $(shell lsb_release -r -s)
Andy Bavier9ee69d02022-02-11 10:31:21 -070088USER := $(shell whoami)
89
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -070090.PHONY: 4g-core 5g-core oaisim test reset-test reset-ue reset-5g-test node-prep clean
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070091
92$(M):
93 mkdir -p $(M)
94
95$(M)/system-check: | $(M)
96 @if [[ $(cpu_family) -eq 6 ]]; then \
97 if [[ $(cpu_model) -lt 60 ]]; then \
98 echo "FATAL: haswell CPU or newer is required."; \
99 exit 1; \
100 fi \
101 else \
102 echo "FATAL: unsupported CPU family."; \
103 exit 1; \
104 fi
105 @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \
Hyunsun7b640512020-10-27 19:49:51 -0500106 if [[ ! $(os_release) =~ (18.04) ]]; then \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700107 echo "WARN: $(os_vendor) $(os_release) has not been tested."; \
108 fi; \
109 if dpkg --compare-versions 4.15 gt $(shell uname -r); then \
110 echo "FATAL: kernel 4.15 or later is required."; \
111 echo "Please upgrade your kernel by running" \
112 "apt install --install-recommends linux-generic-hwe-$(os_release)"; \
113 exit 1; \
114 fi \
115 else \
116 echo "FAIL: unsupported OS."; \
117 exit 1; \
118 fi
119 touch $@
120
Andy Bavier99f31c82022-04-14 16:16:26 -0700121$(M)/interface-check: | $(M)
122ifeq ($(DATA_IFACE_CONF), .d)
123 @echo
124 @echo FATAL: Could not find systemd-networkd config for interface $(DATA_IFACE), exiting now!; exit 1
125endif
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700126 @echo "Add network configuration for enb interface"
127 @if [[ "${ONECLOUD}" == "true" ]]; then \
128 sudo cp netplan/01-enb-static-config.yaml /etc/netplan ; \
129 sudo netplan apply ; \
130 sleep 1 ; \
131 fi
Andy Bavier99f31c82022-04-14 16:16:26 -0700132 touch $@
133
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700134ifeq ($(K8S_INSTALL),kubespray)
Andy Bavier99f31c82022-04-14 16:16:26 -0700135$(M)/setup: | $(M) $(M)/interface-check
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700136 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
Hyunsun Moon82e47c22021-06-28 12:30:20 -0500137 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 -0700138 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700139endif
140
141ifeq ($(K8S_INSTALL),rke2)
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700142$(M)/initial-setup: | $(M) $(M)/interface-check
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700143 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
144 sudo apt update; sudo apt install -y software-properties-common python3 python3-pip python3-venv jq httpie ipvsadm apparmor apparmor-utils
145 systemctl list-units --full -all | grep "docker.service" || sudo apt install -y docker.io
146 sudo adduser $(USER) docker || true
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700147
148ifeq ($(PROXY_ENABLED),true)
149$(M)/proxy-setting: | $(M)
150 echo "Defaults env_keep += \"HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy no_proxy\"" | sudo EDITOR='tee -a' visudo -f /etc/sudoers.d/proxy
151 echo "HTTP_PROXY=$(HTTP_PROXY)" >> rke2-server
152 echo "HTTPS_PROXY=$(HTTPS_PROXY)" >> rke2-server
153 echo "NO_PROXY=$(NO_PROXY),.cluster.local,.svc,$(NODE_IP),192.168.84.0/24,192.168.85.0/24,$(RAN_SUBNET)" >> rke2-server
154 sudo mv rke2-server /etc/default/
155 echo "[Service]" >> http-proxy.conf
156 echo "Environment='HTTP_PROXY=$(HTTP_PROXY)'" >> http-proxy.conf
157 echo "Environment='HTTPS_PROXY=$(HTTPS_PROXY)'" >> http-proxy.conf
158 echo "Environment='NO_PROXY=$(NO_PROXY)'" >> http-proxy.conf
159 sudo mkdir -p /etc/systemd/system/docker.service.d
160 sudo mv http-proxy.conf /etc/systemd/system/docker.service.d
161 sudo systemctl daemon-reload
162 sudo systemctl restart docker
163 touch $(M)/proxy-setting
164else
165$(M)/proxy-setting: | $(M)
166 @echo -n ""
167 touch $(M)/proxy-setting
168endif
169
170$(M)/setup: | $(M)/initial-setup $(M)/proxy-setting
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700171 touch $@
172endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700173
174$(BUILD)/kubespray: | $(M)/setup
175 mkdir -p $(BUILD)
176 cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
177
178$(VENV)/bin/activate: | $(M)/setup
Hyunsun Moon82e47c22021-06-28 12:30:20 -0500179 python3 -m venv $(VENV)
Wei-Yu Chen7edb7e72021-07-28 11:37:55 +0800180 source "$(VENV)/bin/activate" && \
181 python -m pip install -U pip && \
182 deactivate
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700183
184$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
185 source "$(VENV)/bin/activate" && \
186 pip install -r $(BUILD)/kubespray/requirements.txt
187 touch $@
188
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700189ifeq ($(K8S_INSTALL),kubespray)
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700190$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
191 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
192 ansible-playbook -b -i inventory/local/hosts.ini \
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700193 -e "{'http_proxy' : $(HTTP_PROXY)}" \
194 -e "{'https_proxy' : $(HTTPS_PROXY)}" \
195 -e "{'no_proxy' : $(NO_PROXY)}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700196 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
197 -e "{'docker_version' : $(DOCKER_VERSION)}" \
198 -e "{'docker_iptables_enabled' : True}" \
199 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun84f0f172020-09-23 15:40:08 -0500200 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700201 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600202 -e "{'kube_pods_subnet' : 192.168.84.0/24, 'kube_service_addresses' : 192.168.85.0/24}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700203 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
204 -e "{'kubeadm_enabled': True}" \
205 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600206 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*, --node-ip=$(NODE_IP)]}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700207 -e "{'dns_min_replicas' : 1}" \
208 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
209 cluster.yml
210 mkdir -p $(HOME)/.kube
211 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
212 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
213 kubectl wait pod -n kube-system --for=condition=Ready --all
Andy Bavier9ee69d02022-02-11 10:31:21 -0700214 sudo adduser $(USER) docker
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700215 touch $@
216
217$(M)/helm-ready: | $(M)/k8s-ready
Woojoong Kim8425cb32021-01-08 16:18:53 -0800218 helm repo add incubator https://charts.helm.sh/incubator
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700219 helm repo add cord https://charts.opencord.org
Andy Baviereda466b2021-08-27 15:00:36 -0700220 helm repo add atomix https://charts.atomix.io
221 helm repo add onosproject https://charts.onosproject.org
Andy Bavier9ee69d02022-02-11 10:31:21 -0700222 helm repo add aether https://charts.aetherproject.org
Andy Bavier7d5f0552022-05-23 16:01:45 -0700223 helm repo add rancher http://charts.rancher.io/
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700224 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700225endif
226
227ifeq ($(K8S_INSTALL),rke2)
228$(M)/k8s-ready: | $(M)/setup
229 sudo mkdir -p /etc/rancher/rke2/
230 [ -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
231 echo "cni: multus,calico" >> config.yaml
232 echo "cluster-cidr: 192.168.84.0/24" >> config.yaml
233 echo "service-cidr: 192.168.85.0/24" >> config.yaml
234 echo "kubelet-arg:" >> config.yaml
235 echo "- --allowed-unsafe-sysctls="net.*"" >> config.yaml
236 echo "- --node-ip="$(NODE_IP)"" >> config.yaml
237 echo "pause-image: k8s.gcr.io/pause:3.3" >> config.yaml
238 echo "kube-proxy-arg:" >> config.yaml
239 echo "- --metrics-bind-address="0.0.0.0:10249"" >> config.yaml
240 echo "- --proxy-mode="ipvs"" >> config.yaml
241 echo "kube-apiserver-arg:" >> config.yaml
242 echo "- --service-node-port-range="2000-36767"" >> config.yaml
243 sudo mv config.yaml /etc/rancher/rke2/
244 curl -sfL https://get.rke2.io | sudo INSTALL_RKE2_VERSION=$(RKE2_K8S_VERSION) sh -
245 sudo systemctl enable rke2-server.service
246 sudo systemctl start rke2-server.service
247 sudo /var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml wait nodes --for=condition=Ready --all --timeout=300s
248 sudo /var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml wait deployment -n kube-system --for=condition=available --all --timeout=300s
249 curl -LO "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
250 sudo chmod +x kubectl
251 sudo mv kubectl /usr/local/bin/
252 kubectl version --client
253 mkdir -p $(HOME)/.kube
254 sudo cp /etc/rancher/rke2/rke2.yaml $(HOME)/.kube/config
255 sudo chown -R $(shell id -u):$(shell id -g) $(HOME)/.kube
256 touch $@
257
258$(M)/helm-ready: | $(M)/k8s-ready
259 curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
260 chmod 700 get_helm.sh
261 sudo DESIRED_VERSION=$(HELM_VERSION) ./get_helm.sh
262 helm repo add incubator https://charts.helm.sh/incubator
263 helm repo add cord https://charts.opencord.org
264 helm repo add atomix https://charts.atomix.io
265 helm repo add onosproject https://charts.onosproject.org
266 helm repo add aether https://charts.aetherproject.org
Andy Bavier7d5f0552022-05-23 16:01:45 -0700267 helm repo add rancher http://charts.rancher.io/
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700268 touch $@
269endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700270
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700271/opt/cni/bin/static: | $(M)/k8s-ready
272 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
273 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
274 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
275 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
276
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600277node-prep: | $(M)/helm-ready /opt/cni/bin/static
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700278
Andy Bavier99f31c82022-04-14 16:16:26 -0700279$(M)/router-pod: $(ROUTER_POD_NETCONF)
280 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600281 DATA_IFACE=$(DATA_IFACE) envsubst < $(RESOURCEDIR)/router.yaml | kubectl apply -f -
282 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
283 @touch $@
284
Andy Bavier99f31c82022-04-14 16:16:26 -0700285$(M)/router-host: $(ROUTER_HOST_NETCONF) $(UE_NAT_CONF)
286 sudo systemctl daemon-reload
287 sudo systemctl enable aiab-ue-nat.service
288 sudo systemctl start aiab-ue-nat.service
289 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600290 $(eval oiface := $(shell ip route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600291 @touch $@
292
2934g-core: node-prep
294ifeq ($(ENABLE_ROUTER),true)
295ifeq ($(ENABLE_OAISIM),true)
2964g-core: $(M)/router-pod
297else
2984g-core: $(M)/router-host
299endif
300endif
3014g-core: $(M)/omec
302$(M)/omec:
303 @if [[ "${CHARTS}" == "local" || "${CHARTS}" == "local-sdcore" ]]; then \
304 helm dep up $(SD_CORE_CHART); \
305 else \
306 helm repo update; \
307 fi
308 NODE_IP=${NODE_IP} DATA_IFACE=${DATA_IFACE} RAN_SUBNET=${RAN_SUBNET} envsubst < $(4G_CORE_VALUES) | \
309 helm upgrade --create-namespace --install --wait $(HELM_GLOBAL_ARGS) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700310 --namespace omec \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600311 --values - \
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700312 sd-core \
313 $(SD_CORE_CHART)
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600314 @if [[ "${ENABLE_OAISIM}" == "false" ]]; then \
315 $(eval mme_ip := $(shell ip -4 -o addr show $${DATA_IFACE} | awk '{print $$4}' | cut -d'/' -f1)) \
316 echo "Your MME IP is $(mme_ip)"; \
317 fi
318 @touch $@
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700319
Hyunsun Mooncbdac112022-03-19 22:01:27 -06003205g-core: node-prep
321ifeq ($(ENABLE_ROUTER),true)
322ifeq ($(ENABLE_GNBSIM),true)
3235g-core: $(M)/router-pod
324else
3255g-core: $(M)/router-host
326endif
327endif
3285g-core: $(M)/5g-core
329$(M)/5g-core:
330 @if [[ "${CHARTS}" == "local" || "${CHARTS}" == "local-sdcore" ]]; then \
331 helm dep up $(SD_CORE_CHART); \
332 else \
333 helm repo update; \
334 fi
335 NODE_IP=${NODE_IP} DATA_IFACE=${DATA_IFACE} RAN_SUBNET=${RAN_SUBNET} envsubst < $(5G_CORE_VALUES) | \
336 helm upgrade --create-namespace --install --wait $(HELM_GLOBAL_ARGS) \
Badhrinath3e081e22020-12-02 15:02:08 -0600337 --namespace omec \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600338 --values - \
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700339 sd-core \
340 $(SD_CORE_CHART)
Badhrinath3e081e22020-12-02 15:02:08 -0600341 touch $@
342
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700343# UE images includes kernel module, ue_ip.ko
344# which should be built in the exactly same kernel version of the host machine
345$(BUILD)/openairinterface: | $(M)/setup
346 mkdir -p $(BUILD)
347 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
348
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700349ifeq ($(K8S_INSTALL),kubespray)
350download-ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
Andy Bavier9ee69d02022-02-11 10:31:21 -0700351 sg docker -c "docker pull ${OAISIM_UE_IMAGE} && \
352 docker tag ${OAISIM_UE_IMAGE} omecproject/lte-uesoftmodem:1.1.0"
Andy Bavierd6de5612021-11-08 10:39:17 -0700353 touch $(M)/ue-image
354
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700355$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
356 cd $(BUILD)/openairinterface; \
Andy Bavier9ee69d02022-02-11 10:31:21 -0700357 sg docker -c "docker build . --target lte-uesoftmodem \
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700358 --build-arg http_proxy=$(HTTP_PROXY)/ \
Hyunsun7b640512020-10-27 19:49:51 -0500359 --build-arg build_base=omecproject/oai-base:1.1.0 \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700360 --file Dockerfile.ue \
Andy Bavier9ee69d02022-02-11 10:31:21 -0700361 --tag omecproject/lte-uesoftmodem:1.1.0"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700362 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700363endif
364
365ifeq ($(K8S_INSTALL),rke2)
366download-ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
367 sg docker -c "docker pull ${OAISIM_UE_IMAGE} && \
368 docker tag ${OAISIM_UE_IMAGE} omecproject/lte-uesoftmodem:1.1.0 && \
369 docker save -o /tmp/lte-uesoftmodem.tar omecproject/lte-uesoftmodem:1.1.0"
370 $(CTR_CMD) images import /tmp/lte-uesoftmodem.tar
371 touch $(M)/ue-image
372
373$(M)/ue-image: $(M)/k8s-ready $(BUILD)/openairinterface
374 cd $(BUILD)/openairinterface; \
375 sg docker -c "docker build . --target lte-uesoftmodem \
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700376 --build-arg http_proxy=$(HTTP_PROXY)/ \
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700377 --build-arg build_base=omecproject/oai-base:1.1.0 \
378 --file Dockerfile.ue \
379 --tag omecproject/lte-uesoftmodem:1.1.0 && \
380 docker save -o /tmp/lte-uesoftmodem.tar omecproject/lte-uesoftmodem:1.1.0"
381 $(CTR_CMD) images import /tmp/lte-uesoftmodem.tar
382 touch $@
383endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700384
Andy Bavier99f31c82022-04-14 16:16:26 -0700385/etc/systemd/%:
386 @sudo mkdir -p $(@D)
387 @sed 's/DATA_IFACE/$(DATA_IFACE)/g' $(MAKEDIR)/systemd/$(@F) > /tmp/$(@F)
388 @sudo cp /tmp/$(@F) $@
389 echo "Installed $@"
Andy Bavier9ee69d02022-02-11 10:31:21 -0700390
Andy Bavier99f31c82022-04-14 16:16:26 -0700391oaisim-standalone: | $(M)/helm-ready $(M)/ue-image $(LO_NETCONF)
392 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600393 @ip link show $(DATA_IFACE) > /dev/null || (echo DATA_IFACE is not set or does not exist; exit 1)
394 @if [[ "${MME_IP}" == "" ]]; then \
395 echo MME_IP is not set; \
396 exit 1; \
397 else \
398 ping -c 3 $(MME_IP) > /dev/null || (echo MME $(MME_IP) is not reachable; exit 1) \
399 fi
400 sudo ip route add 192.168.252.0/24 via $(MME_IP)
Andy Bavier7b01b682022-03-17 13:26:55 -0700401 helm repo update
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600402 helm upgrade --create-namespace --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(OAISIM_VALUES) \
403 --set config.enb.networks.s1u.interface=$(DATA_IFACE) \
404 --set config.enb.networks.s1_mme.interface=$(DATA_IFACE) \
405 --set config.enb.mme.address=$(MME_IP) \
406 --set config.enb.mme.isLocal=false \
407 --set images.pullPolicy=IfNotPresent
Andy Bavier7b01b682022-03-17 13:26:55 -0700408 kubectl rollout status -n omec statefulset ue
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600409 @echo "Test: registration"
Andy Bavier7b01b682022-03-17 13:26:55 -0700410 @timeout 60s bash -c \
411 "until ip addr show oip1 | grep -q inet; \
412 do \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600413 echo 'Waiting for UE 1 gets IP address'; \
414 sleep 3; \
Andy Bavier7b01b682022-03-17 13:26:55 -0700415 done"
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600416 @echo "Test: ping from UE to 8.8.8.8"
417 ping -I oip1 8.8.8.8 -c 3
418 @touch $(M)/oaisim $(M)/omec
Andy Bavier7b01b682022-03-17 13:26:55 -0700419
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600420oaisim: | $(M)/oaisim
Andy Bavier99f31c82022-04-14 16:16:26 -0700421$(M)/oaisim: | $(M)/ue-image $(M)/router-pod $(OAISIM_NETCONF)
422 sudo systemctl restart systemd-networkd
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700423 sleep 1
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600424 helm upgrade --create-namespace --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(OAISIM_VALUES) \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700425 --set images.pullPolicy=IfNotPresent
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700426 kubectl rollout status -n omec statefulset ue
427 @timeout 60s bash -c \
428 "until ip addr show oip1 | grep -q inet; \
429 do \
430 echo 'Waiting for UE 1 gets IP address'; \
431 sleep 3; \
432 done"
433 touch $@
434
Andy Bavierebf479c2021-09-08 15:47:58 -0700435roc: $(M)/roc
436$(M)/roc: $(M)/helm-ready
437 kubectl get namespace aether-roc 2> /dev/null || kubectl create namespace aether-roc
438 helm repo update
439 if [ "$(CHARTS)" == "local" ]; then helm dep up $(AETHER_ROC_UMBRELLA_CHART); fi
440 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
441 --namespace kube-system \
442 --values $(ROC_VALUES) \
443 atomix-controller \
444 $(ATOMIX_CONTROLLER_CHART)
445 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
446 --namespace kube-system \
447 --values $(ROC_VALUES) \
448 atomix-raft-storage \
449 $(ATOMIX_RAFT_STORAGE_CHART)
450 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
451 --namespace kube-system \
452 --values $(ROC_VALUES) \
453 onos-operator \
454 $(ONOS_OPERATOR_CHART)
455 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
456 --namespace aether-roc \
457 --values $(ROC_VALUES) \
458 aether-roc-umbrella \
459 $(AETHER_ROC_UMBRELLA_CHART)
460 touch $@
461
462# Load the ROC 4G models. Disable loading network slice from SimApp.
463roc-4g-models: $(M)/roc
464 sed -i 's/provision-network-slice: true/provision-network-slice: false/' $(4G_CORE_VALUES)
465 sed -i 's/# syncUrl/syncUrl/' $(4G_CORE_VALUES)
Amit Wankhede01b20c32021-12-01 12:45:58 +0530466 if [ "${ENABLE_SUBSCRIBER_PROXY}" == "true" ] ; then \
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600467 sed -i 's/# sub-proxy-endpt:/sub-proxy-endpt:/' $(4G_CORE_VALUES) ; \
468 sed -i 's/# addr: sub/ addr: sub/' $(4G_CORE_VALUES) ; \
469 sed -i 's/# port: 5000/ port: 5000/' $(4G_CORE_VALUES) ; \
Amit Wankhede01b20c32021-12-01 12:45:58 +0530470 fi
Andy Bavierebf479c2021-09-08 15:47:58 -0700471 $(eval ONOS_CLI_POD := $(shell kubectl -n aether-roc get pods -l name=onos-cli -o name))
472 echo "ONOS CLI pod: ${ONOS_CLI_POD}"
473 until kubectl -n aether-roc exec ${ONOS_CLI_POD} -- \
474 curl -s -f -L -X PATCH "http://aether-roc-api:8181/aether-roc-api" \
475 --header 'Content-Type: application/json' \
476 --data-raw "$$(cat ${ROC_4G_MODELS})"; do sleep 5; done
477
478# Load the ROC 5G models. Disable loading network slice from SimApp.
479roc-5g-models: $(M)/roc
480 sed -i 's/provision-network-slice: true/provision-network-slice: false/' $(5G_CORE_VALUES)
481 sed -i 's/# syncUrl/syncUrl/' $(5G_CORE_VALUES)
Amit Wankhede01b20c32021-12-01 12:45:58 +0530482 if [ "${ENABLE_SUBSCRIBER_PROXY}" == "true" ] ; then \
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600483 sed -i 's/# sub-proxy-endpt:/sub-proxy-endpt:/' $(5G_CORE_VALUES) ; \
484 sed -i 's/# addr: sub/ addr: sub/' $(5G_CORE_VALUES) ; \
485 sed -i 's/# port: 5000/ port: 5000/' $(5G_CORE_VALUES) ; \
Amit Wankhede01b20c32021-12-01 12:45:58 +0530486 fi
Andy Bavierebf479c2021-09-08 15:47:58 -0700487 $(eval ONOS_CLI_POD := $(shell kubectl -n aether-roc get pods -l name=onos-cli -o name))
488 echo "ONOS CLI pod: ${ONOS_CLI_POD}"
489 until kubectl -n aether-roc exec ${ONOS_CLI_POD} -- \
490 curl -s -f -L -X PATCH "http://aether-roc-api:8181/aether-roc-api" \
491 --header 'Content-Type: application/json' \
492 --data-raw "$$(cat ${ROC_5G_MODELS})"; do sleep 5; done
493
494roc-clean:
495 @echo "This could take 2-3 minutes..."
496 sed -i 's/provision-network-slice: false/provision-network-slice: true/' $(4G_CORE_VALUES)
497 sed -i 's/ syncUrl/ # syncUrl/' $(4G_CORE_VALUES)
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600498 sed -i 's/ sub-proxy-endpt:/ # sub-proxy-endpt:/' $(4G_CORE_VALUES)
499 sed -i 's/ addr: sub/ # addr: sub/' $(4G_CORE_VALUES)
500 sed -i 's/ port: 5000/ # port: 5000/' $(4G_CORE_VALUES)
Andy Bavierebf479c2021-09-08 15:47:58 -0700501 sed -i 's/provision-network-slice: false/provision-network-slice: true/' $(5G_CORE_VALUES)
502 sed -i 's/ syncUrl/ # syncUrl/' $(5G_CORE_VALUES)
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600503 sed -i 's/ sub-proxy-endpt:/ # sub-proxy-endpt:/' $(5G_CORE_VALUES)
504 sed -i 's/ addr: sub/ # addr: sub/' $(5G_CORE_VALUES)
505 sed -i 's/ port: 5000/ # port: 5000/' $(5G_CORE_VALUES)
Andy Bavierebf479c2021-09-08 15:47:58 -0700506 kubectl delete namespace aether-roc || true
507 rm -rf $(M)/roc
508
Andy Bavier7d5f0552022-05-23 16:01:45 -0700509monitoring: $(M)/monitoring
510$(M)/monitoring: $(M)/helm-ready
511 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
512 --namespace=cattle-monitoring-system \
513 --create-namespace \
514 --values=$(MONITORING_VALUES) \
515 rancher-monitoring-crd \
516 $(RANCHER_MONITORING_CRD_CHART)
517 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
518 --namespace=cattle-monitoring-system \
519 --create-namespace \
520 --values=$(MONITORING_VALUES) \
521 rancher-monitoring \
522 $(RANCHER_MONITORING_CHART)
523 touch $(M)/monitoring
524
525monitoring-4g: $(M)/monitoring
526 kubectl create namespace omec || true
527 kubectl create namespace cattle-dashboards || true
528 kubectl apply -k resources/4g-monitoring
529
530
531monitoring-clean:
532 helm -n cattle-monitoring-system delete rancher-monitoring || true
533 helm -n cattle-monitoring-system delete rancher-monitoring-crd || true
534 kubectl delete namespace cattle-dashboards cattle-monitoring-system || true
535 rm $(M)/monitoring
536
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600537omec-clean:
538 helm delete -n omec $$(helm -n omec ls -qa) || true
539 @echo ""
540 @echo "Wait for all pods to terminate..."
541 kubectl wait -n omec --for=delete --all=true -l app!=ue pod --timeout=180s || true
542
543router-clean:
544 @kubectl delete net-attach-def router-net 2>/dev/null || true
545 @kubectl delete po router 2>/dev/null || true
546 kubectl wait --for=delete -l app=router pod --timeout=180s 2>/dev/null || true
547 sudo ip link del access || true
548 sudo ip link del core || true
549 $(eval oiface := $(shell ip route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
550 sudo iptables -t nat -D POSTROUTING -s 172.250.0.0/16 -o $(oiface) -j MASQUERADE || true
551 @sudo ip link del data 2>/dev/null || true
552 @cd $(M); rm -f router-pod router-host
553
554oaisim-clean: reset-ue
555 @sudo ip addr del 127.0.0.2/8 dev lo 2>/dev/null || true
556 @sudo ip link del enb 2>/dev/null || true
557 @sudo ip route del 192.168.252.0/24 || true
558 @cd $(M); rm -f oaisim-lo
559
Andy Bavier7d5f0552022-05-23 16:01:45 -07005604g-test: test
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600561test: | 4g-core $(M)/oaisim
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700562 @sleep 5
563 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500564 ping -I oip1 192.168.250.1 -c 15
Fatemeh Rouzbeh85654e72022-05-23 09:26:12 -0700565 @if [ "${PROXY_ENABLED}" == "false" ] ; then \
566 @echo "Test2: ping from UE to 8.8.8.8" ; \
567 ping -I oip1 8.8.8.8 -c 3 ; \
568 @echo "Test3: ping from UE to google.com" ; \
569 ping -I oip1 google.com -c 3 ; \
570 fi
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700571 @echo "Finished to test"
572
Hyunsun Mooncbdac112022-03-19 22:01:27 -06005735g-test: | 5g-core
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700574 @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 -0700575 @echo "Test: Registration + UE initiated PDU Session Establishment + User Data packets"
Andy Bavier0e4906f2022-03-03 15:31:48 -0700576 @sleep 60
Andy Bavier0a055a52022-01-07 10:46:17 -0700577 @rm -f /tmp/gnbsim.out
Andy Baviercd93a202022-01-10 18:03:26 -0800578 @if [[ ${GNBSIM_COLORS} == "true" ]]; then \
579 kubectl -n omec exec gnbsim-0 -- ./gnbsim 2>&1 | tee /tmp/gnbsim.out; \
580 else \
581 kubectl -n omec exec gnbsim-0 -- ./gnbsim 2>&1 | sed -u "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tee /tmp/gnbsim.out; \
582 fi
Andy Bavier094d6ef2022-03-08 13:21:52 -0700583 @grep -q "Simulation Result: PASS" /tmp/gnbsim.out
Andy Bavier0a055a52022-01-07 10:46:17 -0700584
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600585reset-test: | oaisim-clean omec-clean router-clean
586 @cd $(M); rm -f omec oaisim 5g-core
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700587
Andy Bavier8819b9f2022-01-28 16:54:06 -0700588reset-ue:
589 helm delete -n omec oaisim || true
590 kubectl wait -n omec --for=delete pod enb-0 || true
591 kubectl wait -n omec --for=delete pod ue-0 || true
592 cd $(M); rm -f oaisim
593
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600594reset-5g-test: omec-clean
Badhrinath3e081e22020-12-02 15:02:08 -0600595 cd $(M); rm -f 5g-core
596
Osman Amjad488a0222022-01-12 11:58:43 -0600597reset-dbtestapp:
598 helm uninstall --namespace omec 5g-test-app
599
Andy Bavier99f31c82022-04-14 16:16:26 -0700600refresh-4g: reset-ue
601 kubectl -n omec delete pod mme-0
602 kubectl wait -n omec --for='condition=ready' pod mme-0 --timeout=300s
603
Osman Amjad488a0222022-01-12 11:58:43 -0600604dbtestapp:
605 helm repo update
606 if [ "$(CHARTS)" == "local" ]; then helm dep up $(5G_TEST_APPS_CHART); fi
607 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
608 --namespace omec \
609 5g-test-app \
610 --values $(TEST_APP_VALUES) \
611 $(5G_TEST_APPS_CHART)
612 @echo "Finished to dbtestapp"
613
Andy Bavier99f31c82022-04-14 16:16:26 -0700614clean-systemd:
615 cd /etc/systemd/network && sudo rm -f 10-aiab* 20-aiab* */macvlan.conf
616 cd /etc/systemd/system && sudo rm -f aiab*.service && sudo systemctl daemon-reload
617
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700618ifeq ($(K8S_INSTALL),rke2)
Andy Bavier5b5ad562022-04-19 13:02:31 -0700619clean: | roc-clean oaisim-clean router-clean clean-systemd
Andy Bavier99f31c82022-04-14 16:16:26 -0700620 sudo /usr/local/bin/rke2-uninstall.sh || true
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700621 sudo rm -rf /usr/local/bin/kubectl
622 rm -rf $(M)
623endif
624
625ifeq ($(K8S_INSTALL),kubespray)
Andy Bavier5b5ad562022-04-19 13:02:31 -0700626clean: | roc-clean oaisim-clean router-clean clean-systemd
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700627 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
Andy Bavier125baa02021-10-26 16:26:44 -0700628 ansible-playbook -b -i inventory/local/hosts.ini reset.yml --extra-vars "reset_confirmation=yes"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700629 @if [ -d /usr/local/etc/emulab ]; then \
630 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
631 sudo rm -rf /mnt/extra/kubelet; \
632 fi
633 rm -rf $(M)
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700634endif