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

Add dual stack examples #5569

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ To run any feature example follow steps for [Basic NSM setup](../basic)
- [Kernel2Wireguard2Memif IPv6 example](ipv6/Kernel2Wireguard2Memif_ipv6)
- [Memif2Wireguard2Kernel IPv6 example](ipv6/Memif2Wireguard2Kernel_ipv6)
- [Memif2Wireguard2Memif IPv6 example](ipv6/Memif2Wireguard2Memif_ipv6)
- [Kernel2Kernel dual stack example](dual-stack/Kernel2Kernel_dual_stack)
- [Kernel2Wireguard2Kernel dual stack example](dual-stack/Kernel2Wireguard2Kernel_dual_stack)
- [Admission webhook](./webhook)
- [DNS](./dns)
- [Topology aware scale from zero](./scale-from-zero)
Expand Down
2 changes: 2 additions & 0 deletions examples/features/dual-stack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
client.yaml

128 changes: 128 additions & 0 deletions examples/features/dual-stack/Kernel2Kernel_dual_stack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Test kernel to kernel connection


This example shows that NSC and NSE on the one node can find each other by ipv6 addresses.

NSC and NSE are using the `kernel` mechanism to connect to its local forwarder.

## Run

Create test namespace:
```bash
NAMESPACE=($(kubectl create -f https://raw.githubusercontent.com/networkservicemesh/deployments-k8s/7d08174431e049a31fdaf574e03f12ea965c4f5b/examples/features/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}

resources:
- client.yaml
bases:
- https://github.com/networkservicemesh/deployments-k8s/apps/nse-kernel?ref=7d08174431e049a31fdaf574e03f12ea965c4f5b

patchesStrategicMerge:
- patch-nse.yaml
EOF
```

Create Client:
```bash
cat > client.yaml <<EOF
---
apiVersion: v1
kind: Pod
metadata:
name: alpine
labels:
app: alpine
annotations:
networkservicemesh.io: kernel://icmp-responder/nsm-1
spec:
containers:
- name: alpine
image: alpine:3.15.0
imagePullPolicy: IfNotPresent
stdin: true
tty: true
nodeName: ${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/31,2001:db8::/116
nodeName: ${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=alpine -n ${NAMESPACE}
```
```bash
kubectl wait --for=condition=ready --timeout=1m pod -l app=nse-kernel -n ${NAMESPACE}
```

Find NSC and NSE pods by labels:
```bash
NSC=$(kubectl get pods -l app=alpine -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
```
```bash
NSE=$(kubectl get pods -l app=nse-kernel -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
```

Check connectivity:
```bash
kubectl exec ${NSC} -n ${NAMESPACE} -- ping -c 4 2001:db8::
```

Check connectivity:
```bash
kubectl exec ${NSE} -n ${NAMESPACE} -- ping -c 4 2001:db8::1
```

Ping from NSC to NSE:
```bash
kubectl exec ${NSC} -n ${NAMESPACE} -- ping -c 4 172.16.1.100
```

Ping from NSE to NSC:
```bash
kubectl exec ${NSE} -n ${NAMESPACE} -- ping -c 4 172.16.1.101
```

## Cleanup

Delete ns:
```bash
kubectl delete ns ${NAMESPACE}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Test kernel to wireguard to kernel connection

This example shows that NSC and NSE on the different nodes could find and work with each other using IPv6.

NSC and NSE are using the `kernel` mechanism to connect to its local forwarder.
Forwarders are using the `wireguard` mechanism to connect with each other.

## Run

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

Get nodes exclude control-plane:
```bash
NODES=($(kubectl get nodes -o go-template='{{range .items}}{{ if not .spec.taints }}{{index .metadata.labels "kubernetes.io/hostname"}} {{end}}{{end}}'))
```

Create customization file:
```bash
cat > kustomization.yaml <<EOF
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ${NAMESPACE}

resources:
- client.yaml
bases:
- https://github.com/networkservicemesh/deployments-k8s/apps/nse-kernel?ref=7d08174431e049a31fdaf574e03f12ea965c4f5b

patchesStrategicMerge:
- patch-nse.yaml
EOF
```

Create Client:
```bash
cat > client.yaml <<EOF
---
apiVersion: v1
kind: Pod
metadata:
name: alpine
labels:
app: alpine
annotations:
networkservicemesh.io: kernel://icmp-responder-ip/nsm-1
spec:
containers:
- name: alpine
image: alpine:3.15.0
imagePullPolicy: IfNotPresent
stdin: true
tty: true
nodeName: ${NODES[0]}
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/31,2001:db8::/116
- name: NSM_PAYLOAD
value: IP
- name: NSM_SERVICE_NAMES
value: icmp-responder-ip
nodeName: ${NODES[1]}
EOF
```

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

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

Find NSC and NSE pods by labels:
```bash
NSC=$(kubectl get pods -l app=alpine -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
```
```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 2001:db8::
```

Ping from NSE to NSC:
```bash
kubectl exec ${NSE} -n ${NAMESPACE} -- ping -c 4 2001:db8::1
```

Ping from NSC to NSE:
```bash
kubectl exec ${NSC} -n ${NAMESPACE} -- ping -c 4 172.16.1.100
```

Ping from NSE to NSC:
```bash
kubectl exec ${NSE} -n ${NAMESPACE} -- ping -c 4 172.16.1.101
```
## Cleanup

Delete ns:
```bash
kubectl delete ns ${NAMESPACE}
```
4 changes: 1 addition & 3 deletions examples/remotevlan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ spec:
- name: NSM_SERVICES
value: "finance-bridge { vlan: 100; via: gw1}"
- name: NSM_CIDR_PREFIX
value: "172.10.0.0/24"
- name: NSM_IPV6_PREFIX
value: "100:200::/64"
value: 172.10.0.0/24,100:200::/64
- name: NSM_MAX_TOKEN_LIFETIME
value: "60s"
EOF
Expand Down
10 changes: 3 additions & 7 deletions examples/use-cases/Kernel2RVlanMultiNS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ spec:
- name: NSM_SERVICES
value: "private-bridge.${FIRST_NAMESPACE} { vlan: 200; via: gw1 }"
- name: NSM_CIDR_PREFIX
value: "172.10.1.0/24"
- name: NSM_IPV6_PREFIX
value: "100:201::/64"
value: 172.10.1.0/24,100:201::/64
EOF
```

Expand Down Expand Up @@ -219,9 +217,7 @@ spec:
- name: NSM_SERVICES
value: "blue-bridge.${SECOND_NAMESPACE} { vlan: 300; via: gw1 }, green-bridge.${SECOND_NAMESPACE} { vlan: 400; via: gw1 }"
- name: NSM_CIDR_PREFIX
value: "172.10.2.0/24"
- name: NSM_IPV6_PREFIX
value: "100:202::/64"
value: 172.10.2.0/24,100:202::/64
EOF
```

Expand All @@ -240,7 +236,7 @@ resources:
- third-client.yaml

bases:
- ../../../../apps/nse-remote-vlan
- https://github.com/networkservicemesh/deployments-k8s/apps/nse-remote-vlan?ref=7d08174431e049a31fdaf574e03f12ea965c4f5b

nameSuffix: -bg

Expand Down