Skip to content

Commit

Permalink
Add NSE unregister scenario with scaled registry-k8s (#10222)
Browse files Browse the repository at this point in the history
* add NSE unregister scenario with scaled registry-k8s

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* cleanup

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

* cleanup

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>

---------

Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik authored Dec 18, 2023
1 parent d502240 commit 18010a0
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ To run any feature example follow steps for [Basic NSM setup](../basic)
- [vL3 Load Balancer](./vl3-lb)
- [Inject clients in namespace via NSM annotation](./annotated-namespace)
- [NSC connects to multiple services](./multiple-services)
- [Scaled Registry K8s](./scaled-registry)
62 changes: 62 additions & 0 deletions examples/features/scaled-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Test scaled registry-k8s

This example shows that registry-k8s can be easly scaled. NSEs can Register and Unregister themselves in any of
the registries.

## Requires

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

## Run

Deploy NSE:
```bash
kubectl apply -k https://github.com/networkservicemesh/deployments-k8s/examples/features/scaled-registry?ref=5bb6afc5f5199a63e470b3552803d06f6b70cc61
```

Wait for NSE to be ready:
```bash
kubectl wait --for=condition=ready --timeout=1m pod -l app=nse-kernel -n ns-scaled-registry
```

Check registered NSE in `etcd`
```bash
kubectl get nses -A | grep nse-kernel
```

Delete current instance of registry-k8s
```bash
kubectl scale --replicas=0 deployments/registry-k8s -n nsm-system
```

Check registered NSE in `etcd` after registry-k8s instance deletion
```bash
kubectl get nses -A | grep nse-kernel
```

Deploy two new instances of registry-k8s
```bash
kubectl scale --replicas=2 deployments/registry-k8s -n nsm-system
```

Wait for the new registry-k8s instances to be ready:
```bash
kubectl wait --for=condition=ready --timeout=1m pod -l app=registry -n nsm-system
```

Delete NSE (it unregisters itself on deletion)
```bash
kubectl scale --replicas=0 deployments/nse-kernel -n ns-scaled-registry
```

Check there is no any NSEs in `etcd` after NSE unregisters itself through the new registries
```bash
kubectl get nses -A | grep -v nse-kernel
```

## Cleanup

Delete ns:
```bash
kubectl delete ns ns-scaled-registry
```
13 changes: 13 additions & 0 deletions examples/features/scaled-registry/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ns-scaled-registry

resources:
- ns-scaled-registry.yaml
- netsvc.yaml
- ../../../apps/nse-kernel

patchesStrategicMerge:
- patch-nse.yaml
7 changes: 7 additions & 0 deletions examples/features/scaled-registry/netsvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: networkservicemesh.io/v1
kind: NetworkService
metadata:
name: scaled-registry
spec:
payload: ETHERNET
5 changes: 5 additions & 0 deletions examples/features/scaled-registry/ns-scaled-registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: ns-scaled-registry
19 changes: 19 additions & 0 deletions examples/features/scaled-registry/patch-nse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
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
- name: NSM_SERVICE_NAMES
value: "scaled-registry"
- name: NSM_REGISTER_SERVICE
value: "false"
- name: NSM_UNREGISTER_ITSELF
value: "true"

0 comments on commit 18010a0

Please sign in to comment.