From b89fada14f3b307a73224e17c28622c3c7a6302f Mon Sep 17 00:00:00 2001 From: Mikhail Avramenko Date: Fri, 20 Aug 2021 10:30:59 +0700 Subject: [PATCH] added performance testing infrastructure Signed-off-by: Mikhail Avramenko --- examples/performance-testing/.gitignore | 1 + .../Kernel2Vxlan2Kernel/README.md | 168 ++++++++++++++++++ .../Kernel2Vxlan2Kernel/test.sh | 145 +++++++++++++++ examples/performance-testing/namespace.yaml | 5 + 4 files changed, 319 insertions(+) create mode 100644 examples/performance-testing/.gitignore create mode 100644 examples/performance-testing/Kernel2Vxlan2Kernel/README.md create mode 100644 examples/performance-testing/Kernel2Vxlan2Kernel/test.sh create mode 100644 examples/performance-testing/namespace.yaml diff --git a/examples/performance-testing/.gitignore b/examples/performance-testing/.gitignore new file mode 100644 index 000000000000..60b8c45b1693 --- /dev/null +++ b/examples/performance-testing/.gitignore @@ -0,0 +1 @@ +**/kustomization.yaml \ No newline at end of file diff --git a/examples/performance-testing/Kernel2Vxlan2Kernel/README.md b/examples/performance-testing/Kernel2Vxlan2Kernel/README.md new file mode 100644 index 000000000000..8701ca063dc7 --- /dev/null +++ b/examples/performance-testing/Kernel2Vxlan2Kernel/README.md @@ -0,0 +1,168 @@ +# Test kernel to vxlan to kernel connection + +This example shows that NSC and NSE on the different nodes could find and work with each other. + +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}}')) +``` + +Setup for multiple clients +```bash +TEST_CLIENTS_N=8 +mkdir ns-clients +RESOURCES_STR="" +PATCHES_STR="" +for (( i = 1; i <= TEST_CLIENTS_N; i++ )); do + cp ../../../apps/nsc-kernel/nsc.yaml ./ns-clients/nsc-kernel-${i}.yaml + sed -i "s/nsc-kernel/nsc-kernel-${i}/g" ./ns-clients/nsc-kernel-${i}.yaml + RESOURCES_STR="${RESOURCES_STR}- ./ns-clients/nsc-kernel-${i}.yaml"$'\n' + PATCHES_STR="${PATCHES_STR}- patch-nsc-${i}.yaml"$'\n' + echo "$RESOURCES_STR" + echo "$PATCHES_STR" +done +pow=1 +val=2 +while (( TEST_CLIENTS_N >= val )); do + let pow=pow+1 + let val=val*2 +done +echo "$val" +echo "$pow" +``` + +Create customization file: +```bash +cat > kustomization.yaml < patch-nsc-${i}.yaml < patch-nse.yaml <= val )); do + ((pow=pow+1)) + ((val=val*2)) +done + +#kubectl create configmap iperf-script --from-file=iperf.sh + +cat > kustomization.yaml < patch-nsc-"${i}".yaml < patch-nse.yaml < 0)); + then for (( i = IDX_START; i < IP_ADDRS_LEN_NEW; i++ )); + do IP_ADDR=$(echo "${IP_ADDRS[i]}" | sed 's=/[0-9]\{1,2\}==g'); + echo $IP_ADDR; + iperf3 -s -D --pidfile /tmp/iperf.pid --bind ${IP_ADDR}; + sleep 5; + if [ -f /tmp/iperf.pid ]; + then echo "iperf daemon sucesfully started on ${IP_ADDR}"; + rm /tmp/iperf.pid; + fi; + done; + fi; + sleep 5; + + IP_ADDRS_LEN_OLD=${IP_ADDRS_LEN_NEW}; + done; + nodeSelector: + kubernetes.io/hostname: ${NODES[1]} +EOF + +kubectl apply -k . + +kubectl wait --for=condition=ready --timeout=1m pod -l app=nsc-kernel-1 -n ${NAMESPACE} + +kubectl wait --for=condition=ready --timeout=1m pod -l app=nse-kernel -n ${NAMESPACE} + +NSC1=$(kubectl get pods -l app=nsc-kernel-1 -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') + +NSE=$(kubectl get pods -l app=nse-kernel -n ${NAMESPACE} --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') + +kubectl exec ${NSC1} -n ${NAMESPACE} -- ping -c 4 172.16.1.100 + +kubectl exec ${NSE} -n ${NAMESPACE} -- ping -c 4 172.16.1.101 diff --git a/examples/performance-testing/namespace.yaml b/examples/performance-testing/namespace.yaml new file mode 100644 index 000000000000..7919ccab9bec --- /dev/null +++ b/examples/performance-testing/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + generateName: ns-