Getting started
Create a cluster Kubernetes and node group and manage them using kubectl, the Kubernetes command-line interface.
Before you start
To start working with Managed Service for Kubernetes:
-
Go to the management console. Then log in to Yandex.Cloud or sign up if you don't have an account yet.
-
On the billing page, make sure that a billing account is linked and that its status is
ACTIVE
orTRIAL_ACTIVE
. If you don't have a billing account, create one. -
If you don't have a folder, create one.
-
Install the Kubernetes CLI (kubectl).
-
Make sure you have enough resources available in the cloud.
-
If you don't have a network, create one.
-
If you don't have any subnets, create them in the availability zones where your Kubernetes cluster and node group will be created.
-
Create service accounts:
- A service account for resources with the editor role for the folder where the Kubernetes cluster will be created. The resources that the Kubernetes cluster needs will be created on behalf of this account.
- A service account for nodes with the container-registry.images.puller role for the folder with the Docker image registry. Nodes will download the Docker images they require from the registry on behalf of this account.
You can use the same service account for both operations.
Create a cluster Kubernetes
- In management console, select the folder where you want to create your Kubernetes cluster.
- In the list of services, select Managed Service for Kubernetes.
- Click Create cluster.
- Enter a name and description for the Kubernetes cluster.
- Specify a service account for the resources. This is used to create the resources.
- Specify a service account for nodes. The nodes use this service account to access the Docker image registry.
- Specify a release channel.
- Under Master configuration:
-
In the Kubernetes version field, select the Kubernetes version to be installed on the master.
-
In the Public IP field, choose a method for assigning an IP address:
- Auto: Assign a random IP address from the Yandex.Cloud IP pool.
- No address: Don't assign a public IP address.
-
In the Master type field, select the type of master:
- Zonal: A master created in a subnet in one availability zone.
- Regional: A master created and distributed in three subnets in each availability zone.
-
Select the availability zone where you want to create the master node address.
This step is only available for the zonal master.
-
In the Network format field, choose how networks are displayed:
- List: Available networks are displayed as a list. If you don't have a cloud network, click Create network:
- In the window that opens, enter a name for the network. Specify that subnets should be created. Click Create network. By default, networks are created with subnets in each availability zone.
- ID: Enter the unique ID of the required networks.
- List: Available networks are displayed as a list. If you don't have a cloud network, click Create network:
-
In the Cloud network field, select the network to create the master in.
-
In the Subnet field, select the subnet to create the master in.
For the regional master, specify three subnets in each availability zone.
-
- Under Maintenance window settings:
- In the Maintenance frequency / Disable field, configure the maintenance window:
- Disabled: Automatic updates are disabled.
- Anytime: Maintenance is allowed at any time.
- Daily: Maintenance is performed in the time interval specified in the Time (UTC) and duration field.
- On selected days: Maintenance is performed in the time interval specified in the Weekly schedule field.
- In the Maintenance frequency / Disable field, configure the maintenance window:
- Under Cluster network settings:
- Specify the cluster CIDR, which is a range of IP addresses for allocating pod addresses.
- Specify the service CIDR, which is a range of IP addresses for allocating service addresses.
- Click Create cluster.
Add credentials to the kubectl configuration file
If you don't have the Yandex.Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To add Kubernetes cluster credentials to the kubectl configuration file:
-
Run the command:
$ yc managed-kubernetes cluster get-credentials test-k8s-cluster --external
- By default, credentials are added to the
$HOME/.kube/config
directory. - If you need to change the configuration location, use the
--kubeconfig <file path>
flag.
- By default, credentials are added to the
-
Check the kubectl configuration after adding the credentials:
$ kubectl config view apiVersion: v1 clusters: - cluster: certificate-authority-data: DATA+OMITTED ...
Create a node group
To create a node group:
- In management console, select the folder where you want to create your Kubernetes cluster.
- In the list of services, select Managed Service for Kubernetes.
- Select the Kubernetes cluster to create a node group for.
- On the Kubernetes cluster page, go to the Node groups tab.
- Click Create node group.
- Enter a name and description for the node group.
- Specify the Kubernetes version for the nodes.
- Specify the number of nodes in the node group.
- Under Scalability:
- Select the scaling policy type.
- Specify the number of nodes in the node group.
- Under Allow when creating and updating, specify the maximum number of instances that you can exceed and reduce the size of the group by.
- Under Computing resources:
- Choose a platform.
- Specify the required number of vCPUs, guaranteed vCPU performance, and RAM.
- (optional) Specify that the VM must be preemptible.
- Under Storage:
- Specify the Disk type:
- HDD: Standard network drive. Network block storage on an HDD.
- SSD: Fast network drive. Network block storage on an SSD.
- Specify the disk size.
- Specify the Disk type:
- Under Network settings:
- In the Public IP field, choose a method for assigning an IP address:
- Auto: Assign a random IP address from the Yandex.Cloud IP pool.
- No address: Don't assign a public IP address.
- Specify how nodes should be distributed across availability zones and networks.
- (optional) Click Add location and specify an additional availability zone and network to create nodes in different zones.
- In the Public IP field, choose a method for assigning an IP address:
- Under Access, specify the information required to access the node:
- Enter the username in the Login field.
- In the SSH key field, paste the contents of the public key file.
- Under Maintenance window settings:
- In the Maintenance frequency / Disable field, choose the maintenance window:
- Disabled: Automatic updates are disabled.
- Anytime: Maintenance is allowed at any time.
- Daily: Maintenance is performed during the interval specified in the Time (UTC) and duration field.
- On selected days: Maintenance is performed during the interval specified in the Schedule by day field.
- In the Maintenance frequency / Disable field, choose the maintenance window:
- Click Create node group.
What's next
- Read about service concepts.
- Learn how to work with a Kubernetes cluster and node groups.