Skip to content

Commit

Permalink
Add more remote vlan examples (#4433)
Browse files Browse the repository at this point in the history
- The existing suite was broken into two parts:
  - internal
  - vlan breaktrough
- Added OVS-forwarder example
- Added multiple NS example

Signed-off-by: Laszlo Kiraly <laszlo.kiraly@est.tech>
  • Loading branch information
Szilard Vincze authored and ljkiraly committed Jan 31, 2022
1 parent 35d2cc9 commit 50a25fc
Show file tree
Hide file tree
Showing 16 changed files with 538 additions and 66 deletions.
2 changes: 1 addition & 1 deletion apps/nse-remote-vlan/nse-remote-vlan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
- name: NSM_CONNECT_TO
value: "registry:5002"
- name: NSM_SERVICES
value: "finance-bridge { vlan: 100; via: gw1}"
value: "finance-bridge { vlan: 100; via: gw1}, private-bridge { vlan: 200; via: gw1 }"
- name: NSM_CIDR_PREFIX
value: "172.10.0.0/24"
- name: NSM_IPV6_PREFIX
Expand Down
3 changes: 2 additions & 1 deletion examples/remotevlan/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# NSM Remote Vlan Examples

This setup can be used to check remote vlan mechanism. Contain basic setup for NSM that includes `nsmgr`, `registry-k8s`, `admission-webhook-k8s`, `nse-remote-vlan`. The `nse-remote-vlan` belongs to the nsm-system since does not have role in data-plane connection.
This setup can be used to check remote vlan mechanism with both OVS and VPP forwarder. Contain basic setup for NSM that includes `nsmgr`, `registry-k8s`, `admission-webhook-k8s`, `nse-remote-vlan`. The `nse-remote-vlan` belongs to the nsm-system since does not have role in data-plane connection.

## Requires

- [spire](../spire)

## Includes

- [Remote VLAN mechanism using forwarder-ovs](./rvlanovs)
- [Remote VLAN mechanism using forwarder-vpp](./rvlanvpp)

## Run
Expand Down
35 changes: 35 additions & 0 deletions examples/remotevlan/rvlanovs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# NSM Remote Vlan OVS Forwarder

Contains setup for `forwarder-ovs` and device configuration file for remote vlan mechanism.

## Requires

Make sure that you have completed steps from [remotevlan](../../remotevlan) setup.

## Includes

- [Kernel2RVlanInternal](../../use-cases/Kernel2RVlanInternal)
- [Kernel2RVlanBreakout](../../use-cases/Kernel2RVlanBreakout)
- [Kernel2RVlanMultiNS](../../use-cases/Kernel2RVlanMultiNS)

## Run

Deploy the forwarder:

```bash
kubectl apply -k .
```

Wait forwarder to start:

```bash
kubectl -n nsm-system wait --for=condition=ready --timeout=2m pod -l app=forwarder-ovs
```

## Cleanup

Delete the forwarder:

```bash
kubectl delete -k .
```
16 changes: 16 additions & 0 deletions examples/remotevlan/rvlanovs/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: nsm-system

bases:
- ../../../apps/forwarder-ovs

configMapGenerator:
- name: device-selector
files:
- selector

patchesStrategicMerge:
- patch-forwarder-ovs.yaml
24 changes: 24 additions & 0 deletions examples/remotevlan/rvlanovs/patch-forwarder-ovs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: forwarder-ovs
spec:
template:
spec:
containers:
- name: forwarder-ovs
env:
- name: NSM_L2_RESOURCE_SELECTOR_FILE
value: /var/lib/networkservicemesh/device-selector.yaml
volumeMounts:
- name: devsel-vol
mountPath: /var/lib/networkservicemesh/device-selector.yaml
subPath: device-selector.yaml
volumes:
- name: devsel-vol
configMap:
name: device-selector
items:
- key: selector
path: device-selector.yaml
7 changes: 7 additions & 0 deletions examples/remotevlan/rvlanovs/selector
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
interfaces:
- name: eth1
bridge: br0
matches:
- labelSelector:
- via: gw1
18 changes: 17 additions & 1 deletion examples/remotevlan/rvlanvpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Make sure that you have completed steps from [remotevlan](../../remotevlan) setu

## Includes

- [Kernel2RVlan](../../use-cases/Kernel2RVlan)
- [Kernel2RVlanInternal](../../use-cases/Kernel2RVlanInternal)
- [Kernel2RVlanBreakout](../../use-cases/Kernel2RVlanBreakout)
- [Kernel2RVlanMultiNS](../../use-cases/Kernel2RVlanMultiNS)

## Run

Expand All @@ -17,3 +19,17 @@ Deploy the forwarder:
```bash
kubectl apply -k .
```

Wait forwarder to start:

```bash
kubectl -n nsm-system wait --for=condition=ready --timeout=2m pod -l app=forwarder-vpp
```

## Cleanup

Delete the forwarder:

```bash
kubectl delete -k .
```
9 changes: 0 additions & 9 deletions examples/remotevlan/rvlanvpp/device-selector.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions examples/remotevlan/rvlanvpp/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ namespace: nsm-system
bases:
- ../../../apps/forwarder-vpp

resources:
- device-selector.yaml

configMapGenerator:
- name: device-selector
files:
- selector
patchesStrategicMerge:
- patch-forwarder-vpp.yaml
6 changes: 6 additions & 0 deletions examples/remotevlan/rvlanvpp/selector
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
interfaces:
- name: eth1
matches:
- labelSelector:
- via: gw1
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NAMESPACE=($(kubectl create -f https://raw.githubusercontent.com/networkservicem
NAMESPACE=${NAMESPACE:10}
```

Create first iperf server deployment:
Create iperf server deployment:

```bash
cat > first-iperf-s.yaml <<EOF
Expand Down Expand Up @@ -58,26 +58,10 @@ spec:
EOF
```

Create kustomization file:
Deploy the application:

```bash
cat > kustomization.yaml <<EOF
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: ${NAMESPACE}
resources:
- first-iperf-s.yaml
EOF
```

Deploy the iperf-NSCs:

```bash
kubectl apply -k .
kubectl apply -n ${NAMESPACE} -f ./first-iperf-s.yaml
```

Wait for applications ready:
Expand All @@ -92,19 +76,6 @@ Get the iperf-NSC pods:
NSCS=($(kubectl get pods -l app=iperf1-s -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'))
```

Start an iperf server in NSC:

```bash
IS_FIRST=$(kubectl exec ${NSCS[0]} -c iperf-server -n ${NAMESPACE} -- ip a s nsm-1 | grep 172.10.0.1)
if [ -n "$IS_FIRST" ]; then
kubectl exec ${NSCS[0]} -c iperf-server -n ${NAMESPACE} -- iperf3 -sD -B 172.10.0.1 -1
kubectl exec ${NSCS[1]} -c iperf-server -n ${NAMESPACE} -- iperf3 -i0 t 5 -c 172.10.0.1 -B 172.10.0.2
else
kubectl exec ${NSCS[1]} -c iperf-server -n ${NAMESPACE} -- iperf3 -sD -B 172.10.0.1 -1
kubectl exec ${NSCS[0]} -c iperf-server -n ${NAMESPACE} -- iperf3 -i0 t 5 -c 172.10.0.1 -B 172.10.0.2
fi
```

Create a docker image for test external connections:

```bash
Expand All @@ -131,30 +102,87 @@ docker exec rvm-tester ip addr add 172.10.0.254/24 dev eth0.100
docker exec rvm-tester ethtool -K eth0 tx off
```

Start the client from tester container:

```bash
docker exec rvm-tester ping -c 1 172.10.0.1
```

Start iperf client on tester:

```bash
IS_FIRST=$(kubectl exec ${NSCS[0]} -c iperf-server -n ${NAMESPACE} -- ip a s nsm-1 | grep 172.10.0.1)
if [ -n "$IS_FIRST" ]; then
kubectl exec ${NSCS[0]} -c iperf-server -n ${NAMESPACE} -- iperf3 -sD -B 172.10.0.1 -1
else
kubectl exec ${NSCS[1]} -c iperf-server -n ${NAMESPACE} -- iperf3 -sD -B 172.10.0.1 -1
fi
docker exec rvm-tester iperf3 -i0 t 5 -c 172.10.0.1
```
1. TCP

```bash
status=0
for nsc in "${NSCS[@]}"
do
IP_ADDRESS=$(kubectl exec ${nsc} -c cmd-nsc -n ${NAMESPACE} -- ip -4 addr show nsm-1 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
kubectl exec ${nsc} -c iperf-server -n ${NAMESPACE} -- iperf3 -sD -B ${IP_ADDRESS} -1
docker exec rvm-tester iperf3 -i0 -t 125 -c ${IP_ADDRESS}
if test $? -ne 0
then
status=1
fi
done
if test ${status} -eq 1
then
false
fi
```

2. UDP

```bash
status=0
for nsc in "${NSCS[@]}"
do
IP_ADDRESS=$(kubectl exec ${nsc} -c cmd-nsc -n ${NAMESPACE} -- ip -4 addr show nsm-1 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
kubectl exec ${nsc} -c iperf-server -n ${NAMESPACE} -- iperf3 -sD -B ${IP_ADDRESS} -1
docker exec rvm-tester iperf3 -i0 -t 5 -u -c ${IP_ADDRESS}
if test $? -ne 0
then
status=1
fi
done
if test ${status} -eq 1
then
false
fi
```

Start iperf server on tester:

```bash
docker exec rvm-tester iperf3 -sD -B 172.10.0.254 -1
kubectl exec ${NSCS[0]} -c iperf-server -n ${NAMESPACE} -- iperf3 -i0 t 5 -c 172.10.0.254
```
1. TCP

```bash
status=0
for nsc in "${NSCS[@]}"
do
docker exec rvm-tester iperf3 -sD -B 172.10.0.254 -1
kubectl exec ${nsc} -c iperf-server -n ${NAMESPACE} -- iperf3 -i0 -t 5 -c 172.10.0.254
if test $? -ne 0
then
status=1
fi
done
if test ${status} -eq 1
then
false
fi
```

2. UDP

```bash
status=0
for nsc in "${NSCS[@]}"
do
docker exec rvm-tester iperf3 -sD -B 172.10.0.254 -1
kubectl exec ${NSCS[1]} -c iperf-server -n ${NAMESPACE} -- iperf3 -i0 -t 5 -u -c 172.10.0.254
if test $? -ne 0
then
status=1
fi
done
if test ${status} -eq 1
then
false
fi
```

## Cleanup

Expand Down
2 changes: 2 additions & 0 deletions examples/use-cases/Kernel2RVlanInternal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
first-iperf-s.yaml
Dockerfile
Loading

0 comments on commit 50a25fc

Please sign in to comment.