Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(agw): AGW s1ap-tester containerization #11308

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
07dc3d1
feat(agw): AGW s1ap-tester containerization
rmeleromira Jan 27, 2022
b0b627d
feat(agw): AGW s1ap-tester containerization
rmeleromira Feb 7, 2022
291fb65
feat(agw): AGW s1ap-tester containerization
rmeleromira Feb 8, 2022
8927cd3
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 12, 2022
e6ccb91
Merge branch 'magma:master' into s1ap-containerization
rmeleromira Apr 13, 2022
ccdde2e
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 14, 2022
4a0ff70
Merge branch 'magma:master' into s1ap-containerization
rmeleromira Apr 14, 2022
79ce1bc
Merge branch 's1ap-containerization' of github.com:arunuke/magma into…
rmeleromira Apr 14, 2022
1b56bd2
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 21, 2022
7db9b8b
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 21, 2022
2c0a7c8
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 21, 2022
fe17511
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 21, 2022
5aae46a
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 25, 2022
e536f52
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 25, 2022
b5e8675
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 30, 2022
716ecbe
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 30, 2022
7b426b3
feat(agw): AGW s1ap-tester containerization
rmeleromira Apr 30, 2022
076a740
feat(agw): AGW s1ap-tester containerization
rmeleromira May 2, 2022
ee601d2
feat(agw): AGW s1ap-tester containerization
rmeleromira May 4, 2022
6cee9a5
feat(agw): AGW s1ap-tester containerization
rmeleromira May 4, 2022
5469cdd
feat(agw): AGW s1ap-tester containerization
rmeleromira May 9, 2022
9d83471
feat(agw): AGW s1ap-tester containerization
rmeleromira May 23, 2022
3d91c94
Merge branch 'magma:master' into s1ap-containerization
rmeleromira May 23, 2022
19d6cf0
feat(agw): AGW s1ap-tester containerization
rmeleromira May 23, 2022
7b8b5c6
feat(agw): AGW s1ap-tester containerization
rmeleromira May 24, 2022
4398d2f
feat(agw): AGW s1ap-tester containerization
rmeleromira May 26, 2022
d9abab8
feat(agw): AGW s1ap-tester containerization
rmeleromira May 26, 2022
fd834c5
feat(agw): AGW s1ap-tester containerization
rmeleromira Jun 2, 2022
0cab4cb
Merge branch 'magma:master' into s1ap-containerization
rmeleromira Jun 2, 2022
52a480e
feat(agw): AGW s1ap-tester containerization
rmeleromira Jun 7, 2022
f7bebbd
feat(agw): AGW s1ap-tester containerization
rmeleromira Jun 23, 2022
968679a
feat(agw): AGW s1ap-tester containerization
rmeleromira Jun 23, 2022
a8cadad
feat(agw): AGW s1ap-tester containerization
rmeleromira Jun 29, 2022
7c6c58d
Merge branch 'magma:master' into s1ap-containerization
rmeleromira Jul 20, 2022
b2b2537
feat(agw): AGW s1ap-tester containerization
rmeleromira Jul 20, 2022
e21888c
feat(agw): AGW s1ap-tester containerization
rmeleromira Jul 20, 2022
b9d68fe
feat(agw): AGW s1ap-tester containerization
rmeleromira Jul 20, 2022
d8c6dc8
feat(agw): AGW s1ap-tester containerization
rmeleromira Jul 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions lte/gateway/deploy/agw_install_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@ EOF
fi

alias python=python3
pip3 install ansible
pip3 install ansible fire jsonpickle protobuf redis grpcio snowflake

rm -rf /opt/magma/
git clone "${GIT_URL}" /opt/magma
cd /opt/magma || exit
git checkout "$MAGMA_VERSION"

# copy magma modules
mkdir -p /usr/local/lib/python3.8/dist-packages/magma/mobilityd
cp -r /opt/magma/orc8r/gateway/python/magma/* /usr/local/lib/python3.8/dist-packages/magma/
cp -r /opt/magma/lte/gateway/python/magma/mobilityd/* /usr/local/lib/python3.8/dist-packages/magma/mobilityd/

# changing intefaces name
sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"/g' /etc/default/grub
sed -i 's/ens5/eth0/g; s/ens6/eth1/g' /etc/netplan/50-cloud-init.yaml
Expand All @@ -109,7 +114,11 @@ fi

echo "Generating localhost hostfile for Ansible"
echo "[agw_docker]
127.0.0.1 ansible_connection=local" > $DEPLOY_PATH/agw_hosts
127.0.0.1 ansible_connection=local
[s1aptester]
192.168.60.141
[trfgen]
192.168.60.144" > $DEPLOY_PATH/agw_hosts

if [ "$MODE" == "base" ]; then
su - $MAGMA_USER -c "sudo ansible-playbook -v -e \"MAGMA_ROOT='/opt/magma' OUTPUT_DIR='/tmp'\" -i $DEPLOY_PATH/agw_hosts --tags base $DEPLOY_PATH/magma_docker.yml"
Expand Down
32 changes: 32 additions & 0 deletions lte/gateway/deploy/magma_docker_s1ap_setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# Copyright 2022 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Setup AGW for s1aptester
hosts: agw_docker
roles:
- role: agw_docker_s1ap_setup
- name: Setup s1aptester
hosts: s1aptester
roles:
- role: agw_docker_s1aptester
vars:
docker_application: s1aptester
eth1_address: 192.168.60.141
eth2_address: 192.168.128.11
- name: Setup Traffic Generator
hosts: trfgen
roles:
- role: agw_docker_s1aptester
vars:
docker_application: trfgen
eth1_address: 192.168.60.144
eth2_address: 192.168.129.42
16 changes: 16 additions & 0 deletions lte/gateway/deploy/magma_docker_s1ap_teardown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Copyright 2022 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Remove s1aptester changes to AGW host
hosts: agw_docker
roles:
- role: agw_docker_s1ap_teardown
15 changes: 13 additions & 2 deletions lte/gateway/deploy/roles/agw_docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- "/etc/magma"
- "/etc/magma/templates/"
- "/var/opt/magma/docker"
- "/var/opt/magma/docker/s1ap"

- name: Enable IP forwarding
become: true
Expand Down Expand Up @@ -77,10 +78,15 @@
- agwc
- base

- name: copy docker compose config file
shell: cp -r /opt/magma/lte/gateway/docker/docker-compose.yaml /var/opt/magma/docker/
- name: copy the docker-compose files
copy:
src: "/opt/magma/lte/gateway/docker/{{ item }}"
dest: /var/opt/magma/docker/
tags:
- agwc
loop:
- docker-compose.yaml
- s1ap/docker-compose.agw.s1ap.override.yaml

- name: update nat interface
shell: cp -f /etc/magma/pipelined.yml_prod /etc/magma/pipelined.yml
Expand All @@ -103,6 +109,11 @@
- agwc
- base

- name: Making python scripts executable
shell: chmod +x /usr/local/bin/*.py
tags:
- agwc

- name: docker login
shell: docker login -u {{ docker_user }} -p {{ docker_pass }} {{ docker_registry }}
args:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
################################################################################
# Copyright 2022 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
82 changes: 82 additions & 0 deletions lte/gateway/deploy/roles/agw_docker_s1ap_setup/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
rmeleromira marked this conversation as resolved.
Show resolved Hide resolved
################################################################################
# Copyright 2022 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
- name: Verify eth0 and eth1 exist
assert:
that:
- "{{ ansible_facts['eth0'] is defined }}"
- "{{ ansible_facts['eth1'] is defined }}"
fail_msg: "eth0 and eth1 interfaces must exist"

- name: Get AGW deployment status
stat:
path: /var/opt/magma/docker/docker-compose.yaml
register: agw_deployed

- name: Verify AGW is deployed
assert:
that: "{{ agw_deployed.stat.exists }}"
fail_msg: "Deploy host as an AGW"

- name: Verify eth1 address
assert:
that: ansible_facts['eth1']['ipv4']['address'] == '192.168.60.142'
fail_msg: "eth1 must have address 192.168.60.142"

- name: Verify eth0 address
assert:
that: ansible_facts['eth0']['ipv4']['address'] == '192.168.129.1'
fail_msg: "eth0 must have address 192.168.129.1"

- name: Update ubuntu password
user:
name: ubuntu
password: "{{ 'ubuntu' | password_hash('sha512', 'ubuntu') }}"

- name: Permit ssh password authentication
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^PasswordAuthentication|^#PasswordAuthentication'
line: "PasswordAuthentication yes"
register: password_auth

- name: Reload ssh
systemd:
name: ssh
state: reloaded
when: password_auth.changed

- name: Add docker registry to .env
lineinfile:
path: /var/opt/magma/docker/.env
regexp: '^DOCKER_REGISTRY='
line: "DOCKER_REGISTRY={{ docker_registry }}"
when: docker_registry is defined

- name: "Build agw images"
shell:
cmd: "docker-compose build --parallel"
chdir: /opt/magma/lte/gateway/docker
when: docker_registry is not defined

- name: Insert ryu static service to pipelined
lineinfile:
path: /etc/magma/pipelined.yml
search_string: "^static_services"
insertafter: "^static_services"
line: " 'ryu_rest_service',"

- name: "Start AGW containers"
shell:
cmd: "docker-compose --env-file .env -f docker-compose.yaml -f docker-compose.agw.s1ap.override.yaml up -d"
chdir: /var/opt/magma/docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
################################################################################
# Copyright 2022 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
- name: Remove ubuntu password
user:
name: ubuntu
password: ""

- name: Disable ssh password authentication
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^PasswordAuthentication|^#PasswordAuthentication'
line: "PasswordAuthentication no"
register: password_auth

- name: Reload ssh
systemd:
name: ssh
state: reloaded
when: password_auth.changed

- name: Remove ryu static service from pipelined
lineinfile:
path: /etc/magma/pipelined.yml
search_string: "ryu_rest_service"
state: absent
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
################################################################################
# Copyright 2022 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
magma_version: "master"
magma_repo: 'https://github.com/magma/magma'
docker_compose_version: "2.5.1"
72 changes: 72 additions & 0 deletions lte/gateway/deploy/roles/agw_docker_s1aptester/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
################################################################################
# Copyright 2022 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
- name: Verify eth0, eth1, eth2 exist
assert:
that:
- "{{ ansible_facts['eth0'] is defined }}"
- "{{ ansible_facts['eth1'] is defined }}"
- "{{ ansible_facts['eth2'] is defined }}"
fail_msg: "eth0, eth1, eth2 interfaces must exist"

- name: Verify eth1 address
assert:
that: ansible_facts['eth1']['ipv4']['address'] == eth1_address
fail_msg: "eth1 must have address {{ eth1_address }}"

- name: Verify eth2 address
assert:
that: ansible_facts['eth2']['ipv4']['address'] == eth2_address
fail_msg: "eth2 must have address {{ eth2_address }}"

- name: Download Docker install script
get_url:
url: https://get.docker.com
dest: ~/get-docker.sh
mode: '0740'
register: get_docker

- name: Download docker-compose
get_url:
url: 'https://github.com/docker/compose/releases/download/v{{docker_compose_version}}/docker-compose-linux-x86_64'
dest: /usr/local/bin/docker-compose
mode: '0740'

- name: Install docker
shell: ~/get-docker.sh
when: get_docker.changed

- name: Git checkout magma repository
git:
repo: '{{ magma_repo }}'
dest: /opt/magma
version: '{{ magma_version }}'
when: get_docker.changed

- name: Add docker registry to .env
lineinfile:
path: /opt/magma/lte/gateway/docker/.env
regexp: '^DOCKER_REGISTRY='
line: "DOCKER_REGISTRY={{ docker_registry }}"
when: docker_registry is defined

- name: "Build {{ docker_application }} image"
shell:
cmd: "docker-compose -f docker-compose.yaml -f s1ap/docker-compose.override.yaml build {{ docker_application }}"
chdir: /opt/magma/lte/gateway/docker
when: docker_registry is not defined

- name: "Start {{ docker_application }} container"
shell:
cmd: "docker-compose --env-file .env -f s1ap/docker-compose.s1ap.yaml up -d {{ docker_application }}"
chdir: /opt/magma/lte/gateway/docker
28 changes: 14 additions & 14 deletions lte/gateway/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ The images can be built with `cd $MAGMA_ROOT/lte/gateway/docker && docker-compos

## Deploying the containerized AGW on AWS

* Build the docker images and push them to a registry of your choice
* Look at [the cloudstrapper readme](../../../experimental/cloudstrapper/README.md) for an AWS setup
* If you are only interested in running the AGW, you only need steps 1 and 5.1
* Step 1 will produce required AWS resources like security groups, S3 buckets, and a keypair, and download the keypair to a local directory that you specify
* Step 5.1 will start and customize an Ubuntu machine and create an AMI snapshot of that machine. The machine stays running after the snapshot is taken.
* You don't need to configure Github and Docker credentials in the `secrets.yaml`
* After running step 5.1, you should be able to SSH to the created EC2 instance
* On the EC2 instance
* optional: Copy custom `rootCA.pem` to `/var/opt/magma/certs` with permissions 400
* Copy `agw_install_docker.sh` to the instance and run it to finish the preparation of the host
* Adapt the docker registry in `/var/opt/magma/docker/.env`
* Example for the registry setting: `DOCKER_REGISTRY=registry.hub.docker.com/arunuke/`
* Make changes to config files and restart services by running `/var/opt/magma/docker/agw_upgrade.sh` or by running the `agw_install_docker.sh` script
- Build the docker images and push them to a registry of your choice
- Look at [the cloudstrapper readme](../../../experimental/cloudstrapper/README.md) for an AWS setup
- If you are only interested in running the AGW, you only need steps 1 and 5.1
- Step 1 will produce required AWS resources like security groups, S3 buckets, and a keypair, and download the keypair to a local directory that you specify
rmeleromira marked this conversation as resolved.
Show resolved Hide resolved
- Step 5.1 will start and customize an Ubuntu machine and create an AMI snapshot of that machine. The machine stays running after the snapshot is taken.
rmeleromira marked this conversation as resolved.
Show resolved Hide resolved
- You don't need to configure Github and Docker credentials in the `secrets.yaml`
rmeleromira marked this conversation as resolved.
Show resolved Hide resolved
rmeleromira marked this conversation as resolved.
Show resolved Hide resolved
- After running step 5.1, you should be able to SSH to the created EC2 instance
- On the EC2 instance
- optional: Copy custom `rootCA.pem` to `/var/opt/magma/certs` with permissions 400
- Copy `agw_install_docker.sh` to the instance and run it to finish the preparation of the host
- Adapt the docker registry in `/var/opt/magma/docker/.env`
- Example for the registry setting: `DOCKER_REGISTRY=registry.hub.docker.com/arunuke/`
rmeleromira marked this conversation as resolved.
Show resolved Hide resolved
rmeleromira marked this conversation as resolved.
Show resolved Hide resolved
- Make changes to config files and restart services by running `/var/opt/magma/docker/agw_upgrade.sh` or by running the `agw_install_docker.sh` script

## Running the containerized AGW locally on the magma VM

The magma VM defined in [../Vagrantfile](../Vagrantfile) can be used to run the
containerized AGW by running the following steps inside the VM:

```
```bash
cd $MAGMA_ROOT/lte/gateway && make run # You can skip this if you have built the AGW with make before
for component in redis nghttpx td-agent-bit; do cp "${MAGMA_ROOT}"/{orc8r,lte}/gateway/configs/templates/${component}.conf.template; done
sudo systemctl stop 'magma@*' # We don't want the systemd-based AGW to run when we start the containerized AGW
Expand Down
1 change: 1 addition & 0 deletions lte/gateway/docker/docker-compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ services:
build:
context: ${BUILD_CONTEXT}
dockerfile: lte/gateway/docker/services/python/Dockerfile

rmeleromira marked this conversation as resolved.
Show resolved Hide resolved