blob: 72076b56cff74256c2095dc12f702e7a9ce40d4b [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
Andy Bavier7d5f0552022-05-23 16:01:45 -070055# monitoring
56RANCHER_MONITORING_CRD_CHART := rancher/rancher-monitoring-crd
57RANCHER_MONITORING_CHART := rancher/rancher-monitoring
58MONITORING_VALUES ?= $(MAKEDIR)/monitoring.yaml
59
Hyunsun Moon4e5795a2022-04-07 09:27:12 -070060NODE_IP ?= $(shell ip route get 8.8.8.8 | grep -oP 'src \K\S+')
61ifndef NODE_IP
62$(error NODE_IP is not set)
63endif
64
Hyunsun Mooncbdac112022-03-19 22:01:27 -060065MME_IP ?=
66
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070067HELM_GLOBAL_ARGS ?=
Andy Baviereda466b2021-08-27 15:00:36 -070068
69# Allow installing local charts or specific versions of published charts.
70# E.g., to install the Aether 1.5 release:
71# CHARTS=release-1.5 make test
72# Default is to install from the local charts.
73CHARTS ?= local
74CONFIGFILE := configs/$(CHARTS)
75include $(CONFIGFILE)
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070076
77cpu_family := $(shell lscpu | grep 'CPU family:' | awk '{print $$3}')
78cpu_model := $(shell lscpu | grep 'Model:' | awk '{print $$2}')
79os_vendor := $(shell lsb_release -i -s)
80os_release := $(shell lsb_release -r -s)
Andy Bavier9ee69d02022-02-11 10:31:21 -070081USER := $(shell whoami)
82
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -070083.PHONY: 4g-core 5g-core oaisim test reset-test reset-ue reset-5g-test node-prep clean
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -070084
85$(M):
86 mkdir -p $(M)
87
88$(M)/system-check: | $(M)
89 @if [[ $(cpu_family) -eq 6 ]]; then \
90 if [[ $(cpu_model) -lt 60 ]]; then \
91 echo "FATAL: haswell CPU or newer is required."; \
92 exit 1; \
93 fi \
94 else \
95 echo "FATAL: unsupported CPU family."; \
96 exit 1; \
97 fi
98 @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \
Hyunsun7b640512020-10-27 19:49:51 -050099 if [[ ! $(os_release) =~ (18.04) ]]; then \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700100 echo "WARN: $(os_vendor) $(os_release) has not been tested."; \
101 fi; \
102 if dpkg --compare-versions 4.15 gt $(shell uname -r); then \
103 echo "FATAL: kernel 4.15 or later is required."; \
104 echo "Please upgrade your kernel by running" \
105 "apt install --install-recommends linux-generic-hwe-$(os_release)"; \
106 exit 1; \
107 fi \
108 else \
109 echo "FAIL: unsupported OS."; \
110 exit 1; \
111 fi
112 touch $@
113
Andy Bavier99f31c82022-04-14 16:16:26 -0700114$(M)/interface-check: | $(M)
115ifeq ($(DATA_IFACE_CONF), .d)
116 @echo
117 @echo FATAL: Could not find systemd-networkd config for interface $(DATA_IFACE), exiting now!; exit 1
118endif
119 touch $@
120
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700121ifeq ($(K8S_INSTALL),kubespray)
Andy Bavier99f31c82022-04-14 16:16:26 -0700122$(M)/setup: | $(M) $(M)/interface-check
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700123 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
Hyunsun Moon82e47c22021-06-28 12:30:20 -0500124 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 -0700125 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700126endif
127
128ifeq ($(K8S_INSTALL),rke2)
Andy Bavier99f31c82022-04-14 16:16:26 -0700129$(M)/setup: | $(M) $(M)/interface-check
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700130 sudo $(SCRIPTDIR)/cloudlab-disksetup.sh
131 sudo apt update; sudo apt install -y software-properties-common python3 python3-pip python3-venv jq httpie ipvsadm apparmor apparmor-utils
132 systemctl list-units --full -all | grep "docker.service" || sudo apt install -y docker.io
133 sudo adduser $(USER) docker || true
134 touch $@
135endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700136
137$(BUILD)/kubespray: | $(M)/setup
138 mkdir -p $(BUILD)
139 cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION)
140
141$(VENV)/bin/activate: | $(M)/setup
Hyunsun Moon82e47c22021-06-28 12:30:20 -0500142 python3 -m venv $(VENV)
Wei-Yu Chen7edb7e72021-07-28 11:37:55 +0800143 source "$(VENV)/bin/activate" && \
144 python -m pip install -U pip && \
145 deactivate
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700146
147$(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate
148 source "$(VENV)/bin/activate" && \
149 pip install -r $(BUILD)/kubespray/requirements.txt
150 touch $@
151
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700152ifeq ($(K8S_INSTALL),kubespray)
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700153$(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements
154 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
155 ansible-playbook -b -i inventory/local/hosts.ini \
156 -e "{'override_system_hostname' : False, 'disable_swap' : True}" \
157 -e "{'docker_version' : $(DOCKER_VERSION)}" \
158 -e "{'docker_iptables_enabled' : True}" \
159 -e "{'kube_version' : $(K8S_VERSION)}" \
Hyunsun84f0f172020-09-23 15:40:08 -0500160 -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700161 -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600162 -e "{'kube_pods_subnet' : 192.168.84.0/24, 'kube_service_addresses' : 192.168.85.0/24}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700163 -e "{'kube_apiserver_node_port_range' : 2000-36767}" \
164 -e "{'kubeadm_enabled': True}" \
165 -e "{'kube_feature_gates' : [SCTPSupport=True]}" \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600166 -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*, --node-ip=$(NODE_IP)]}" \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700167 -e "{'dns_min_replicas' : 1}" \
168 -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \
169 cluster.yml
170 mkdir -p $(HOME)/.kube
171 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
172 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
173 kubectl wait pod -n kube-system --for=condition=Ready --all
Andy Bavier9ee69d02022-02-11 10:31:21 -0700174 sudo adduser $(USER) docker
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700175 touch $@
176
177$(M)/helm-ready: | $(M)/k8s-ready
Woojoong Kim8425cb32021-01-08 16:18:53 -0800178 helm repo add incubator https://charts.helm.sh/incubator
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700179 helm repo add cord https://charts.opencord.org
Andy Baviereda466b2021-08-27 15:00:36 -0700180 helm repo add atomix https://charts.atomix.io
181 helm repo add onosproject https://charts.onosproject.org
Andy Bavier9ee69d02022-02-11 10:31:21 -0700182 helm repo add aether https://charts.aetherproject.org
Andy Bavier7d5f0552022-05-23 16:01:45 -0700183 helm repo add rancher http://charts.rancher.io/
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700184 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700185endif
186
187ifeq ($(K8S_INSTALL),rke2)
188$(M)/k8s-ready: | $(M)/setup
189 sudo mkdir -p /etc/rancher/rke2/
190 [ -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
191 echo "cni: multus,calico" >> config.yaml
192 echo "cluster-cidr: 192.168.84.0/24" >> config.yaml
193 echo "service-cidr: 192.168.85.0/24" >> config.yaml
194 echo "kubelet-arg:" >> config.yaml
195 echo "- --allowed-unsafe-sysctls="net.*"" >> config.yaml
196 echo "- --node-ip="$(NODE_IP)"" >> config.yaml
197 echo "pause-image: k8s.gcr.io/pause:3.3" >> config.yaml
198 echo "kube-proxy-arg:" >> config.yaml
199 echo "- --metrics-bind-address="0.0.0.0:10249"" >> config.yaml
200 echo "- --proxy-mode="ipvs"" >> config.yaml
201 echo "kube-apiserver-arg:" >> config.yaml
202 echo "- --service-node-port-range="2000-36767"" >> config.yaml
203 sudo mv config.yaml /etc/rancher/rke2/
204 curl -sfL https://get.rke2.io | sudo INSTALL_RKE2_VERSION=$(RKE2_K8S_VERSION) sh -
205 sudo systemctl enable rke2-server.service
206 sudo systemctl start rke2-server.service
207 sudo /var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml wait nodes --for=condition=Ready --all --timeout=300s
208 sudo /var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml wait deployment -n kube-system --for=condition=available --all --timeout=300s
209 curl -LO "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
210 sudo chmod +x kubectl
211 sudo mv kubectl /usr/local/bin/
212 kubectl version --client
213 mkdir -p $(HOME)/.kube
214 sudo cp /etc/rancher/rke2/rke2.yaml $(HOME)/.kube/config
215 sudo chown -R $(shell id -u):$(shell id -g) $(HOME)/.kube
216 touch $@
217
218$(M)/helm-ready: | $(M)/k8s-ready
219 curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
220 chmod 700 get_helm.sh
221 sudo DESIRED_VERSION=$(HELM_VERSION) ./get_helm.sh
222 helm repo add incubator https://charts.helm.sh/incubator
223 helm repo add cord https://charts.opencord.org
224 helm repo add atomix https://charts.atomix.io
225 helm repo add onosproject https://charts.onosproject.org
226 helm repo add aether https://charts.aetherproject.org
Andy Bavier7d5f0552022-05-23 16:01:45 -0700227 helm repo add rancher http://charts.rancher.io/
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700228 touch $@
229endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700230
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700231/opt/cni/bin/static: | $(M)/k8s-ready
232 mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \
233 wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \
234 tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz
235 sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/
236
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600237node-prep: | $(M)/helm-ready /opt/cni/bin/static
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700238
Andy Bavier99f31c82022-04-14 16:16:26 -0700239$(M)/router-pod: $(ROUTER_POD_NETCONF)
240 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600241 DATA_IFACE=$(DATA_IFACE) envsubst < $(RESOURCEDIR)/router.yaml | kubectl apply -f -
242 kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
243 @touch $@
244
Andy Bavier99f31c82022-04-14 16:16:26 -0700245$(M)/router-host: $(ROUTER_HOST_NETCONF) $(UE_NAT_CONF)
246 sudo systemctl daemon-reload
247 sudo systemctl enable aiab-ue-nat.service
248 sudo systemctl start aiab-ue-nat.service
249 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600250 $(eval oiface := $(shell ip route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600251 @touch $@
252
2534g-core: node-prep
254ifeq ($(ENABLE_ROUTER),true)
255ifeq ($(ENABLE_OAISIM),true)
2564g-core: $(M)/router-pod
257else
2584g-core: $(M)/router-host
259endif
260endif
2614g-core: $(M)/omec
262$(M)/omec:
263 @if [[ "${CHARTS}" == "local" || "${CHARTS}" == "local-sdcore" ]]; then \
264 helm dep up $(SD_CORE_CHART); \
265 else \
266 helm repo update; \
267 fi
268 NODE_IP=${NODE_IP} DATA_IFACE=${DATA_IFACE} RAN_SUBNET=${RAN_SUBNET} envsubst < $(4G_CORE_VALUES) | \
269 helm upgrade --create-namespace --install --wait $(HELM_GLOBAL_ARGS) \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700270 --namespace omec \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600271 --values - \
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700272 sd-core \
273 $(SD_CORE_CHART)
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600274 @if [[ "${ENABLE_OAISIM}" == "false" ]]; then \
275 $(eval mme_ip := $(shell ip -4 -o addr show $${DATA_IFACE} | awk '{print $$4}' | cut -d'/' -f1)) \
276 echo "Your MME IP is $(mme_ip)"; \
277 fi
278 @touch $@
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700279
Hyunsun Mooncbdac112022-03-19 22:01:27 -06002805g-core: node-prep
281ifeq ($(ENABLE_ROUTER),true)
282ifeq ($(ENABLE_GNBSIM),true)
2835g-core: $(M)/router-pod
284else
2855g-core: $(M)/router-host
286endif
287endif
2885g-core: $(M)/5g-core
289$(M)/5g-core:
290 @if [[ "${CHARTS}" == "local" || "${CHARTS}" == "local-sdcore" ]]; then \
291 helm dep up $(SD_CORE_CHART); \
292 else \
293 helm repo update; \
294 fi
295 NODE_IP=${NODE_IP} DATA_IFACE=${DATA_IFACE} RAN_SUBNET=${RAN_SUBNET} envsubst < $(5G_CORE_VALUES) | \
296 helm upgrade --create-namespace --install --wait $(HELM_GLOBAL_ARGS) \
Badhrinath3e081e22020-12-02 15:02:08 -0600297 --namespace omec \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600298 --values - \
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700299 sd-core \
300 $(SD_CORE_CHART)
Badhrinath3e081e22020-12-02 15:02:08 -0600301 touch $@
302
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700303# UE images includes kernel module, ue_ip.ko
304# which should be built in the exactly same kernel version of the host machine
305$(BUILD)/openairinterface: | $(M)/setup
306 mkdir -p $(BUILD)
307 cd $(BUILD); git clone https://github.com/opencord/openairinterface.git
308
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700309ifeq ($(K8S_INSTALL),kubespray)
310download-ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
Andy Bavier9ee69d02022-02-11 10:31:21 -0700311 sg docker -c "docker pull ${OAISIM_UE_IMAGE} && \
312 docker tag ${OAISIM_UE_IMAGE} omecproject/lte-uesoftmodem:1.1.0"
Andy Bavierd6de5612021-11-08 10:39:17 -0700313 touch $(M)/ue-image
314
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700315$(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
316 cd $(BUILD)/openairinterface; \
Andy Bavier9ee69d02022-02-11 10:31:21 -0700317 sg docker -c "docker build . --target lte-uesoftmodem \
Hyunsun7b640512020-10-27 19:49:51 -0500318 --build-arg build_base=omecproject/oai-base:1.1.0 \
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700319 --file Dockerfile.ue \
Andy Bavier9ee69d02022-02-11 10:31:21 -0700320 --tag omecproject/lte-uesoftmodem:1.1.0"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700321 touch $@
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700322endif
323
324ifeq ($(K8S_INSTALL),rke2)
325download-ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface
326 sg docker -c "docker pull ${OAISIM_UE_IMAGE} && \
327 docker tag ${OAISIM_UE_IMAGE} omecproject/lte-uesoftmodem:1.1.0 && \
328 docker save -o /tmp/lte-uesoftmodem.tar omecproject/lte-uesoftmodem:1.1.0"
329 $(CTR_CMD) images import /tmp/lte-uesoftmodem.tar
330 touch $(M)/ue-image
331
332$(M)/ue-image: $(M)/k8s-ready $(BUILD)/openairinterface
333 cd $(BUILD)/openairinterface; \
334 sg docker -c "docker build . --target lte-uesoftmodem \
335 --build-arg build_base=omecproject/oai-base:1.1.0 \
336 --file Dockerfile.ue \
337 --tag omecproject/lte-uesoftmodem:1.1.0 && \
338 docker save -o /tmp/lte-uesoftmodem.tar omecproject/lte-uesoftmodem:1.1.0"
339 $(CTR_CMD) images import /tmp/lte-uesoftmodem.tar
340 touch $@
341endif
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700342
Andy Bavier99f31c82022-04-14 16:16:26 -0700343/etc/systemd/%:
344 @sudo mkdir -p $(@D)
345 @sed 's/DATA_IFACE/$(DATA_IFACE)/g' $(MAKEDIR)/systemd/$(@F) > /tmp/$(@F)
346 @sudo cp /tmp/$(@F) $@
347 echo "Installed $@"
Andy Bavier9ee69d02022-02-11 10:31:21 -0700348
Andy Bavier99f31c82022-04-14 16:16:26 -0700349oaisim-standalone: | $(M)/helm-ready $(M)/ue-image $(LO_NETCONF)
350 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600351 @ip link show $(DATA_IFACE) > /dev/null || (echo DATA_IFACE is not set or does not exist; exit 1)
352 @if [[ "${MME_IP}" == "" ]]; then \
353 echo MME_IP is not set; \
354 exit 1; \
355 else \
356 ping -c 3 $(MME_IP) > /dev/null || (echo MME $(MME_IP) is not reachable; exit 1) \
357 fi
358 sudo ip route add 192.168.252.0/24 via $(MME_IP)
Andy Bavier7b01b682022-03-17 13:26:55 -0700359 helm repo update
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600360 helm upgrade --create-namespace --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(OAISIM_VALUES) \
361 --set config.enb.networks.s1u.interface=$(DATA_IFACE) \
362 --set config.enb.networks.s1_mme.interface=$(DATA_IFACE) \
363 --set config.enb.mme.address=$(MME_IP) \
364 --set config.enb.mme.isLocal=false \
365 --set images.pullPolicy=IfNotPresent
Andy Bavier7b01b682022-03-17 13:26:55 -0700366 kubectl rollout status -n omec statefulset ue
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600367 @echo "Test: registration"
Andy Bavier7b01b682022-03-17 13:26:55 -0700368 @timeout 60s bash -c \
369 "until ip addr show oip1 | grep -q inet; \
370 do \
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600371 echo 'Waiting for UE 1 gets IP address'; \
372 sleep 3; \
Andy Bavier7b01b682022-03-17 13:26:55 -0700373 done"
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600374 @echo "Test: ping from UE to 8.8.8.8"
375 ping -I oip1 8.8.8.8 -c 3
376 @touch $(M)/oaisim $(M)/omec
Andy Bavier7b01b682022-03-17 13:26:55 -0700377
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600378oaisim: | $(M)/oaisim
Andy Bavier99f31c82022-04-14 16:16:26 -0700379$(M)/oaisim: | $(M)/ue-image $(M)/router-pod $(OAISIM_NETCONF)
380 sudo systemctl restart systemd-networkd
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600381 helm upgrade --create-namespace --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(OAISIM_VALUES) \
Jeremy Ronquilloaf084f32020-08-24 13:18:47 -0700382 --set images.pullPolicy=IfNotPresent
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700383 kubectl rollout status -n omec statefulset ue
384 @timeout 60s bash -c \
385 "until ip addr show oip1 | grep -q inet; \
386 do \
387 echo 'Waiting for UE 1 gets IP address'; \
388 sleep 3; \
389 done"
390 touch $@
391
Andy Bavierebf479c2021-09-08 15:47:58 -0700392roc: $(M)/roc
393$(M)/roc: $(M)/helm-ready
394 kubectl get namespace aether-roc 2> /dev/null || kubectl create namespace aether-roc
395 helm repo update
396 if [ "$(CHARTS)" == "local" ]; then helm dep up $(AETHER_ROC_UMBRELLA_CHART); fi
397 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
398 --namespace kube-system \
399 --values $(ROC_VALUES) \
400 atomix-controller \
401 $(ATOMIX_CONTROLLER_CHART)
402 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
403 --namespace kube-system \
404 --values $(ROC_VALUES) \
405 atomix-raft-storage \
406 $(ATOMIX_RAFT_STORAGE_CHART)
407 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
408 --namespace kube-system \
409 --values $(ROC_VALUES) \
410 onos-operator \
411 $(ONOS_OPERATOR_CHART)
412 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
413 --namespace aether-roc \
414 --values $(ROC_VALUES) \
415 aether-roc-umbrella \
416 $(AETHER_ROC_UMBRELLA_CHART)
417 touch $@
418
419# Load the ROC 4G models. Disable loading network slice from SimApp.
420roc-4g-models: $(M)/roc
421 sed -i 's/provision-network-slice: true/provision-network-slice: false/' $(4G_CORE_VALUES)
422 sed -i 's/# syncUrl/syncUrl/' $(4G_CORE_VALUES)
Amit Wankhede01b20c32021-12-01 12:45:58 +0530423 if [ "${ENABLE_SUBSCRIBER_PROXY}" == "true" ] ; then \
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600424 sed -i 's/# sub-proxy-endpt:/sub-proxy-endpt:/' $(4G_CORE_VALUES) ; \
425 sed -i 's/# addr: sub/ addr: sub/' $(4G_CORE_VALUES) ; \
426 sed -i 's/# port: 5000/ port: 5000/' $(4G_CORE_VALUES) ; \
Amit Wankhede01b20c32021-12-01 12:45:58 +0530427 fi
Andy Bavierebf479c2021-09-08 15:47:58 -0700428 $(eval ONOS_CLI_POD := $(shell kubectl -n aether-roc get pods -l name=onos-cli -o name))
429 echo "ONOS CLI pod: ${ONOS_CLI_POD}"
430 until kubectl -n aether-roc exec ${ONOS_CLI_POD} -- \
431 curl -s -f -L -X PATCH "http://aether-roc-api:8181/aether-roc-api" \
432 --header 'Content-Type: application/json' \
433 --data-raw "$$(cat ${ROC_4G_MODELS})"; do sleep 5; done
434
435# Load the ROC 5G models. Disable loading network slice from SimApp.
436roc-5g-models: $(M)/roc
437 sed -i 's/provision-network-slice: true/provision-network-slice: false/' $(5G_CORE_VALUES)
438 sed -i 's/# syncUrl/syncUrl/' $(5G_CORE_VALUES)
Amit Wankhede01b20c32021-12-01 12:45:58 +0530439 if [ "${ENABLE_SUBSCRIBER_PROXY}" == "true" ] ; then \
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600440 sed -i 's/# sub-proxy-endpt:/sub-proxy-endpt:/' $(5G_CORE_VALUES) ; \
441 sed -i 's/# addr: sub/ addr: sub/' $(5G_CORE_VALUES) ; \
442 sed -i 's/# port: 5000/ port: 5000/' $(5G_CORE_VALUES) ; \
Amit Wankhede01b20c32021-12-01 12:45:58 +0530443 fi
Andy Bavierebf479c2021-09-08 15:47:58 -0700444 $(eval ONOS_CLI_POD := $(shell kubectl -n aether-roc get pods -l name=onos-cli -o name))
445 echo "ONOS CLI pod: ${ONOS_CLI_POD}"
446 until kubectl -n aether-roc exec ${ONOS_CLI_POD} -- \
447 curl -s -f -L -X PATCH "http://aether-roc-api:8181/aether-roc-api" \
448 --header 'Content-Type: application/json' \
449 --data-raw "$$(cat ${ROC_5G_MODELS})"; do sleep 5; done
450
451roc-clean:
452 @echo "This could take 2-3 minutes..."
453 sed -i 's/provision-network-slice: false/provision-network-slice: true/' $(4G_CORE_VALUES)
454 sed -i 's/ syncUrl/ # syncUrl/' $(4G_CORE_VALUES)
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600455 sed -i 's/ sub-proxy-endpt:/ # sub-proxy-endpt:/' $(4G_CORE_VALUES)
456 sed -i 's/ addr: sub/ # addr: sub/' $(4G_CORE_VALUES)
457 sed -i 's/ port: 5000/ # port: 5000/' $(4G_CORE_VALUES)
Andy Bavierebf479c2021-09-08 15:47:58 -0700458 sed -i 's/provision-network-slice: false/provision-network-slice: true/' $(5G_CORE_VALUES)
459 sed -i 's/ syncUrl/ # syncUrl/' $(5G_CORE_VALUES)
Amit Wankhedefdf10ff2022-02-16 08:37:20 -0600460 sed -i 's/ sub-proxy-endpt:/ # sub-proxy-endpt:/' $(5G_CORE_VALUES)
461 sed -i 's/ addr: sub/ # addr: sub/' $(5G_CORE_VALUES)
462 sed -i 's/ port: 5000/ # port: 5000/' $(5G_CORE_VALUES)
Andy Bavierebf479c2021-09-08 15:47:58 -0700463 kubectl delete namespace aether-roc || true
464 rm -rf $(M)/roc
465
Andy Bavier7d5f0552022-05-23 16:01:45 -0700466monitoring: $(M)/monitoring
467$(M)/monitoring: $(M)/helm-ready
468 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
469 --namespace=cattle-monitoring-system \
470 --create-namespace \
471 --values=$(MONITORING_VALUES) \
472 rancher-monitoring-crd \
473 $(RANCHER_MONITORING_CRD_CHART)
474 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
475 --namespace=cattle-monitoring-system \
476 --create-namespace \
477 --values=$(MONITORING_VALUES) \
478 rancher-monitoring \
479 $(RANCHER_MONITORING_CHART)
480 touch $(M)/monitoring
481
482monitoring-4g: $(M)/monitoring
483 kubectl create namespace omec || true
484 kubectl create namespace cattle-dashboards || true
485 kubectl apply -k resources/4g-monitoring
486
487
488monitoring-clean:
489 helm -n cattle-monitoring-system delete rancher-monitoring || true
490 helm -n cattle-monitoring-system delete rancher-monitoring-crd || true
491 kubectl delete namespace cattle-dashboards cattle-monitoring-system || true
492 rm $(M)/monitoring
493
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600494omec-clean:
495 helm delete -n omec $$(helm -n omec ls -qa) || true
496 @echo ""
497 @echo "Wait for all pods to terminate..."
498 kubectl wait -n omec --for=delete --all=true -l app!=ue pod --timeout=180s || true
499
500router-clean:
501 @kubectl delete net-attach-def router-net 2>/dev/null || true
502 @kubectl delete po router 2>/dev/null || true
503 kubectl wait --for=delete -l app=router pod --timeout=180s 2>/dev/null || true
504 sudo ip link del access || true
505 sudo ip link del core || true
506 $(eval oiface := $(shell ip route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }'))
507 sudo iptables -t nat -D POSTROUTING -s 172.250.0.0/16 -o $(oiface) -j MASQUERADE || true
508 @sudo ip link del data 2>/dev/null || true
509 @cd $(M); rm -f router-pod router-host
510
511oaisim-clean: reset-ue
512 @sudo ip addr del 127.0.0.2/8 dev lo 2>/dev/null || true
513 @sudo ip link del enb 2>/dev/null || true
514 @sudo ip route del 192.168.252.0/24 || true
515 @cd $(M); rm -f oaisim-lo
516
Andy Bavier7d5f0552022-05-23 16:01:45 -07005174g-test: test
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600518test: | 4g-core $(M)/oaisim
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700519 @sleep 5
520 @echo "Test1: ping from UE to SGI network gateway"
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500521 ping -I oip1 192.168.250.1 -c 15
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700522 @echo "Test2: ping from UE to 8.8.8.8"
523 ping -I oip1 8.8.8.8 -c 3
Hyunsun Moon0bd8cec2020-09-28 00:38:26 -0500524 @echo "Test3: ping from UE to google.com"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700525 ping -I oip1 google.com -c 3
526 @echo "Finished to test"
527
Hyunsun Mooncbdac112022-03-19 22:01:27 -06005285g-test: | 5g-core
Andy Bavier31dfb9e2022-02-15 15:24:57 -0700529 @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 -0700530 @echo "Test: Registration + UE initiated PDU Session Establishment + User Data packets"
Andy Bavier0e4906f2022-03-03 15:31:48 -0700531 @sleep 60
Andy Bavier0a055a52022-01-07 10:46:17 -0700532 @rm -f /tmp/gnbsim.out
Andy Baviercd93a202022-01-10 18:03:26 -0800533 @if [[ ${GNBSIM_COLORS} == "true" ]]; then \
534 kubectl -n omec exec gnbsim-0 -- ./gnbsim 2>&1 | tee /tmp/gnbsim.out; \
535 else \
536 kubectl -n omec exec gnbsim-0 -- ./gnbsim 2>&1 | sed -u "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tee /tmp/gnbsim.out; \
537 fi
Andy Bavier094d6ef2022-03-08 13:21:52 -0700538 @grep -q "Simulation Result: PASS" /tmp/gnbsim.out
Andy Bavier0a055a52022-01-07 10:46:17 -0700539
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600540reset-test: | oaisim-clean omec-clean router-clean
541 @cd $(M); rm -f omec oaisim 5g-core
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700542
Andy Bavier8819b9f2022-01-28 16:54:06 -0700543reset-ue:
544 helm delete -n omec oaisim || true
545 kubectl wait -n omec --for=delete pod enb-0 || true
546 kubectl wait -n omec --for=delete pod ue-0 || true
547 cd $(M); rm -f oaisim
548
Hyunsun Mooncbdac112022-03-19 22:01:27 -0600549reset-5g-test: omec-clean
Badhrinath3e081e22020-12-02 15:02:08 -0600550 cd $(M); rm -f 5g-core
551
Osman Amjad488a0222022-01-12 11:58:43 -0600552reset-dbtestapp:
553 helm uninstall --namespace omec 5g-test-app
554
Andy Bavier99f31c82022-04-14 16:16:26 -0700555refresh-4g: reset-ue
556 kubectl -n omec delete pod mme-0
557 kubectl wait -n omec --for='condition=ready' pod mme-0 --timeout=300s
558
Osman Amjad488a0222022-01-12 11:58:43 -0600559dbtestapp:
560 helm repo update
561 if [ "$(CHARTS)" == "local" ]; then helm dep up $(5G_TEST_APPS_CHART); fi
562 helm upgrade --install --wait $(HELM_GLOBAL_ARGS) \
563 --namespace omec \
564 5g-test-app \
565 --values $(TEST_APP_VALUES) \
566 $(5G_TEST_APPS_CHART)
567 @echo "Finished to dbtestapp"
568
Andy Bavier99f31c82022-04-14 16:16:26 -0700569clean-systemd:
570 cd /etc/systemd/network && sudo rm -f 10-aiab* 20-aiab* */macvlan.conf
571 cd /etc/systemd/system && sudo rm -f aiab*.service && sudo systemctl daemon-reload
572
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700573ifeq ($(K8S_INSTALL),rke2)
Andy Bavier5b5ad562022-04-19 13:02:31 -0700574clean: | roc-clean oaisim-clean router-clean clean-systemd
Andy Bavier99f31c82022-04-14 16:16:26 -0700575 sudo /usr/local/bin/rke2-uninstall.sh || true
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700576 sudo rm -rf /usr/local/bin/kubectl
577 rm -rf $(M)
578endif
579
580ifeq ($(K8S_INSTALL),kubespray)
Andy Bavier5b5ad562022-04-19 13:02:31 -0700581clean: | roc-clean oaisim-clean router-clean clean-systemd
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700582 source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \
Andy Bavier125baa02021-10-26 16:26:44 -0700583 ansible-playbook -b -i inventory/local/hosts.ini reset.yml --extra-vars "reset_confirmation=yes"
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -0700584 @if [ -d /usr/local/etc/emulab ]; then \
585 mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \
586 sudo rm -rf /mnt/extra/kubelet; \
587 fi
588 rm -rf $(M)
Fatemeh Rouzbeha0b26e22022-04-07 12:45:12 -0700589endif