Jeremy Ronquillo | 5263c73 | 2020-10-13 09:42:19 -0700 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
| 2 | # |
| 3 | # SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 |
| 4 | |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 5 | SHELL := /bin/bash |
| 6 | BUILD ?= /tmp/build |
| 7 | M ?= $(BUILD)/milestones |
| 8 | MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) |
Jeremy Ronquillo | af084f3 | 2020-08-24 13:18:47 -0700 | [diff] [blame] | 9 | SCRIPTDIR := $(MAKEDIR)/scripts |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 10 | RESOURCEDIR := $(MAKEDIR)/resources |
| 11 | WORKSPACE ?= $(HOME) |
Jeremy Ronquillo | d3cab74 | 2020-08-24 11:49:00 -0700 | [diff] [blame] | 12 | VENV ?= $(BUILD)/venv/aiab |
| 13 | AIABVALUES ?= $(MAKEDIR)/aether-in-a-box-values.yaml |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 14 | |
Hyunsun | 84f0f17 | 2020-09-23 15:40:08 -0500 | [diff] [blame] | 15 | KUBESPRAY_VERSION ?= release-2.14 |
| 16 | DOCKER_VERSION ?= 19.03 |
| 17 | K8S_VERSION ?= v1.18.9 |
Scott Baker | 17b70d1 | 2020-09-29 23:26:21 -0700 | [diff] [blame] | 18 | HELM_VERSION ?= v3.2.4 |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 19 | |
| 20 | # used to start logging/monitoring and other infrastructure charts |
| 21 | INFRA_CHARTS ?= |
| 22 | INFRA_PREREQS = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart)) |
| 23 | |
| 24 | KAFKA_CHART_VERSION ?= 0.13.3 |
| 25 | KAFKA_POD := "pod/cord-kafka-0" |
| 26 | |
| 27 | HELM_GLOBAL_ARGS ?= |
| 28 | HELM_NEM_ARGS ?= $(HELM_GLOBAL_ARGS) |
| 29 | HELM_ONOS_ARGS ?= $(HELM_GLOBAL_ARGS) |
| 30 | |
| 31 | cpu_family := $(shell lscpu | grep 'CPU family:' | awk '{print $$3}') |
| 32 | cpu_model := $(shell lscpu | grep 'Model:' | awk '{print $$2}') |
| 33 | os_vendor := $(shell lsb_release -i -s) |
| 34 | os_release := $(shell lsb_release -r -s) |
| 35 | |
Jeremy Ronquillo | d3cab74 | 2020-08-24 11:49:00 -0700 | [diff] [blame] | 36 | aiab: $(M)/system-check $(M)/omec |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 37 | oaisim: $(M)/oaisim |
| 38 | |
Jeremy Ronquillo | d3cab74 | 2020-08-24 11:49:00 -0700 | [diff] [blame] | 39 | .PHONY: aiab oaisim test reset-test clean |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 40 | |
| 41 | $(M): |
| 42 | mkdir -p $(M) |
| 43 | |
| 44 | $(M)/system-check: | $(M) |
| 45 | @if [[ $(cpu_family) -eq 6 ]]; then \ |
| 46 | if [[ $(cpu_model) -lt 60 ]]; then \ |
| 47 | echo "FATAL: haswell CPU or newer is required."; \ |
| 48 | exit 1; \ |
| 49 | fi \ |
| 50 | else \ |
| 51 | echo "FATAL: unsupported CPU family."; \ |
| 52 | exit 1; \ |
| 53 | fi |
| 54 | @if [[ $(os_vendor) =~ (Ubuntu) ]]; then \ |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 55 | if [[ ! $(os_release) =~ (18.04) ]]; then \ |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 56 | echo "WARN: $(os_vendor) $(os_release) has not been tested."; \ |
| 57 | fi; \ |
| 58 | if dpkg --compare-versions 4.15 gt $(shell uname -r); then \ |
| 59 | echo "FATAL: kernel 4.15 or later is required."; \ |
| 60 | echo "Please upgrade your kernel by running" \ |
| 61 | "apt install --install-recommends linux-generic-hwe-$(os_release)"; \ |
| 62 | exit 1; \ |
| 63 | fi \ |
| 64 | else \ |
| 65 | echo "FAIL: unsupported OS."; \ |
| 66 | exit 1; \ |
| 67 | fi |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 68 | @if [[ ! -d "$(WORKSPACE)/cord/aether-helm-charts" ]]; then \ |
| 69 | echo "FATAL: Please clone aether-helm-charts under $(WORKSPACE)/cord directory."; \ |
| 70 | exit 1; \ |
| 71 | fi |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 72 | touch $@ |
| 73 | |
| 74 | $(M)/setup: | $(M) |
| 75 | sudo $(SCRIPTDIR)/cloudlab-disksetup.sh |
| 76 | sudo apt update; sudo apt install -y software-properties-common python-pip jq httpie ipvsadm |
| 77 | touch $@ |
| 78 | |
| 79 | $(BUILD)/kubespray: | $(M)/setup |
| 80 | mkdir -p $(BUILD) |
| 81 | cd $(BUILD); git clone https://github.com/kubernetes-incubator/kubespray.git -b $(KUBESPRAY_VERSION) |
| 82 | |
| 83 | $(VENV)/bin/activate: | $(M)/setup |
| 84 | sudo pip install virtualenv |
| 85 | virtualenv $(VENV) |
| 86 | |
| 87 | $(M)/kubespray-requirements: $(BUILD)/kubespray | $(VENV)/bin/activate |
| 88 | source "$(VENV)/bin/activate" && \ |
| 89 | pip install -r $(BUILD)/kubespray/requirements.txt |
| 90 | touch $@ |
| 91 | |
| 92 | $(M)/k8s-ready: | $(M)/setup $(BUILD)/kubespray $(VENV)/bin/activate $(M)/kubespray-requirements |
| 93 | source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \ |
| 94 | ansible-playbook -b -i inventory/local/hosts.ini \ |
| 95 | -e "{'override_system_hostname' : False, 'disable_swap' : True}" \ |
| 96 | -e "{'docker_version' : $(DOCKER_VERSION)}" \ |
| 97 | -e "{'docker_iptables_enabled' : True}" \ |
| 98 | -e "{'kube_version' : $(K8S_VERSION)}" \ |
Hyunsun | 84f0f17 | 2020-09-23 15:40:08 -0500 | [diff] [blame] | 99 | -e "{'kube_network_plugin_multus' : True, 'multus_version' : stable, 'multus_cni_version' : 0.3.1}" \ |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 100 | -e "{'kube_proxy_metrics_bind_address' : 0.0.0.0:10249}" \ |
| 101 | -e "{'kube_pods_subnet' : 192.168.0.0/17, 'kube_service_addresses' : 192.168.128.0/17}" \ |
| 102 | -e "{'kube_apiserver_node_port_range' : 2000-36767}" \ |
| 103 | -e "{'kubeadm_enabled': True}" \ |
| 104 | -e "{'kube_feature_gates' : [SCTPSupport=True]}" \ |
| 105 | -e "{'kubelet_custom_flags' : [--allowed-unsafe-sysctls=net.*]}" \ |
| 106 | -e "{'dns_min_replicas' : 1}" \ |
| 107 | -e "{'helm_enabled' : True, 'helm_version' : $(HELM_VERSION)}" \ |
| 108 | cluster.yml |
| 109 | mkdir -p $(HOME)/.kube |
| 110 | sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config |
| 111 | sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config |
| 112 | kubectl wait pod -n kube-system --for=condition=Ready --all |
| 113 | touch $@ |
| 114 | |
| 115 | $(M)/helm-ready: | $(M)/k8s-ready |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 116 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 117 | helm repo add cord https://charts.opencord.org |
| 118 | touch $@ |
| 119 | |
| 120 | /opt/cni/bin/simpleovs: | $(M)/k8s-ready |
| 121 | sudo cp $(RESOURCEDIR)/simpleovs /opt/cni/bin/ |
| 122 | |
| 123 | /opt/cni/bin/static: | $(M)/k8s-ready |
| 124 | mkdir -p $(BUILD)/cni-plugins; cd $(BUILD)/cni-plugins; \ |
| 125 | wget https://github.com/containernetworking/plugins/releases/download/v0.8.2/cni-plugins-linux-amd64-v0.8.2.tgz && \ |
| 126 | tar xvfz cni-plugins-linux-amd64-v0.8.2.tgz |
| 127 | sudo cp $(BUILD)/cni-plugins/static /opt/cni/bin/ |
| 128 | |
| 129 | # TODO: need to connect ONOS |
| 130 | $(M)/fabric: | $(M)/setup /opt/cni/bin/simpleovs /opt/cni/bin/static |
| 131 | sudo apt install -y openvswitch-switch |
| 132 | sudo ovs-vsctl --may-exist add-br br-enb-net |
| 133 | sudo ovs-vsctl --may-exist add-port br-enb-net enb -- set Interface enb type=internal |
| 134 | sudo ip addr add 192.168.251.4/24 dev enb || true |
| 135 | sudo ip link set enb up |
| 136 | sudo ethtool --offload enb tx off |
| 137 | sudo ip route replace 192.168.252.0/24 via 192.168.251.1 dev enb |
| 138 | kubectl apply -f $(RESOURCEDIR)/router.yaml |
| 139 | kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s |
Hyunsun | 84f0f17 | 2020-09-23 15:40:08 -0500 | [diff] [blame] | 140 | kubectl -n default exec router ip route add 10.250.0.0/16 via 192.168.250.3 |
Jeremy Ronquillo | af084f3 | 2020-08-24 13:18:47 -0700 | [diff] [blame] | 141 | kubectl delete net-attach-def core-net |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 142 | touch $@ |
| 143 | |
| 144 | $(M)/omec: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric |
Scott Baker | 17b70d1 | 2020-09-29 23:26:21 -0700 | [diff] [blame] | 145 | kubectl get namespace omec 2> /dev/null || kubectl create namespace omec |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 146 | helm repo update |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 147 | helm dep up $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 148 | helm upgrade --install $(HELM_GLOBAL_ARGS) \ |
| 149 | --namespace omec \ |
Jeremy Ronquillo | d3cab74 | 2020-08-24 11:49:00 -0700 | [diff] [blame] | 150 | --values $(AIABVALUES) \ |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 151 | omec-control-plane \ |
Jeremy Ronquillo | af084f3 | 2020-08-24 13:18:47 -0700 | [diff] [blame] | 152 | $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane && \ |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 153 | kubectl wait pod -n omec --for=condition=Ready -l release=omec-control-plane --timeout=300s && \ |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 154 | helm upgrade --install $(HELM_GLOBAL_ARGS) \ |
| 155 | --namespace omec \ |
Jeremy Ronquillo | d3cab74 | 2020-08-24 11:49:00 -0700 | [diff] [blame] | 156 | --values $(AIABVALUES) \ |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 157 | omec-user-plane \ |
Jeremy Ronquillo | af084f3 | 2020-08-24 13:18:47 -0700 | [diff] [blame] | 158 | $(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \ |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 159 | kubectl wait pod -n omec --for=condition=Ready -l release=omec-user-plane --timeout=300s |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 160 | touch $@ |
| 161 | |
| 162 | # UE images includes kernel module, ue_ip.ko |
| 163 | # which should be built in the exactly same kernel version of the host machine |
| 164 | $(BUILD)/openairinterface: | $(M)/setup |
| 165 | mkdir -p $(BUILD) |
| 166 | cd $(BUILD); git clone https://github.com/opencord/openairinterface.git |
| 167 | |
| 168 | $(M)/ue-image: | $(M)/k8s-ready $(BUILD)/openairinterface |
| 169 | cd $(BUILD)/openairinterface; \ |
| 170 | sudo docker build . --target lte-uesoftmodem \ |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 171 | --build-arg build_base=omecproject/oai-base:1.1.0 \ |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 172 | --file Dockerfile.ue \ |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 173 | --tag omecproject/lte-uesoftmodem:1.1.0 |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 174 | touch $@ |
| 175 | |
| 176 | $(M)/oaisim: | $(M)/ue-image $(M)/omec |
| 177 | sudo ip addr add 127.0.0.2/8 dev lo || true |
| 178 | $(eval mme_iface=$(shell ip -4 route list default | awk -F 'dev' '{ print $$2; exit }' | awk '{ print $$1 }')) |
Hyunsun | 7b64051 | 2020-10-27 19:49:51 -0500 | [diff] [blame^] | 179 | helm upgrade --install $(HELM_GLOBAL_ARGS) --namespace omec oaisim cord/oaisim -f $(AIABVALUES) \ |
Jeremy Ronquillo | af084f3 | 2020-08-24 13:18:47 -0700 | [diff] [blame] | 180 | --set config.enb.networks.s1_mme.interface=$(mme_iface) \ |
| 181 | --set images.pullPolicy=IfNotPresent |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 182 | kubectl rollout status -n omec statefulset ue |
| 183 | @timeout 60s bash -c \ |
| 184 | "until ip addr show oip1 | grep -q inet; \ |
| 185 | do \ |
| 186 | echo 'Waiting for UE 1 gets IP address'; \ |
| 187 | sleep 3; \ |
| 188 | done" |
| 189 | touch $@ |
| 190 | |
| 191 | test: | $(M)/fabric $(M)/omec $(M)/oaisim |
| 192 | @sleep 5 |
| 193 | @echo "Test1: ping from UE to SGI network gateway" |
Hyunsun Moon | 0bd8cec | 2020-09-28 00:38:26 -0500 | [diff] [blame] | 194 | ping -I oip1 192.168.250.1 -c 15 |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 195 | @echo "Test2: ping from UE to 8.8.8.8" |
| 196 | ping -I oip1 8.8.8.8 -c 3 |
Hyunsun Moon | 0bd8cec | 2020-09-28 00:38:26 -0500 | [diff] [blame] | 197 | @echo "Test3: ping from UE to google.com" |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 198 | ping -I oip1 google.com -c 3 |
| 199 | @echo "Finished to test" |
| 200 | |
| 201 | reset-test: |
Scott Baker | 17b70d1 | 2020-09-29 23:26:21 -0700 | [diff] [blame] | 202 | helm delete -n omec oaisim || true |
| 203 | helm delete -n omec omec-control-plane || true |
| 204 | helm delete -n omec omec-user-plane || true |
| 205 | cd $(M); rm -f oaisim omec |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 206 | |
| 207 | clean: reset-test |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 208 | kubectl delete po router || true |
Jeremy Ronquillo | af084f3 | 2020-08-24 13:18:47 -0700 | [diff] [blame] | 209 | kubectl delete net-attach-def core-net || true |
| 210 | sudo ovs-vsctl del-br br-access-net || true |
| 211 | sudo ovs-vsctl del-br br-core-net || true |
Jeremy Ronquillo | 6be909e | 2020-08-24 09:36:13 -0700 | [diff] [blame] | 212 | sudo apt remove --purge openvswitch-switch -y |
| 213 | source "$(VENV)/bin/activate" && cd $(BUILD)/kubespray; \ |
| 214 | ansible-playbook -b -i inventory/local/hosts.ini reset.yml |
| 215 | @if [ -d /usr/local/etc/emulab ]; then \ |
| 216 | mount | grep /mnt/extra/kubelet/pods | cut -d" " -f3 | sudo xargs umount; \ |
| 217 | sudo rm -rf /mnt/extra/kubelet; \ |
| 218 | fi |
| 219 | rm -rf $(M) |