Getting started with Managed Service for Kubernetes
Create a Managed Service for Kubernetes cluster and node group and manage them using kubectl, the Kubernetes command line interface.
Getting started
To get started with Managed Service for Kubernetes:
-
Navigate to the management console
and log in to Yandex Cloud or sign up if not signed up yet. -
On the Yandex Cloud Billing
page, make sure you have a billing account linked and its status isACTIVEorTRIAL_ACTIVE. If you do not have a billing account yet, create one. -
If you do not have a folder yet, create one.
-
Install kubectl
, the Kubernetes CLI. -
Make sure you have enough resources available in the cloud.
-
If you do not have a network yet, create one.
-
If you do not have any subnets yet, create them in the availability zones where your Managed Service for Kubernetes cluster and node group will reside.
-
Create these service accounts:
- Service account with the
k8s.clusters.agentandvpc.publicAdminroles for the folder where you want to create a Managed Service for Kubernetes cluster. This service account will be used to create the resources for the Managed Service for Kubernetes cluster. - Service account with the container-registry.images.puller role for the folder containing the Docker image registry. Managed Service for Kubernetes nodes will pull the required Docker images from the registry on behalf of this account.
You can use the same service account for both operations.
Note
To create a cluster with tunnel mode, the cluster service account requires the
k8s.tunnelClusters.agentrole. - Service account with the
-
Configure security groups for network traffic of your Managed Service for Kubernetes cluster.
Create a Managed Service for Kubernetes cluster
- In the management console
, select the folder where you want to create a Managed Service for Kubernetes cluster. - Select Managed Service for Kubernetes.
- Click Create cluster.
- Enter the Managed Service for Kubernetes cluster name. It must be unique within the folder.
- Optionally, enter a description for the Managed Service for Kubernetes cluster.
- Service account for resources: Specify the service account with the
k8s.clusters.agentandvpc.publicAdminroles to use for creating resources. - Service account for nodes: Specify the service account with the container-registry.images.puller role that Managed Service for Kubernetes nodes will use to access the Docker image registry.
- Specify the release channel. You will not be able to edit this setting once you create the Managed Service for Kubernetes cluster.
- Under Master configuration:
- Kubernetes version: Select the Kubernetes version to install on the Managed Service for Kubernetes master.
- Public address: Select the IP address assignment method:
Auto: Assign a random IP address from the Yandex Cloud IP address pool.No address: Do not assign a public IP address.
- Type of master: Select the master type:
Basic: To create a single master host in the selected availability zone. Specify the cloud network and select the subnet for the master host.Highly available: To create a single master host in each availability zone. Specify the cloud network and subnet for each availability zone.
- Select security groups for the Managed Service for Kubernetes cluster's network traffic.
- Under Cluster network settings:
- Click Create.
For more information, see this step-by-step guide for creating a Managed Service for Kubernetes cluster.
Create a node group
To create a Managed Service for Kubernetes node group:
-
In the management console
, select the folder where you created the required Managed Service for Kubernetes cluster. -
In the list of services, select Managed Service for Kubernetes.
-
Select the Managed Service for Kubernetes cluster to create a node group for.
-
On the Managed Service for Kubernetes cluster page, go to the
Node manager tab. -
Click Create a node group.
-
Enter a name and description for the Managed Service for Kubernetes node group.
-
In the Kubernetes version field, select the Kubernetes version for the Managed Service for Kubernetes nodes.
-
Under Scaling, select its type:
Fixed, to keep a fixed number of nodes in the Managed Service for Kubernetes group. Specify this number.Automatic, to manage the number of nodes in the Managed Service for Kubernetes group using Managed Service for Kubernetes cluster autoscaling.
-
Under Changes during creation and updates, specify the maximum number of VMs by which you can exceed or reduce the Managed Service for Kubernetes group size.
-
Under Computing resources:
- Select a platform.
- Specify the required number of vCPUs, guaranteed vCPU performance, and the amount of RAM.
- Optionally, make the VM instance preemptible by checking the relevant box.
- Optionally, enable a software-accelerated network.
-
Under Storage:
-
Specify the Disk type for the Managed Service for Kubernetes group nodes:
HDD: Standard network drive; HDD network block storage.SSD: Fast network drive; SSD network block storage.Non-replicated SSD: Network drive with enhanced performance achieved by eliminating redundancy. You can only change the size of this disk type in 93 GB increments.SSD IO: Network drive with the same performance specifications asNon-replicated SSD, plus redundancy. You can only change the size of this disk type in 93 GB increments.
For more information about disk types, see this Yandex Compute Cloud guide.
-
Specify the disk size for the Managed Service for Kubernetes group nodes.
-
-
Under Network settings:
- In the Public address field, select an IP address assignment method:
Auto: Assign a random IP address from the Yandex Cloud IP address pool.No address: Do not assign a public IP address.
- Select security groups.
- Select the availability zone and subnet to place the Managed Service for Kubernetes group nodes in.
- In the Public address field, select an IP address assignment method:
-
Under Access, specify the access credentials for the Managed Service for Kubernetes group nodes over SSH:
- Login: Enter the username.
- SSH key: Paste the contents of the public key file.
-
Click Create.
For more information, see this step-by-step guide for creating Managed Service for Kubernetes node groups.
Add credentials to the kubectl configuration file
With kubectl, you can manage a Managed Service for Kubernetes cluster. To configure the utility to work with the created cluster, add its credentials to the kubectl configuration file:
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
Run this command:
yc managed-kubernetes cluster get-credentials test-k8s-cluster --externalTip
You can also view the connection command in the management console
on the cluster page under Access.- By default, credentials are added to the
$HOME/.kube/configdirectory. - If you need to change the configuration location, use the
--kubeconfig <file_path>parameter.
- By default, credentials are added to the
-
Check the
kubectlconfiguration after adding the credentials:kubectl config viewResult:
apiVersion: v1 clusters: - cluster: certificate-authority-data: DATA+OMITTED ... -
Check the connection to the cluster:
kubectl get nodesThe command will return information about the node group you created:
NAME STATUS ROLES AGE VERSION cl17i6943n92********-itif Ready <none> 31m v1.13.3To learn more about connecting to a Managed Service for Kubernetes cluster, see Overview of connection methods.
What's next
- Read about service concepts.
- Learn how to work with a Managed Service for Kubernetes cluster and node groups.
- Check questions and answers.
- Check the recommendations on using Kubernetes.