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:

  1. Go to the management console. Then log in to Yandex.Cloud or sign up if don't already have an account.

  2. On the billing page, make sure that a billing account is linked and that its status is ACTIVE or TRIAL_ACTIVE. If you don't have a billing account, create one.

  3. If you don't have a folder, create one.

  4. Install the Kubernetes CLI (kubectl).

  5. Make sure you have enough resources available in the cloud.

  6. If you don't have a network, create one.

  7. If you don't have any subnets, create them in the availability zones where your Kubernetes cluster and node group will be created.

  8. 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

To create a Kubernetes cluster:

  1. In the management console, select a folder to create your Kubernetes cluster in.

  2. In the list of services, select Managed Service for Kubernetes.

  3. Click Create cluster.

  4. Enter a name and description for the Kubernetes cluster. Naming requirements:

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

  5. Under Master configuration:

    • Select the availability zone to create a master in.
    • Select a service account for resources to use when creating resources.
    • Select a service account for nodes that nodes will use to access the Docker image registry.
    • 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 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.
  6. Under Cluster network settings:

    • Specify the cluster CIDR — a range of IP addresses for allocating pod addresses.
    • Specify the service CIDR — a range of IP addresses for allocating service addresses.
  7. Click Create cluster.

Add credentials to the kubectl configuration file

If you don't have the Yandex.Cloud command line interface yet, install 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:

  1. 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.
  2. 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:

  1. In the management console, select a folder to create your Kubernetes node group in.

  2. In the list of services, select Managed Service for Kubernetes.

  3. Select the Kubernetes cluster to create a node group for.

  4. On the Kubernetes cluster page, go to the Node groups tab.

  5. Click Create node group.

  6. Enter a name and description for the node group. Naming requirements:

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

  7. Specify the number of nodes in the group.

  8. Under Computing resources:

  9. Under Storage:

    • Specify the Disk type:
      • HDD: A standard network drive. Network block storage on an HDD.
      • SSD: A fast network drive. Network block storage on an SSD.
    • Specify the disk size.
  10. 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.
  11. 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.
  12. Click Create node group.

What's next