Skip to content

Commit

Permalink
add smartvf vlan trunking example
Browse files Browse the repository at this point in the history
Signed-off-by: Periyasamy Palanisamy <[email protected]>
  • Loading branch information
pperiyasamy committed Nov 23, 2021
1 parent c562474 commit 993430c
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/ovs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Contain basic setup for NSM that includes `nsmgr`, `forwarder-ovs`, `registry-k8
- [Kernel to Kernel Connection](../use-cases/Kernel2Kernel)
- [Kernel to Kernel Connection over VLAN Trunking](../use-cases/Kernel2KernelVLAN)
- [SmartVF to SmartVF Connection](../use-cases/SmartVF2SmartVF)
- [SmartVF to SmartVF Connection over VLAN Trunking](../use-cases/SmartVf2SmartVfVlan)
- [Admission webhook SmartVF example](../features/webhook-smartvf)

## SR-IOV config
Expand Down
128 changes: 128 additions & 0 deletions examples/use-cases/SmartVf2SmartVfVlan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Test SmartVF to SmartVF connection over VLAN Trunking at NSE side


This example shows that NS Clients and NSE on the one node can find each other.

NS Clients and NSE are using the `kernel` mechanism via SmartVF device to connect to its local ovs forwarder.
The NS Client connections are multiplexed over single VF device on the NSE side.

## Requires

Make sure that you have completed steps from [ovs](../../ovs) setup.
There is more consumption of heap memory by NSE pod due to vpp process when host is configured with
hugepage, so in this case NSE pod should be created with memory limit > 2.2 GB.

## Run

Create test namespace:
```bash
NAMESPACE=($(kubectl create -f https://raw.githubusercontent.com/networkservicemesh/deployments-k8s/95391f6d46abc524f4b740ee093a2ec14f4eff01/examples/use-cases/namespace.yaml)[0])
NAMESPACE=${NAMESPACE:10}
```

Select node to deploy NSC and NSE:
```bash
NODE=($(kubectl get nodes -o go-template='{{range .items}}{{ if not .spec.taints }}{{index .metadata.labels "kubernetes.io/hostname"}} {{end}}{{end}}')[0])
```

Create customization file:
```bash
cat > kustomization.yaml <<EOF
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: ${NAMESPACE}
bases:
- https://github.com/networkservicemesh/deployments-k8s/apps/nsc-kernel?ref=95391f6d46abc524f4b740ee093a2ec14f4eff01
- https://github.com/networkservicemesh/deployments-k8s/apps/nse-vlan-vpp?ref=95391f6d46abc524f4b740ee093a2ec14f4eff01
patchesStrategicMerge:
- patch-nsc.yaml
- patch-nse.yaml
EOF
```

Create NSC patch:
```bash
cat > patch-nsc.yaml <<EOF
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nsc-kernel
spec:
replicas: 2
template:
spec:
containers:
- name: nsc
env:
- name: NSM_NETWORK_SERVICES
value: kernel://vlan-vpp-responder/nsm-1?sriovToken=worker.domain/100G
resources:
limits:
worker.domain/100G: 1
nodeSelector:
kubernetes.io/hostname: ${NODE}
EOF
```

Create NSE patch:
```bash
cat > patch-nse.yaml <<EOF
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nse-kernel
spec:
template:
spec:
containers:
- name: nse
env:
- name: NSM_CIDR_PREFIX
value: 172.16.1.100/30
resources:
limits:
worker.domain/100G: 1
nodeSelector:
kubernetes.io/hostname: ${NODE}
EOF
```

Deploy NSC and NSE:
```bash
kubectl apply -k .
```

Wait for applications ready:
```bash
kubectl wait --for=condition=ready --timeout=1m pod -l app=nsc-kernel -n ${NAMESPACE}
```
```bash
kubectl wait --for=condition=ready --timeout=1m pod -l app=nse-kernel -n ${NAMESPACE}
```

Choose one ns client pod and nse pod by labels:
```bash
NSC=$((kubectl get pods -l app=nsc-kernel -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{" "}}{{end}}') | cut -d' ' -f1)
TARGET_IP=$(kubectl exec -ti ${NSC} -n ${NAMESPACE} -- ip route show | grep 172.16 | cut -d' ' -f1)
```
```bash
NSE=$(kubectl get pods -l app=nse-kernel -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
```
Ping from NSC to NSE:
```bash
kubectl exec ${NSC} -n ${NAMESPACE} -- ping -c 4 ${TARGET_IP}
```
## Cleanup
Delete ns:
```bash
kubectl delete ns ${NAMESPACE}
```

0 comments on commit 993430c

Please sign in to comment.