diff --git a/examples/features/README.md b/examples/features/README.md index 8a2e016ea4b6..4548acc6494a 100644 --- a/examples/features/README.md +++ b/examples/features/README.md @@ -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) diff --git a/examples/features/scaled-registry/README.md b/examples/features/scaled-registry/README.md new file mode 100644 index 000000000000..4ace5c4d16ba --- /dev/null +++ b/examples/features/scaled-registry/README.md @@ -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 +``` diff --git a/examples/features/scaled-registry/kustomization.yaml b/examples/features/scaled-registry/kustomization.yaml new file mode 100644 index 000000000000..ab3aaf454d67 --- /dev/null +++ b/examples/features/scaled-registry/kustomization.yaml @@ -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 diff --git a/examples/features/scaled-registry/netsvc.yaml b/examples/features/scaled-registry/netsvc.yaml new file mode 100644 index 000000000000..4a4937b925a9 --- /dev/null +++ b/examples/features/scaled-registry/netsvc.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: networkservicemesh.io/v1 +kind: NetworkService +metadata: + name: scaled-registry +spec: + payload: ETHERNET diff --git a/examples/features/scaled-registry/ns-scaled-registry.yaml b/examples/features/scaled-registry/ns-scaled-registry.yaml new file mode 100644 index 000000000000..db0424f7bccd --- /dev/null +++ b/examples/features/scaled-registry/ns-scaled-registry.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: ns-scaled-registry diff --git a/examples/features/scaled-registry/patch-nse.yaml b/examples/features/scaled-registry/patch-nse.yaml new file mode 100644 index 000000000000..cba9286cf44b --- /dev/null +++ b/examples/features/scaled-registry/patch-nse.yaml @@ -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"