Skip to main content
Version: v1.1

Join Nodes

There are two ways to join nodes into OpenYurt cluster in terms of the node status.

1. Joining nodes from scratch

1.1 yurtadm join

Users can join cloud nodes and edge nodes to the OpenYurt cluster using Yurtadm join. Note that when joining a node, the runtime needs to be installed on the node and the swap partition is turned off.

Execute the following command to join the edge node to cluster:

$ _output/local/bin/linux/amd64/yurtadm join --token=zffaj3.a5vjzf09qn9ft3gt --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5

Execute the following command to join the cloud node to cluster:

$ _output/local/bin/linux/amd64/yurtadm join --token=zffaj3.a5vjzf09qn9ft3gt --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5

When the runtime of the edge node is containerd, the cri-socket parameter needs to be configured. For example, change the command above of joining the edge node to:

$ _output/local/bin/linux/amd64/yurtadm join --token=zffaj3.a5vjzf09qn9ft3gt --node-type=edge --discovery-token-unsafe-skip-ca-verification --cri-socket=/run/containerd/containerd.sock --v=5
  • how to compile yurtadm binary, please refer to the link here

Explanation of parameters:

  • The address of apiserver
  • --token:bootstrap token
  • --node-type:openyurt node type,can be cloud or edge

The process of yurtadm join` will automatically install the following k8s components:

  • kubeadm
  • kubectl
  • kubelet
  • kube-proxy

1.2 yurtadm reset

yurtadm reset can be used when it is necessary to delete a node that was joined using yurtadm join. Here are the detailed steps:

In master:

kubectl drain {NodeName} --delete-local-data --force --ignore-daemonsets
kubectl delete node {NodeName}

In joined node:

1. execute yurtadm reset

yurtadm reset

2. delete /etc/cni/net.d dir:

rm -rf /etc/cni/net.d

2. Install OpenYurt node components

You should only install node components of OpenYurt on nodes that already have been joined in the Kubernetes cluster.

2.1 Label your node

OpenYurt distinguish cloud nodes and edge nodes through the node label From this, it makes the decision that whether to evict Pods on this node. Assume we have a node named us-west- which is an edge node.

$ kubectl label node us-west-
node/us-west- labeled

If us-west- is a cloud node, then you should change the label from true to false

To further activate the node autonomous mode, we add an annotation to this edge node:

$ kubectl annotate node us-west-
node/us-west- annotated

Also if you want to take advantage of the unitization ability of OpenYurt, you can add this node to an nodePool.

$ cat <<EOF | kubectl apply -f -
kind: NodePool
  name: worker
  type: Edge
$ kubectl label node us-west-

2.2 Setup Yurthub

Before proceeding, we need to prepare the following items:

  1. Get the apiserver's address (i.e., ip:port) and a bootstrap token, which will be used to replace the placeholder in the template file config/setup/yurthub.yaml.

In the following command, we assume that the address of the apiserver is and bootstrap token is 07401b.f395accd246ae52d

$ cat config/setup/yurthub.yaml |
sed 's|__kubernetes_master_address__||;
s|__bootstrap_token__|07401b.f395accd246ae52d|' > /tmp/yurthub-ack.yaml &&
scp -i <yourt-ssh-identity-file> /tmp/yurthub-ack.yaml root@us-west-

and the Yurthub will be ready in minutes.

2.3 Configure Kubelet

we need to reset the kubelet service to let it access the apiserver through the yurthub (The following steps assume that we have logged on to the edge node as the root user). As kubelet will connect to the Yurthub through HTTP, so we create a new kubeconfig file for the kubelet service.

mkdir -p /var/lib/openyurt
cat << EOF > /var/lib/openyurt/kubelet.conf
apiVersion: v1
- cluster:
  name: default-cluster
- context:
    cluster: default-cluster
    namespace: default
    user: default-auth
  name: default-context
current-context: default-context
kind: Config
preferences: {}

In order for let kubelet to use the new kubeconfig, we edit the drop-in file of the kubelet service (i.e., /etc/systemd/system/kubelet.service.d/10-kubeadm.conf or /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf for CentOS)

sed -i "s|KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=\/etc\/kubernetes\/bootstrap-kubelet.conf\ --kubeconfig=\/etc\/kubernetes\/kubelet.conf|KUBELET_KUBECONFIG_ARGS=--kubeconfig=\/var\/lib\/openyurt\/kubelet.conf|g" \

then, we restart the kubelet service

# assume we are logged in to the edge node already
$ systemctl daemon-reload && systemctl restart kubelet

Finally, we need to make sure node is ready after kubelet restart.

$ kubectl get nodes
NAME                     STATUS   ROLES    AGE     VERSION
us-west-   Ready    <none>   3d23h   v1.20.11
us-west-   Ready    <none>   3d23h   v1.20.11

2.4 Restart Pods

After Yurthub installation and kubelet restart, all pods on this edge node should be recreated in order to make sure pods access kube-apiserver through Yurthub. Before performing this operation, confirm the impact on the production environment.

$ kubectl get pod -A -o wide | grep us-west-
kube-system   yurt-hub-us-west-           1/1     Running   0          19d    us-west-   <none>           <none>
kube-system   coredns-qq6dk                             1/1     Running   0          19d   us-west-   <none>           <none>
kube-system   kube-flannel-ds-j698r                     1/1     Running   0          19d    us-west-   <none>           <none>
kube-system   kube-proxy-f5qvr                          1/1     Running   0          19d    us-west-   <none>           <none>

// then delete all pods above except yurthub pod.
$ kubectl -n kube-system delete pod coredns-qq6dk kube-flannel-ds-j698r kube-proxy-f5qvr