Connecting a Yandex BareMetal server as an external node to a Yandex Managed Service for Kubernetes cluster
Note
Connecting external nodes to a Managed Service for Kubernetes cluster is currently at the Preview stage and free of charge.
You can connect BareMetal servers to a Managed Service for Kubernetes cluster as external nodes using special Kubernetes API resources. The definitions of these resources (CustomResourceDefinitions
Required paid resources
The support cost for this solution includes:
-
Fee for the Managed Service for Kubernetes master (see Yandex Managed Service for Kubernetes pricing).
-
Fee for Managed Service for Kubernetes standard cluster nodes (if any): use of computing resources and storage (see Yandex Compute Cloud pricing).
-
VM fee: use of computing resources and storage (see Yandex Compute Cloud pricing).
Note
Your operating system fee depends on its type (see Compute Cloud pricing).
-
Fee for using a public IP address for a VM (see Yandex Virtual Private Cloud pricing).
-
BareMetal server lease fee (see Yandex BareMetal pricing).
To connect a BareMetal server as an external node to a Managed Service for Kubernetes cluster:
- Get ready for work.
- Create an external node group.
- Install system components on your BareMetal server.
- Check the external node status.
See also How to cancel a lease and delete resources.
Getting started
-
Create a service account with the k8s.clusters.agent, vpc.publicAdmin, and k8s.tunnelClusters.agent roles for the folder you are creating the Managed Service for Kubernetes cluster in.
-
Create a Managed Service for Kubernetes cluster of any suitable configuration, operating in tunnel mode. When doing so, specify the service account you created earlier.
Warning
Tunnel mode can only be activated at the step of creating a cluster.
-
Install kubect
and configure it to work with the new cluster. -
Lease a BareMetal server with an
Ubuntu 24.04OS image and internet access.You can also use BareMetal servers with other operating systems.
Creating an external 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 private IP address of the BareMetal server you are connecting.
- Click Add.
Installing system components on a BareMetal server
To connect servers to a Managed Service for Kubernetes cluster, you need to install their system components.
You can install system components in any of the following ways:
Automated installation
With automated installation, the Managed Service for Kubernetes cluster connects to the BareMetal 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 BareMetal server:
kubectl -n yandex-system create secret generic <secret_name> \ --from-file=ssh-privatekey=<SSH_key_file_path> \ --type=kubernetes.io/ssh-authWarning
If you have lost the private SSH key specified when leasing the server, you can add a new public SSH key to the server's root user account.
-
Specify the name of the secret in the node group specification:
Management console- 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.
Semi-automated installation
With semi-automated installation, you prepare the BareMetal 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 BareMetal 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 BareMetal server:scp kube.config root@<baremetal_server_public_IP>:/ -
Connect to the BareMetal 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 following commands on the BareMetal 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 check
Once the system components are installed, the BareMetal server will initiate the Managed Service for Kubernetes cluster connection.
To make sure the BareMetal server is successfully connected:
- 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.
How to cancel a lease and delete resources
Some resources are not free of charge. Delete the resources you no longer need to avoid paying for them:
- Delete the Managed Service for Kubernetes cluster.
- Delete the service accounts you created.
- Delete the VM.
- Cancel your BareMetal server lease renewal. After canceling the lease, the server will remain active until the paid period ends, after which it will be automatically deleted.
- Delete the private connection.