Rate This Document
Findability
Accuracy
Completeness
Readability

OVS Component Networking Operations

Prerequisites

  • The Docker and Kubernetes components (kubeadm, kubectl, and kubelet) have been installed on the node to be deployed.
  • The OVS component has been installed on the node to be deployed.
  • The node to be deployed can properly pull Docker images.

Procedure

  1. Start the OVS service on all nodes to be deployed.

    This section uses the default installation path /usr as an example. If the OVS configuration has been changed, change the commands accordingly. For details, see Open vSwitch Installation Guide.

    1
    2
    export PATH=$PATH:/usr/share/openvswitch/scripts
    ovs-ctl start
    

    Figure 1 shows the startup process. After the startup is complete, check the OVS virtual bridge version information.

    Figure 1 OVS startup process
  1. Set the Kubernetes master node during initialization.

    In this section, the 10.244.0.0/16 network segment is used as the network driver CIDR and the default gateway is used as the network broadcast address. If you need to specify another network segment, modify the command accordingly.

    1
    2
    3
    4
    kubeadm init --pod-network-cidr=10.244.0.0/16
    mkdir -p $HOME/.kube
    cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    chown $(id -u):$(id -g) $HOME/.kube/config
    

    After the initialization is complete, information in Figure 2 and Figure 3 are displayed. Check whether the pods information of the Kubernetes cluster is normal and whether the node status is NotReady. Back up the kubeadm join command in the output for future use. Then, deploy the network plane.

    Figure 2 Successful initialization of the active Kubernetes node
    Figure 3 Initialization status of the active Kubernetes node
  1. Edit the deployment YAML file of k-vswitch (OVS Kubernetes component).

    Download the k-vswitch.yaml file and edit the clusterCIDA, serviceCIDA, and overlayType fields in the file.

    The values of clusterCIDA and serviceCIDA must be the same as the IP address segments planned for the Kubernetes cluster. The value of overlayType can be set to vxlan or gre based on user requirements.

    Figure 4 Modifying the k-vswitch configuration file
  1. Deploy cluster network components.

    Use kubectl to deploy cluster network components.

    1
    kubectl apply -f k-vswitch.yaml
    

    After the deployment is complete, the coredns service is in the Running state and the node is in the Ready state, as shown in Figure 5 and Figure 6.

    Figure 5 Installing the k-vswitch component
    Figure 6 k-vswitch component deployment status
  1. Add nodes to the cluster.

    On other Kubernetes nodes to be deployed, run the kubeadm join command backed up in Step 2 to add the nodes to be deployed to the Kubernetes cluster.

    1
    2
    kubeadm join <master-ip:port> --token <your-token> \
    --discovery-token-ca-cert-hash sha256:<your-sha256-ca>
    

    After the cluster nodes are added, "This node has joined the cluster" is displayed, as shown in Figure 7. The OVS component networking procedure is complete.

    Figure 7 Adding nodes on the OVS network

Network Verification

  1. Copy the following content and edit the Nginx deployment test YAML file to test the intra-node and cross-node communication capability.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-arm-deployment
    spec:
      selector:
        matchLabels:
          app: arm64v8_nginx
      replicas: 5
      template:
        metadata:
          labels:
            app: arm64v8_nginx
        spec:
          containers:
          - name: nginx
            image: nginx:latest
            ports:
            - containerPort: 80
    
  2. Run the kubectl command to deploy the Nginx service. If information shown in Figure 8 is displayed, the Nginx service is running properly and the IP address has been allocated.
    1
    kubectl apply -f nginx.yaml
    
    Figure 8 OVS networking service deployment test
  3. Check that the node routing information and OVS bridge status are normal, as shown in Figure 9. OVS has configured the cluster-wide and node-local port information on the k-vswitch0 bridge. All service ports are mounted to the bridge in veth pair mode. Intra-node and inter-node communication can be implemented through routes and the OVS bridge.
    Figure 9 Routing and bridge information of OVS networking nodes