Skip to content
Draft
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: 1 addition & 1 deletion apps/admission-webhook-k8s/admission-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ spec:
- name: NSM_LABELS
value: spiffe.io/spiffe-id:true
- name: NSM_ENVS
value: NSM_LOG_LEVEL=TRACE
value: NSM_LIVENESS_CHECK_ENABLED=false
2 changes: 1 addition & 1 deletion examples/features/annotated-namespace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Make sure that you have completed steps from [basic](../../basic) or [memory](..

## Run

Create test namespace and deploy NSE:
Create test namespace and deploy NSE and emoji client:
```bash
kubectl apply -k https://github.com/networkservicemesh/deployments-k8s/examples/features/annotated-namespace?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
```
Expand Down
4 changes: 2 additions & 2 deletions examples/interdomain/nsm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This example simply show how can be deployed and configured two NSM on different

Install NSM
```bash
kubectl --kubeconfig=$KUBECONFIG1 apply -k https://github.com/networkservicemesh/deployments-k8s/examples/interdomain/nsm/cluster1?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
kubectl --kubeconfig=$KUBECONFIG2 apply -k https://github.com/networkservicemesh/deployments-k8s/examples/interdomain/nsm/cluster2?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
kubectl --kubeconfig=$KUBECONFIG1 apply -k ./nsm/cluster1
kubectl --kubeconfig=$KUBECONFIG2 apply -k ./nsm/cluster2
```

Wait for admission-webhook-k8s:
Expand Down
2 changes: 1 addition & 1 deletion examples/interdomain/nsm/cluster1/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bases:
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-k8s?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-proxy-dns?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- https://github.com/networkservicemesh/deployments-k8s/apps/nsmgr-proxy?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- https://github.com/networkservicemesh/deployments-k8s/apps/admission-webhook-k8s?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- ../../../../apps/admission-webhook-k8s

resources:
- namespace.yaml
Expand Down
2 changes: 1 addition & 1 deletion examples/interdomain/nsm/cluster2/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bases:
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-k8s?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-proxy-dns?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- https://github.com/networkservicemesh/deployments-k8s/apps/nsmgr-proxy?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- https://github.com/networkservicemesh/deployments-k8s/apps/admission-webhook-k8s?ref=40eba2b9d535b7e3c0e3f7463af6227d863c5a32
- ../../../../apps/admission-webhook-k8s

patchesStrategicMerge:
- patch-nsmgr-proxy.yaml
Expand Down
212 changes: 212 additions & 0 deletions examples/interdomain/nsm_linkerd-1cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Test automatic scale from zero

This example shows how Linkerd can be integrated with one of classic NSM examples.

## Run

Install Linkerd CLI:
```bash
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh
```
Verify Linkerd CLI is installed:
```bash
linkerd version
```
If not, export linkerd path to $PATH:
export PATH=$PATH:/home/amalysheva/.linkerd2/bin

Install Linkerd onto cluster:
```bash
linkerd check --pre
linkerd install --crds | kubectl apply -f -
linkerd install | kubectl apply -f -
linkerd check
```


1. Create test namespace:
```bash
kubectl create ns ns-nsm-linkerd
```

2. Select nodes to deploy NSC and supplier:
```bash
NODES=($(kubectl get nodes -o go-template='{{range .items}}{{ if not .spec.taints }}{{ .metadata.name }} {{end}}{{end}}'))
NSC_NODE=${NODES[0]}
SUPPLIER_NODE=${NODES[1]}
if [ "$SUPPLIER_NODE" == "" ]; then SUPPLIER_NODE=$NSC_NODE; echo "Only 1 node found, testing that pod is created on the same node is useless"; fi
```

3. Create patch for NSC:
```bash
cat > patch-nsc.yaml <<EOF
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nsc-kernel
spec:
template:
spec:
nodeName: $NSC_NODE
containers:
- name: nsc
env:
- name: NSM_NETWORK_SERVICES
value: kernel://autoscale-icmp-responder/nsm-1
- name: NSM_REQUEST_TIMEOUT
value: 30s
EOF
```

4. Create patch for supplier:
```bash
cat > patch-supplier.yaml <<EOF
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nse-supplier-k8s
spec:
template:
spec:
nodeName: $SUPPLIER_NODE
containers:
- name: nse-supplier
env:
- name: NSM_SERVICE_NAME
value: autoscale-icmp-responder
- name: NSM_LABELS
value: app:icmp-responder-supplier
- name: NSM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: NSM_POD_DESCRIPTION_FILE
value: /run/supplier/pod-template.yaml
volumeMounts:
- name: pod-file
mountPath: /run/supplier
readOnly: true
volumes:
- name: pod-file
configMap:
name: supplier-pod-template-configmap
EOF
```

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

namespace: ns-nsm-linkerd

bases:
- https://github.com/networkservicemesh/deployments-k8s/apps/nse-supplier-k8s?ref=5278bf09564d36b701e8434d9f1d4be912e6c266
- https://github.com/networkservicemesh/deployments-k8s/apps/nsc-kernel?ref=5278bf09564d36b701e8434d9f1d4be912e6c266

patchesStrategicMerge:
- patch-nsc.yaml
- patch-supplier.yaml

configMapGenerator:
- name: supplier-pod-template-configmap
files:
- https://raw.githubusercontent.com/networkservicemesh/deployments-k8s/5278bf09564d36b701e8434d9f1d4be912e6c266/examples/features/scale-from-zero/pod-template.yaml
EOF
```

6. Register network service:
```bash
kubectl apply -f https://raw.githubusercontent.com/networkservicemesh/deployments-k8s/5278bf09564d36b701e8434d9f1d4be912e6c266/examples/features/scale-from-zero/autoscale-netsvc.yaml
```

7. Deploy NSC and supplier:
```bash
kubectl apply -k .
```

8. Wait for applications ready:
```bash
kubectl wait -n ns-nsm-linkerd --for=condition=ready --timeout=1m pod -l app=nse-supplier-k8s
kubectl wait -n ns-nsm-linkerd --for=condition=ready --timeout=1m pod -l app=nsc-kernel
kubectl wait -n ns-nsm-linkerd --for=condition=ready --timeout=1m pod -l app=nse-icmp-responder
```

9. Find NSC and NSE pods by labels:
```bash
NSC=$(kubectl get pod -n ns-nsm-linkerd --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' -l app=nsc-kernel)
NSE=$(kubectl get pod -n ns-nsm-linkerd --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' -l app=nse-icmp-responder)
```

Check connectivity:
```bash
kubectl exec $NSC -n ns-nsm-linkerd -- ping -c 4 169.254.0.0
```
```bash
kubectl exec $NSE -n ns-nsm-linkerd -- ping -c 4 169.254.0.1
```
Remove NSC:
```bash
kubectl scale -n ns-nsm-linkerd deployment nsc-kernel --replicas=0
```

Wait for the NSE pod to be deleted:
```bash
kubectl wait -n ns-nsm-linkerd --for=delete --timeout=1m pod -l app=nse-icmp-responder
```
Scale NSC up:
```bash
kubectl scale -n ns-nsm-linkerd deployment nsc-kernel --replicas=1
```

Inject Linkerd into NSC:
```bash
kubectl get -n ns-nsm-linkerd deploy nsc-kernel -o yaml | linkerd inject - | kubectl apply -f -
```
```bash
NSC=$(kubectl get pod -n ns-nsm-linkerd --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' -l app=nsc-kernel)
```

10. Check connectivity:
```bash
kubectl exec $NSC -n ns-nsm-linkerd -c nsc -- ping -c 4 169.254.0.0
```
```bash
kubectl exec $NSE -n ns-nsm-linkerd -- ping -c 4 169.254.0.1
```
Remove NSC:
```bash
kubectl scale -n ns-nsm-linkerd deployment nsc-kernel --replicas=0
```

Wait for the NSE pod to be deleted:
```bash
kubectl wait -n ns-nsm-linkerd --for=delete --timeout=1m pod -l app=nse-icmp-responder
```





## Cleanup

Uninject linkerd proxy from deployments:
```bash
kubectl get -n ns-nsm-linkerd deploy nsc-kernel -o yaml | linkerd uninject - | kubectl apply -f -
```
Delete namespace:
```bash
kubectl delete ns ns-nsm-linkerd
```
Delete network service:
```bash
kubectl delete -n nsm-system networkservices.networkservicemesh.io autoscale-icmp-responder
```
Remove Linkerd control plane from cluster:
```bash
linkerd uninstall | kubectl delete -f -
```
19 changes: 19 additions & 0 deletions examples/interdomain/nsm_linkerd-1cluster/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: ns-vl3-interdomain

resources:
- namespace.yaml
- ../../../../../apps/nsc-kernel
- ../../../../../apps/nse-supplier-k8s

patchesStrategicMerge:
- nsc-patch.yaml
- supplier-patch.yaml

configMapGenerator:
- name: supplier-pod-template-configmap
files:
- pod-template.yaml
5 changes: 5 additions & 0 deletions examples/interdomain/nsm_linkerd-1cluster/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: ns-nsm-linkerd
Loading