Skip to content

Commit

Permalink
Add clab to interconnect clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Morales <v.morales@samsung.com>
  • Loading branch information
electrocucaracha committed Jun 15, 2023
1 parent 03259b3 commit d77362b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*log
.vagrant/
*.bak
42 changes: 42 additions & 0 deletions e2e/provision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,48 @@ kubectl get secret edge02-kubeconfig -o jsonpath='{.data.value}' | base64 -d > $
export KUBECONFIG=$HOME/.kube/config:$HOME/.kube/regional-kubeconfig:$HOME/.kube/edge01-kubeconfig:$HOME/.kube/edge02-kubeconfig
```

Once the edge clusters are ready it's necessary to inter-connect them. This time
we are going to use the [containerlab tool](https://containerlab.dev/) for that
operation. Eventually inter-cluster networking will be automated as well, but it
is not yet in this release.

```bash
workers=""
for context in $(kubectl config get-contexts --no-headers --output name); do
workers+=$(kubectl get nodes -l node-role.kubernetes.io/control-plane!= -o jsonpath='{range .items[*]}"{.metadata.name}",{"\n"}{end}' --context "$context")
done
echo "{\"workers\":[${workers::-1}]}" | tee /tmp/vars.json
sudo containerlab deploy --topo test-infra/e2e/tests/002-topo.gotmpl --vars /tmp/vars.json --skip-post-deploy
```

<details>
<summary>The output is similar to:</summary>

```console
{"workers":["edge01-md-0-5xpjv-d578b7b8bxwph6d-6sv2n","edge02-md-0-fvpvh-99498794cxhfzsn-q5xvl","regional-md-0-p6zbf-586d7b54d8xw6b5x-qv77v"]}
INFO[0000] Containerlab v0.41.2 started
INFO[0000] Parsing & checking topology file: 002-topo.gotmpl
INFO[0000] Could not read docker config: open /root/.docker/config.json: no such file or directory
INFO[0000] Pulling ghcr.io/nokia/srlinux:latest Docker image
INFO[0266] Done pulling ghcr.io/nokia/srlinux:latest
INFO[0266] Creating lab directory: /tmp/test-infra/e2e/clab-free5gc-net
INFO[0268] Creating docker network: Name="clab", IPv4Subnet="172.20.20.0/24", IPv6Subnet="2001:172:20:20::/64", MTU="1500"
INFO[0271] Creating container: "N6"
INFO[0276] Creating virtual wire: N6:e1-1 <--> edge02-md-0-fvpvh-99498794cxhfzsn-q5xvl:eth1
INFO[0276] Creating virtual wire: N6:e1-2 <--> regional-md-0-p6zbf-586d7b54d8xw6b5x-qv77v:eth1
INFO[0276] Creating virtual wire: N6:e1-0 <--> edge01-md-0-5xpjv-d578b7b8bxwph6d-6sv2n:eth1
INFO[0277] Adding containerlab host entries to /etc/hosts file
+---+--------------------------------------------+--------------+-----------------------+---------------+---------+----------------+--------------------------+
| # | Name | Container ID | Image | Kind | State | IPv4 Address | IPv6 Address |
+---+--------------------------------------------+--------------+-----------------------+---------------+---------+----------------+--------------------------+
| 1 | edge01-md-0-5xpjv-d578b7b8bxwph6d-6sv2n | 44e78769fc1e | kindest/node:v1.26.3 | ext-container | running | 172.18.0.11/16 | fc00:f853:ccd:e793::b/64 |
| 2 | edge02-md-0-fvpvh-99498794cxhfzsn-q5xvl | 38eb76c0323b | kindest/node:v1.26.3 | ext-container | running | 172.18.0.8/16 | fc00:f853:ccd:e793::8/64 |
| 3 | regional-md-0-p6zbf-586d7b54d8xw6b5x-qv77v | 142a4f0cff7e | kindest/node:v1.26.3 | ext-container | running | 172.18.0.5/16 | fc00:f853:ccd:e793::5/64 |
| 4 | net-free5gc-net-N6 | 1581d603e174 | ghcr.io/nokia/srlinux | srl | running | 172.20.20.2/24 | 2001:172:20:20::2/64 |
+---+--------------------------------------------+--------------+-----------------------+---------------+---------+----------------+--------------------------+
```
</details>

Finally, we want to configure the resource backend to know about these clusters.
The resource backend is an IP address and VLAN index management system. It is
included for demonstration purposes, to show how Nephio package specialization
Expand Down
7 changes: 7 additions & 0 deletions e2e/provision/playbooks/cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
hosts: vm
vars:
container_engine: docker
clab_version: 0.41.2
pre_tasks:
- name: Install kubernetes python package
become: true
Expand All @@ -38,3 +39,9 @@
cni_plugins_dir: /opt/cni/bin
- bootstrap
- install
tasks:
- name: Install container lab tool
become: true
ansible.builtin.apt:
deb: "https://github.com/srl-labs/containerlab/releases/download/v{{ clab_version }}/containerlab_{{ clab_version }}_linux_{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}.deb"
when: ansible_os_family == 'Debian' and ansible_architecture in ('arm64', 'x86_64')
27 changes: 27 additions & 0 deletions e2e/tests/002-topo.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2023 The Nephio Authors.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

name: free5gc-net
prefix: net
topology:
kinds:
srl:
image: ghcr.io/nokia/srlinux
nodes:
N6:
kind: srl
{{- range .workers }}
{{ . }}:
kind: ext-container
{{- end }}
links:
{{- range $i, $worker := .workers }}
- endpoints: ["N6:e1-{{ $i }}", "{{ $worker }}:eth1"]
{{- end }}
9 changes: 9 additions & 0 deletions e2e/tests/002.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ k8s_wait_exists "$kubeconfig" 600 "default" "cluster" "edge02"

k8s_wait_ready "$kubeconfig" 600 "default" "cluster" "edge01"
k8s_wait_ready "$kubeconfig" 600 "default" "cluster" "edge02"

# Inter-connect worker nodes
workers=""
for cluster in regional edge01 edge02; do
_kubeconfig=$(k8s_get_capi_kubeconfig "$kubeconfig" "default" "$cluster")
workers+=$(kubectl get nodes -l node-role.kubernetes.io/control-plane!= -o jsonpath='{range .items[*]}"{.metadata.name}",{"\n"}{end}' --kubeconfig "$_kubeconfig")
done
echo "{\"workers\":[${workers::-1}]}" | tee /tmp/vars.json
sudo containerlab deploy --topo "$TESTDIR/002-topo.gotmpl" --vars /tmp/vars.json --skip-post-deploy

0 comments on commit d77362b

Please sign in to comment.