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