Adding NeuReality AI Inference Modules to Kubernetes clusters

You can join NR1™ AI Inference Modules as nodes to a Kubernetes cluster. Once you join them to a cluster, you can orchestrate CG pods on NR1™ AI Inference Modules in the same way regular pods are orchestrated on general-purpose Kubernetes nodes.

Joining a node

To join a NR1™ AI Inference Module to a Kubernetes cluster, perform the following steps:

  1. Log in to a control plane node.

  2. Perform the following kubeadm token command:

    $ kubeadm token create --print-join-command
    kubeadm join <ip>:<port> --token <token> --discovery-token-ca-cert-hash <hash value>
    

    Write down the values of ip, port, token, hash value from the output above.

  3. Create a JoinConfiguration YAML. See a template below:

    k8s_join_config.yaml
     1apiVersion: kubeadm.k8s.io/v1beta3
     2kind: JoinConfiguration
     3discovery:
     4  bootstrapToken:
     5    apiServerEndpoint: <ip>:<port>
     6    caCertHashes:
     7    - <hash value>
     8    token: <token>
     9nodeRegistration:
    10  taints:
    11  - key: "neureality-server"
    12    value: "true"
    13    effect: "NoExecute"
    14  kubeletExtraArgs:
    15    node-ip: <node IP>
    16    node-labels: neureality.ai/arch=nr1
    

    Fill the values of ip, port, token, hash value in the template above. Fill the Ethernet IP of the NR1™ AI Inference Module as the node ip in the template.

    Important points to note about the YAML above
    • taint neureality-server. It is required to prevent general-purpose pods from being scheduled to the NR1™ node.

    • node-labels contains the neureality.ai/arch=nr1 label. It is required for CG pods to be able to specify this label as node selector in order to be scheduled on the node.

  4. Use NeuReality Management API to join the NR1™ AI Inference Module to the cluster using the values you copied:

    $ curl <the Ethernet IP of the NeuReality Module>:5200/v1/k8s/join -X POST --data-binary @<your Join configuration YAML location>
    {
        "requestMethod": "POST",
        "requestURI": "/v1/k8s/join",
        "result": {
            "restStatus": "done"
    	}
    }
    
  5. Check your nodes:

    $ kubectl get nodes
    NAME                       STATUS     ROLES           AGE    VERSION 
    aspen-nr1s3-1              Ready      <none>          1m     v1.27.5-dirty
    demo2-k8s-clients-node-1   Ready      <none>          128d   v1.27.2
    demo2-k8s-master-1         Ready      control-plane   128d   v1.27.2
    demo2-k8s-worker-1         Ready      <none>          128d   v1.27.2
    

    Notice the newly joined node in the list of the cluster nodes.

Removing a node

To remove a NR1™ AI Inference Module from a Kubernetes cluster, perform the following steps:

  1. Drain the node:

    $ kubectl drain aspen-nr1s3-1
    

    The command above will evict all the CG pods from the node and will prevent scheduling new CG pods on it.

  2. Use NeuReality Management API to remove the NR1™ AI Inference Module from the cluster:

    $ curl <the Ethernet IP of the NeuReality Module>:5200/v1/k8s/leave -X POST
    {
        "requestMethod": "POST",
        "requestURI": "/v1/k8s/leave",
        "result": {
            "restStatus": "done"
    	}
    }
    
  3. Check that the node became NotReady:

    $ kubectl get node aspen-nr1s3-1
    NAME                       STATUS        ROLES           AGE    VERSION   
    aspen-nr1s3-1              NotReady      <none>          1m     v1.27.5-dirty
    
  4. Delete the node. This operation is required in order to let Kubernetes control plane remove the node from its data structures.

    $ kubectl delete node aspen-nr1s3-1