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 support. #11228

Merged
merged 52 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a091993
Add dual stack support.
Feb 6, 2024
ed1e898
Merge last changes.
Feb 8, 2024
2b720bd
Refactor deployment scheme.
Feb 13, 2024
7dbefd8
Update references
Mar 26, 2024
7d71fbf
Update references
Mar 26, 2024
e3a2d1e
Update references
Mar 26, 2024
aec2762
Update references
Mar 26, 2024
c0ad668
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
d72f806
Update references
Mar 26, 2024
7211f57
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
527dde7
Update references
Mar 26, 2024
998f9f2
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
0a24adf
Update references
Mar 26, 2024
56b58c2
Update references
Mar 26, 2024
ec3a76e
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
ee677b1
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
06b7fb4
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
0d9b17d
Update references
Mar 26, 2024
cdd2d12
Update references
Mar 26, 2024
cb2f6c7
Update references
Mar 26, 2024
6827592
Update references
Mar 26, 2024
f381ae3
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
909f3d0
Update references
Mar 26, 2024
1c7d186
Update references
Mar 26, 2024
9f073d0
Update references
Mar 26, 2024
d1913d0
Update references
Mar 26, 2024
c246188
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
e1e3b85
Update references
Mar 26, 2024
c267d63
Update references
Mar 26, 2024
08f711f
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
b240202
Update references
Mar 26, 2024
9e627ef
Update references
Mar 26, 2024
3c8ba64
Update references
Mar 26, 2024
b64f6a0
Update references
Mar 26, 2024
16f3e49
Update references
Mar 26, 2024
3f9fec7
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
71c8e96
Update references
Mar 26, 2024
1c78ec0
Update references
Mar 26, 2024
71787d9
Update references
Mar 26, 2024
c523518
Update go.mod and go.sum to latest version from networkservicemesh/cm…
nsmbot Mar 26, 2024
4b35a79
Update references
Mar 26, 2024
51f4f5c
Update references
Mar 26, 2024
24c646f
Update references
Mar 26, 2024
ae44b85
Update references
Mar 26, 2024
1407ee3
Update references
Mar 26, 2024
c014f98
Update references
Mar 26, 2024
b95b9f0
Update references
Mar 26, 2024
8356cc8
Update references
Mar 26, 2024
b567c5b
Update references
Mar 26, 2024
96a21bf
Update references
Mar 26, 2024
4f0a467
Merge last changes.
Mar 26, 2024
5103ad2
Merge last changes.
Mar 27, 2024
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
1 change: 1 addition & 0 deletions examples/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ To run any feature example follow steps for [Basic NSM setup](../basic)
- [Memif2IP2Memif IPv6 example](ipv6/Memif2IP2Memif_ipv6)
- [Kernel2Kernel dual stack example](dual-stack/Kernel2Kernel_dual_stack)
- [Kernel2IP2Kernel dual stack example](dual-stack/Kernel2IP2Kernel_dual_stack)
- [vL3 dual stack example](dual-stack/vl3-dual-stack)
- [Admission webhook](./webhook)
- [DNS](./dns)
- [Topology aware scale from zero](./scale-from-zero)
Expand Down
92 changes: 92 additions & 0 deletions examples/features/dual-stack/vl3-dual-stack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# vL3 dual stack example

This example shows how could be configured vL3 dual stack network via NSM.

Diagram:

![NSM vL3 dual stack Diagram](./vl3-dual-stack.png "NSM Authorize Scheme")

**NOTE: Forwarder and NSMmgr are missed in the diagram for the simplicity**


## Run

Deploy network service, nsc and vl3 nses (See at `kustomization.yaml`):
```bash
kubectl apply -k https://github.com/networkservicemesh/deployments-k8s/examples/features/dual-stack/vl3-dual-stack?ref=05a9319b78acdb91b0d4d0ef6b21736d7b17602c
kubectl apply -k https://github.com/networkservicemesh/deployments-k8s/examples/features/dual-stack/vl3-dual-stack/ipam-ipv6?ref=05a9319b78acdb91b0d4d0ef6b21736d7b17602c
```

Wait for clients to be ready:
```bash
kubectl wait --for=condition=ready --timeout=2m pod -l app=alpine -n ns-vl3-dual-stack
```

Find all nscs:
```bash
nscs=$(kubectl get pods -l app=alpine -o go-template --template="{{range .items}}{{.metadata.name}} {{end}}" -n ns-vl3-dual-stack)
[[ ! -z $nscs ]]
```

Ping each client by each client:
```bash
(
for nsc in $nscs
do
ipAddr=$(kubectl exec -n ns-vl3-dual-stack $nsc -- ifconfig nsm-1) || exit
ipv4Addr=$(echo $ipAddr | grep -Eo 'inet addr:[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'| cut -c 11-)
ipv6Addr=$(echo $ipAddr | grep -Eo 'inet6 addr: 2001:.*' | cut -d ' ' -f 3 | cut -d '/' -f 1)
for pinger in $nscs
do
if [ "$nsc" != "$pinger" ]; then
echo $pinger pings $ipv4Addr
kubectl exec $pinger -n ns-vl3-dual-stack -- ping -c2 -i 0.5 $ipv4Addr || exit
echo $pinger pings $ipv6Addr
kubectl exec $pinger -n ns-vl3-dual-stack -- ping6 -c2 -i 0.5 $ipv6Addr || exit
fi
done
done
)
```

Ping each vl3-nse by each client.
Note: By default ipam prefixes are `172.16.0.0/16` and `2001:db8::/64` and corresponding client prefix len-s are `24` and `112`. We also have two vl3 nses in this example. So we expect to have two ipv4 vl3 addresses: `172.16.0.0` and `172.16.1.0` and two ipv6 vl3 addresses: `2001:db8::` and `2001:db8::1:0` that should be accessible by each client.
```bash
(
for nsc in $nscs
do
echo $nsc pings nses
kubectl exec -n ns-vl3-dual-stack $nsc -- ping 172.16.0.0 -c2 -i 0.5 || exit
kubectl exec -n ns-vl3-dual-stack $nsc -- ping 172.16.1.0 -c2 -i 0.5 || exit
kubectl exec -n ns-vl3-dual-stack $nsc -- ping6 2001:db8:: -c2 -i 0.5 || exit
kubectl exec -n ns-vl3-dual-stack $nsc -- ping6 2001:db8::1:0 -c2 -i 0.5 || exit
done
)
```

Find all nses:
```bash
nses=$(kubectl get pods -l app=nse-vl3-vpp -o go-template --template="{{range .items}}{{.metadata.name}} {{end}}" -n ns-vl3-dual-stack)
[[ ! -z $nses ]]
```

Ping vl3-nse by each vl3-nse.
```bash
(
for nse in $nses
do
echo $nse pings nses
kubectl exec -n ns-vl3-dual-stack $nse -- ping 172.16.0.0 -c2 -i 0.5 || exit
kubectl exec -n ns-vl3-dual-stack $nse -- ping 172.16.1.0 -c2 -i 0.5 || exit
kubectl exec -n ns-vl3-dual-stack $nse -- ping6 2001:db8:: -c2 -i 0.5 || exit
kubectl exec -n ns-vl3-dual-stack $nse -- ping6 2001:db8::1:0 -c2 -i 0.5 || exit
done
)
```

## Cleanup

To cleanup the example just follow the next command:
```bash
kubectl delete ns ns-vl3-dual-stack
```
26 changes: 26 additions & 0 deletions examples/features/dual-stack/vl3-dual-stack/client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: alpine
labels:
app: alpine
spec:
replicas: 2
selector:
matchLabels:
app: alpine
template:
metadata:
labels:
app: alpine
annotations:
networkservicemesh.io: kernel://vl3-dual-stack/nsm-1
spec:
containers:
- name: alpine
image: alpine:3.15.0
imagePullPolicy: IfNotPresent
# simple `sleep` command would work
# but we need `trap` to be able to delete pods quckly
command: ["/bin/sh", "-c", "trap : TERM INT; sleep infinity & wait"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- op: replace
path: /metadata/name
value: vl3-ipam-ds-ipv4
- op: replace
path: /metadata/labels/app
value: vl3-ipam-ds-ipv4
- op: replace
path: /spec/selector/matchLabels/app
value: vl3-ipam-ds-ipv4
- op: replace
path: /spec/template/metadata/labels/app
value: vl3-ipam-ds-ipv4
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- op: replace
path: /metadata/name
value: vl3-ipam-ds-ipv6
- op: replace
path: /metadata/labels/app
value: vl3-ipam-ds-ipv6
- op: replace
path: /spec/selector/matchLabels/app
value: vl3-ipam-ds-ipv6
- op: replace
path: /spec/template/metadata/labels/app
value: vl3-ipam-ds-ipv6
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: vl3-ipam
labels:
app: vl3-ipam
spec:
template:
spec:
containers:
- name: vl3-ipam
env:
- name: NSM_PREFIX
value: 2001:db8::/64
- name: NSM_CLIENT_PREFIX_LEN
value: "112"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- op: replace
path: /metadata/name
value: vl3-ipam-ds-ipv6
- op: replace
path: /spec/selector/app
value: vl3-ipam-ds-ipv6
- op: replace
path: /spec/ports/0/name
value: vl3-ipam-ds-ipv6
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ns-vl3-dual-stack

resources:
- ../../../../../apps/vl3-ipam

patches:
- path: ipam-patch.yaml
- target:
version: v1
kind: Deployment
name: vl3-ipam
path: ipam-deployment-patch.yaml
- target:
version: v1
kind: Service
name: vl3-ipam
path: ipam-service-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- op: replace
path: /metadata/name
value: vl3-ipam-ds-ipv4
- op: replace
path: /spec/selector/app
value: vl3-ipam-ds-ipv4
- op: replace
path: /spec/ports/0/name
value: vl3-ipam-ds-ipv4
25 changes: 25 additions & 0 deletions examples/features/dual-stack/vl3-dual-stack/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ns-vl3-dual-stack

resources:
- ns-vl3-dual-stack.yaml
- netsvc.yaml
- client.yaml
- ../../../../apps/vl3-ipam
- ../../../../apps/nse-vl3-vpp

patches:
- path: nse-patch.yaml
- target:
version: v1
kind: Deployment
name: vl3-ipam
path: ipam-deployment-patch.yaml
- target:
version: v1
kind: Service
name: vl3-ipam
path: ipam-service-patch.yaml
7 changes: 7 additions & 0 deletions examples/features/dual-stack/vl3-dual-stack/netsvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: networkservicemesh.io/v1
kind: NetworkService
metadata:
name: vl3-dual-stack
spec:
payload: IP
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: ns-vl3-dual-stack
20 changes: 20 additions & 0 deletions examples/features/dual-stack/vl3-dual-stack/nse-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nse-vl3-vpp
labels:
app: nse-vl3-vpp
spec:
replicas: 2
template:
spec:
containers:
- name: nse
env:
- name: NSM_PREFIX_SERVER_URL
value: "vl3-ipam-ds-ipv4:5006,vl3-ipam-ds-ipv6:5006"
- name: NSM_SERVICE_NAMES
value: "vl3-dual-stack"
- name: NSM_REGISTER_SERVICE
value: "false"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading