Skip to content

Latest commit

 

History

History
454 lines (334 loc) · 10.3 KB

File metadata and controls

454 lines (334 loc) · 10.3 KB
title description
iPerf3
Running basic connectivity between iPerf3 applications across two sites using ClusterLink.

In this tutorial we establish iPerf3 connectivity between two kind cluster using ClusterLink. The tutorial uses two kind clusters:

  1. Client cluster - runs ClusterLink along with an iPerf3 client.
  2. Server cluster - runs ClusterLink along with an iPerf3 server.

Install ClusterLink CLI

  1. Install ClusterLink on Linux or Mac using the installation script:

    curl -L https://github.com/clusterlink-net/clusterlink/releases/latest/download/clusterlink.sh | sh -
  2. Verify the installation:

    clusterlink --version

Initialize clusters

Before you start, you must have access to two K8s clusters. For example, in this tutorial we set up a local environment using the kind project. To setup two kind clusters:

  1. Install kind using kind installation guide.

  2. Create a directory for all the tutorial files:

    mkdir iperf3-tutorial
  3. Open two terminals in the tutorial directory and create a kind cluster in each terminal:

    Client cluster:

    cd iperf3-tutorial
    kind create cluster --name=client

    Server cluster:

    cd iperf3-tutorial
    kind create cluster --name=server

{{< notice note >}} kind uses the prefix "kind", so the name of created clusters will be kind-client and kind-server. {{< /notice >}}

  1. Setup KUBECONFIG on each terminal to access the cluster:

    Client cluster:

    kubectl config use-context kind-client
    cp ~/.kube/config $PWD/config-client
    export KUBECONFIG=$PWD/config-client

    Server cluster:

    kubectl config use-context kind-server
    cp ~/.kube/config $PWD/config-server
    export KUBECONFIG=$PWD/config-server

{{< notice note >}} You can run the tutorial in a single terminal and switch access between the clusters using kubectl config use-context kind-client and kubectl config use-context kind-server. {{< /notice >}}

Deploy iPerf3 client and server

Install iPerf3 (client and server) on the clusters:

Client cluster:

export IPERF3_FILES=https://raw.githubusercontent.com/clusterlink-net/clusterlink/main/demos/iperf3/testdata/manifests
kubectl apply -f $IPERF3_FILES/iperf3-client/iperf3-client.yaml

Server cluster:

export IPERF3_FILES=https://raw.githubusercontent.com/clusterlink-net/clusterlink/main/demos/iperf3/testdata/manifests
kubectl apply -f $IPERF3_FILES/iperf3-server/iperf3.yaml

Deploy ClusterLink

  1. Create the fabric and peer certificates for the clusters:

    Client cluster:

    clusterlink create fabric
    clusterlink create peer-cert --name client

    Server cluster:

    clusterlink create peer-cert --name server

    For more details about fabric and peer concepts see core concepts.

  2. Deploy ClusterLink on each cluster:

    Client cluster:

    clusterlink deploy peer --name client --autostart --ingress=NodePort --ingress-port=30443

    Server cluster:

    clusterlink deploy peer --name server --autostart --ingress=NodePort --ingress-port=30443

{{< notice note >}} In this example, we use NodePort to create an external access point for the kind clusters. By default deploy peer creates an ingress of type LoadBalancer, which is more suitable for Kubernetes clusters running in the cloud. {{< /notice >}}

  1. Verify that ClusterLink controlplane and dataplane are running:

    Client cluster:

    kubectl rollout status deployment cl-controlplane -n clusterlink-system
    kubectl rollout status deployment cl-dataplane -n clusterlink-system

    Server cluster:

    kubectl rollout status deployment cl-controlplane -n clusterlink-system
    kubectl rollout status deployment cl-dataplane -n clusterlink-system

{{% expand summary="Output" %}} It may take a few seconds for the deployments to be successfully created.

deployment "cl-controlplane" successfully rolled out
deployment "cl-dataplane" successfully rolled out

{{% /expand %}}

Enable cross-cluster access

In this step, we enable connectivity access between the iPerf3 client and server. For each step, you have an example demonstrating how to apply the command from a file or providing the complete custom resource (CR) associated with the command.

Peers setup

Add the remote peer to each cluster:

Client cluster:

{{< tabpane text=true >}} {{% tab header="File" %}}

export SERVER_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' server-control-plane`
curl -s $IPERF3_FILES/clusterlink/peer-server.yaml | envsubst | kubectl apply -f -

{{% /tab %}} {{% tab header="Full CR" %}}

export SERVER_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' server-control-plane`
echo "
apiVersion: clusterlink.net/v1alpha1
kind: Peer
metadata:
  name: server
  namespace: clusterlink-system
spec:
  gateways:
    - host: "${SERVER_IP}"
      port: 30443
" | kubectl apply -f -

{{% /tab %}} {{< /tabpane >}}

Server cluster:

{{< tabpane text=true >}} {{% tab header="File" %}}

export CLIENT_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' client-control-plane`
curl -s $IPERF3_FILES/clusterlink/peer-client.yaml | envsubst | kubectl apply -f -

{{% /tab %}} {{% tab header="Full CR" %}}

export CLIENT_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' client-control-plane`
echo "
apiVersion: clusterlink.net/v1alpha1
kind: Peer
metadata:
  name: client
  namespace: clusterlink-system
spec:
  gateways:
    - host: "${CLIENT_IP}"
      port: 30443
" | kubectl apply -f -

{{% /tab %}} {{< /tabpane >}}

{{% expand summary="Install envsubst for macOS users" %}} In case envsubst does not exist, you can install it with:

brew install gettext
brew link --force gettext

{{% /expand %}}
{{< notice note >}}

The CLIENT_IP and SERVER_IP refers to the node IP of the peer kind cluster, which assigns the peer YAML file. {{< /notice >}}

Export iPerf server endpoint

In the server cluster, export the iperf3-server service:

Server cluster:

{{< tabpane text=true >}} {{% tab header="File" %}}

kubectl apply -f $IPERF3_FILES/clusterlink/export-iperf3.yaml

{{% /tab %}} {{% tab header="Full CR" %}}

echo "
apiVersion: clusterlink.net/v1alpha1
kind: Export
metadata:
  name: iperf3-server
  namespace: default
spec:
  port:  5000
" | kubectl apply -f -

{{% /tab %}} {{< /tabpane >}}

Import setup

In the client cluster, import the iperf3-server service from the server cluster:

Client cluster:

{{< tabpane text=true >}} {{% tab header="File" %}}

kubectl apply -f $IPERF3_FILES/clusterlink/import-iperf3.yaml

{{% /tab %}} {{% tab header="Full CR" %}}

echo "
apiVersion: clusterlink.net/v1alpha1
kind: Import
metadata:
  name: iperf3-server
  namespace: default
spec:
  port:       5000
  sources:
    - exportName:       iperf3-server
      exportNamespace:  default
      peer:             server
" | kubectl apply -f -

{{% /tab %}} {{< /tabpane >}}

Policies setup

Create access policies on both clusters to allow connectivity:

Client cluster:

{{< tabpane text=true >}} {{% tab header="File" %}}

kubectl apply -f $IPERF3_FILES/clusterlink/allow-policy.yaml

{{% /tab %}} {{% tab header="Full CR" %}}

echo "
apiVersion: clusterlink.net/v1alpha1
kind: AccessPolicy
metadata:
  name: allow-policy
  namespace: default
spec:
  action: allow
  from:
    - workloadSelector: {}
  to:
    - workloadSelector: {}
" | kubectl apply -f -

{{% /tab %}} {{< /tabpane >}}

Server cluster:

{{< tabpane text=true >}} {{% tab header="File" %}}

kubectl apply -f $IPERF3_FILES/clusterlink/allow-policy.yaml

{{% /tab %}} {{% tab header="Full CR" %}}

echo "
apiVersion: clusterlink.net/v1alpha1
kind: AccessPolicy
metadata:
  name: allow-policy
  namespace: default
spec:
  action: allow
  from:
    - workloadSelector: {}
  to:
    - workloadSelector: {}
" | kubectl apply -f -

{{% /tab %}} {{< /tabpane >}}

For more details regarding policy configuration, see here.

Test service connectivity

Test the iperf3 connectivity between the clusters:

Client cluster:

export IPERF3CLIENT=`kubectl get pods -l app=iperf3-client -o custom-columns=:metadata.name --no-headers`
kubectl exec -i $IPERF3CLIENT -- iperf3 -c iperf3-server --port 5000

{{% expand summary="Output" %}}

Connecting to host iperf3-server, port 5000
[  5] local 10.244.0.5 port 51666 connected to 10.96.46.198 port 5000
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   639 MBytes  5.36 Gbits/sec    0    938 KBytes
[  5]   1.00-2.00   sec   627 MBytes  5.26 Gbits/sec    0    938 KBytes
[  5]   2.00-3.00   sec   628 MBytes  5.26 Gbits/sec    0    938 KBytes
[  5]   3.00-4.00   sec   635 MBytes  5.33 Gbits/sec    0    938 KBytes
[  5]   4.00-5.00   sec   630 MBytes  5.29 Gbits/sec    0    938 KBytes
[  5]   5.00-6.00   sec   636 MBytes  5.33 Gbits/sec    0    938 KBytes
[  5]   6.00-7.00   sec   639 MBytes  5.36 Gbits/sec    0    938 KBytes
[  5]   7.00-8.00   sec   634 MBytes  5.32 Gbits/sec    0    938 KBytes
[  5]   8.00-9.00   sec   641 MBytes  5.39 Gbits/sec    0    938 KBytes
[  5]   9.00-10.00  sec   633 MBytes  5.30 Gbits/sec    0    938 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  6.19 GBytes  5.32 Gbits/sec    0             sender
[  5]   0.00-10.00  sec  6.18 GBytes  5.31 Gbits/sec                  receiver

iperf Done.

{{% /expand %}}

Cleanup

  1. Delete all kind clusters: Client cluster:

    kind delete cluster --name=client

    Server cluster:

    kind delete cluster --name=server
  2. Remove tutorial directory:

    cd .. && rm -rf iperf3-tutorial
  3. Unset environment variables: Client cluster:

    unset KUBECONFIG IPERF3_FILES IPERF3CLIENT

    Server cluster:

    unset KUBECONFIG IPERF3_FILES