-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
- Loading branch information
Vladimir Popov
committed
Jun 7, 2021
1 parent
79e062a
commit ed6dfa5
Showing
6 changed files
with
480 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Heal examples | ||
|
||
This document contains links for heal examples of NSM. | ||
|
||
## Requires | ||
|
||
To run any feature example follow steps for [Basic NSM setup](../basic) | ||
|
||
## Includes | ||
|
||
- [Local NSMgr restart](local-nsmgr-restart) | ||
- [Remote NSMgr restart](remote-nsmgr-restart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
# Local NSMgr restart | ||
|
||
This example shows that NSM keeps working after the local NSMgr restart. | ||
|
||
NSC and NSE are using the `kernel` mechanism to connect to its local forwarder. | ||
Forwarders are using the `vxlan` mechanism to connect with each other. | ||
|
||
## Requires | ||
|
||
Make sure that you have completed steps from [basic](../../basic) or [memory](../../memory) setup. | ||
|
||
## Run | ||
|
||
Create test namespace: | ||
```bash | ||
NAMESPACE=($(kubectl create -f ../namespace.yaml)[0]) | ||
NAMESPACE=${NAMESPACE:10} | ||
``` | ||
|
||
Register namespace in `spire` server: | ||
```bash | ||
kubectl exec -n spire spire-server-0 -- \ | ||
/opt/spire/bin/spire-server entry create \ | ||
-spiffeID spiffe://example.org/ns/${NAMESPACE}/sa/default \ | ||
-parentID spiffe://example.org/ns/spire/sa/spire-agent \ | ||
-selector k8s:ns:${NAMESPACE} \ | ||
-selector k8s:sa:default | ||
``` | ||
|
||
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} | ||
bases: | ||
- ../../../apps/nsc-kernel | ||
- ../../../apps/nse-kernel | ||
patchesStrategicMerge: | ||
- patch-nsc.yaml | ||
- patch-nse.yaml | ||
EOF | ||
``` | ||
|
||
Create NSC patch: | ||
```bash | ||
cat > patch-nsc.yaml <<EOF | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nsc-kernel | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: nsc | ||
env: | ||
- name: NSM_NETWORK_SERVICES | ||
value: kernel://icmp-responder/nsm-1 | ||
nodeSelector: | ||
kubernetes.io/hostname: ${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: NSE_CIDR_PREFIX | ||
value: 172.16.1.100/31 | ||
nodeSelector: | ||
kubernetes.io/hostname: ${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=nsc-kernel -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=nsc-kernel -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 172.16.1.100 | ||
``` | ||
|
||
Ping from NSE to NSC: | ||
```bash | ||
kubectl exec ${NSE} -n ${NAMESPACE} -- ping -c 4 172.16.1.101 | ||
``` | ||
|
||
Find local NSMgr pod: | ||
```bash | ||
NSMGR=$(kubectl get pods -l app=nsmgr --field-selector spec.nodeName==${NODES[0]} -n nsm-system --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') | ||
``` | ||
|
||
Restart local NSMgr: | ||
```bash | ||
kubectl delete pod ${NSMGR} -n nsm-system | ||
sleep 70 | ||
``` | ||
|
||
Ping from NSC to NSE again after local NSMgr restored: | ||
```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} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
# Remote NSMgr restart | ||
|
||
This example shows that NSM keeps working after the remote NSMgr death. | ||
|
||
NSC and NSE are using the `kernel` mechanism to connect to its local forwarder. | ||
Forwarders are using the `vxlan` mechanism to connect with each other. | ||
|
||
## Requires | ||
|
||
Make sure that you have completed steps from [basic](../../basic) or [memory](../../memory) setup. | ||
|
||
## Run | ||
|
||
Create test namespace: | ||
```bash | ||
NAMESPACE=($(kubectl create -f ../namespace.yaml)[0]) | ||
NAMESPACE=${NAMESPACE:10} | ||
``` | ||
|
||
Register namespace in `spire` server: | ||
```bash | ||
kubectl exec -n spire spire-server-0 -- \ | ||
/opt/spire/bin/spire-server entry create \ | ||
-spiffeID spiffe://example.org/ns/${NAMESPACE}/sa/default \ | ||
-parentID spiffe://example.org/ns/spire/sa/spire-agent \ | ||
-selector k8s:ns:${NAMESPACE} \ | ||
-selector k8s:sa:default | ||
``` | ||
|
||
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} | ||
bases: | ||
- ../../../apps/nsc-kernel | ||
- ../../../apps/nse-kernel | ||
patchesStrategicMerge: | ||
- patch-nsc.yaml | ||
- patch-nse.yaml | ||
EOF | ||
``` | ||
|
||
Create NSC patch: | ||
```bash | ||
cat > patch-nsc.yaml <<EOF | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nsc-kernel | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: nsc | ||
env: | ||
- name: NSM_NETWORK_SERVICES | ||
value: kernel://icmp-responder/nsm-1 | ||
nodeSelector: | ||
kubernetes.io/hostname: ${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: NSE_CIDR_PREFIX | ||
value: 172.16.1.100/31 | ||
nodeSelector: | ||
kubernetes.io/hostname: ${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=nsc-kernel -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=nsc-kernel -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 172.16.1.100 | ||
``` | ||
|
||
Ping from NSE to NSC: | ||
```bash | ||
kubectl exec ${NSE} -n ${NAMESPACE} -- ping -c 4 172.16.1.101 | ||
``` | ||
|
||
Kill remote node: | ||
```bash | ||
kubectl | ||
``` | ||
|
||
Find remote NSMgr pod: | ||
```bash | ||
NSMGR=$(kubectl get pods -l app=nsmgr --field-selector spec.nodeName==${NODES[1]} -n nsm-system --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') | ||
``` | ||
|
||
Restart local NSMgr: | ||
```bash | ||
kubectl delete pod ${NSMGR} -n nsm-system | ||
sleep 70 | ||
``` | ||
|
||
Ping from NSC to NSE again after local NSMgr restored: | ||
```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} | ||
``` |
Oops, something went wrong.