Connecting external nodes to a cluster
Note
Connecting external nodes to a Managed Service for Kubernetes cluster is at the Preview stage. You will not be charged for using them.
You can connect external servers as nodes to a Managed Service for Kubernetes cluster using special Kubernetes API resources. The definitions (CustomResourceDefinitions
Warning
For external nodes to connect to a Managed Service for Kubernetes cluster, both the cluster and the connecting servers must meet certain requirements.
Getting started
-
Create a Managed Service for Kubernetes cluster with any suitable configuration.
To create an external node group, the Managed Service for Kubernetes cluster must operate in tunnel mode. You can only enable this mode when creating the cluster.
-
Install kubect
and configure it to work with the new cluster.
Creating a node group
- On the Managed Service for Kubernetes cluster page, go to the Node manager tab.
- Click Create a node group and then External.
- Enter a name for the Managed Service for Kubernetes node group.
- In the Node IP addresses field, specify the IP address of the server you are connecting, available from the Managed Service for Kubernetes cluster's cloud network.
- Click Add IP address to add more IP addresses as needed.
- Click Add.
-
Save the specification of the
NodeGrouptype object for the Managed Service for Kubernetes group from themks.yandex.cloud/v1alpha1API in theyandex-systemnamespace to a YAML file namedext-nodegroup.yaml:apiVersion: mks.yandex.cloud/v1alpha1 kind: NodeGroup metadata: name: external-node-group namespace: yandex-system spec: ips: # List the IP addresses of the connecting servers accessible from the Managed Service for Kubernetes cluster's cloud network. - 10.130.0.4 - 10.130.1.5 -
Create a Managed Service for Kubernetes node group:
kubectl apply -f ext-nodegroup.yaml
Updating a node group
If required, you can edit the node group, e.g., add more IP addresses.
- On the Managed Service for Kubernetes cluster page, go to the Node manager tab.
- Select the Managed Service for Kubernetes node group.
- In the top-right corner, click Edit.
- Edit the group as needed and click Save.
To edit a Managed Service for Kubernetes node group specification, run this command:
kubectl -n yandex-system edit nodegroup external-node-group
Installing system components
To connect servers to a Managed Service for Kubernetes cluster, you need to install their system components.
You can install system components using one of the following methods:
Automated installation
With automated installation, the Managed Service for Kubernetes cluster connects to the server over SSH and installs all required system components all by itself.
To run an automated installation:
-
In your Managed Service for Kubernetes cluster, create a secret with a private SSH key for connection to the server:
kubectl -n yandex-system create secret generic <secret_name> \ --from-file=ssh-privatekey=<SSH_key_file_path> \ --type=kubernetes.io/ssh-auth -
Specify the name of the secret in the node group specification:
Management consoleCLI- On the Managed Service for Kubernetes cluster page, go to the Node manager tab.
- Select the new Managed Service for Kubernetes node group from the list.
- In the top-right corner, click Edit.
- In the Secret with private SSH key field, select the new secret from the drop-down list.
- Click Save.
-
Run this command:
kubectl -n yandex-system edit nodegroup external-node-group -
Edit the specification:
apiVersion: mks.yandex.cloud/v1alpha1 kind: NodeGroup metadata: name: external-node-group namespace: yandex-system spec: ips: ... provisionBySsh: sshKeySecret: name: <secret_name> namespace: yandex-system
Semi-automated installation
With semi-automated installation, you prepare the server manually by installing the maintainer component and setting up access for the Managed Service for Kubernetes cluster. With that done, the maintainer component will automatically download and install the remaining system components.
To run a semi-automated installation:
-
Use
kubectlto get a secret containingkubeconfigfor the server you are connecting and save it to a file:kubectl -n yandex-system get secret <node_group_name>-maintainer-kube-config \ -o json | jq -r '.data."kube-config"' | base64 -d > kube.configThis secret becomes available after the node group is created in the Managed Service for Kubernetes cluster.
-
Move the
kube.configfile to the server:scp kube.config root@<server_public_IP_address>:/ -
Connect to the server:
ssh root@<server_public_IP_address> -
Create a folder named
/etc/yandex-maintainerand move thekube.configfile into it:sudo mkdir -p /etc/yandex-maintainer sudo mv /kube.config /etc/yandex-maintainer/ -
Run the commands below on a connecting server:
sudo mkdir -p /home/kubernetes/bin sudo curl --output /home/kubernetes/bin/maintainer https://storage.yandexcloud.net/mk8s-maintainer/v1/maintainer sudo chmod +x /home/kubernetes/bin/maintainer sudo /home/kubernetes/bin/maintainer install
External node status checks
Once the system components have been installed, the servers will initiate Managed Service for Kubernetes cluster connections. Once the connection is complete, the new cluster nodes will get the Ready status.
To check the node status:
- On the Managed Service for Kubernetes cluster page, go to the Node manager tab.
- Click the name of the new Managed Service for Kubernetes node group.
- Navigate to the Nodes tab.
- Check that the new Managed Service for Kubernetes node is now
Ready. - Open the new node and go to the Events tab.
- Check that all server connection steps have been successful.
Run this command:
kubectl get node -o wide -w
Result:
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
...
ext-node2 Ready <none> 4m03s v1.20.6 10.130.0.4 <none> Ubuntu 20.04.3 LTS 5.4.0-42-generic docker://20.10.8
ext-node1 Ready <none> 4m25s v1.20.6 10.130.1.5 <none> Ubuntu 20.04.3 LTS 5.4.0-42-generic docker://20.10.8
Disabling external nodes
- On the Managed Service for Kubernetes cluster page, go to the Node manager tab.
- Select the new Managed Service for Kubernetes node group from the list.
- In the top-right corner, click Edit.
- Delete the IP addresses of the Managed Service for Kubernetes nodes you created.
- Click Save.
-
Run this command:
kubectl -n yandex-system edit nodegroup -
Delete the IP addresses of the nodes from the
spec.ipsfield.
Troubleshooting
If there are any issues, review the events in the yandex-system namespace first:
- On the Managed Service for Kubernetes cluster page, go to the Events tab.
- Select the
yandex-systemnamespace.
To get a list of events, run this command:
kubectl -n yandex-system get events
If there is not enough information, review the system component logs on the relevant server:
journalctl -u yandex-maintainer
journalctl -u kubelet
Consider the external Managed Service for Kubernetes node connection requirements.