Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Key Management Service
  • Getting started
    • All tutorials
    • Encrypting secrets in Managed Service for Kubernetes
    • Signing and verifying Docker images in Managed Service for Kubernetes
    • Managing KMS keys with Hashicorp Terraform
    • Encrypting secrets in Hashicorp Terraform
    • Auto Unseal in Hashicorp Vault
    • Secure password transmission to an initialization script
    • Server-side encryption for an Object Storage bucket
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • FAQ

In this article:

  • Required paid resources
  • See also
  1. Tutorials
  2. Encrypting secrets in Managed Service for Kubernetes

Encrypting secrets in Yandex Managed Service for Kubernetes

Written by
Yandex Cloud
Updated at May 5, 2025
  • Required paid resources
  • See also

Use Yandex Key Management Service keys to encrypt secrets, i.e., confidential information, such as passwords, OAuth tokens, and SSH keys, in Yandex Managed Service for Kubernetes. To do this, specify a Key Management Service key when creating a Managed Service for Kubernetes cluster. This key will be used for encryption and decryption.

Make sure you specify the encryption key when creating a Managed Service for Kubernetes cluster, as you cannot add it when updating the cluster.

Required paid resourcesRequired paid resources

The cost of support for the described solution includes a Key Management Service fee: number of active key versions (with Active or Scheduled For Destruction for status) and completed cryptographic operations (see Key Management Service pricing).

Management console
CLI
Terraform
API

Specify a key when creating a Managed Service for Kubernetes cluster:

  1. In the management console, select the folder where you want to create a Managed Service for Kubernetes cluster.
  2. In the list of services, select Managed Service for Kubernetes.
  3. Click Create cluster.
  4. In the Encryption key field, enter the required key or create a new one.
  5. Enter all the other parameters to create your cluster.
  6. Click Create.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

You can specify a key when creating a Managed Service for Kubernetes cluster in two ways:

  • Using the key ID:

    yc managed-kubernetes cluster create \
      ...
      --kms-key-id <key_ID> \
      ...
    
  • Using the key name:

    yc managed-kubernetes cluster create \
      ...
      --kms-key-name <key_name> \
      ...
    

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

Specify a key when creating a Managed Service for Kubernetes cluster:

  1. Add a section named kms_provider to the Managed Service for Kubernetes cluster description:

    resource "yandex_kubernetes_cluster" "<cluster_name>" {
      ...
      kms_provider {
        key_id = "<key_ID>"
      }
    }
    
  2. Make sure the configuration files are correct.

    1. In the command line, go to the folder where you created the configuration file.

    2. Run a check using this command:

      terraform plan
      

    If the configuration is described correctly, the terminal will display a list of created resources and their parameters. If the configuration contains any errors, Terraform will point them out. This is a test step; no resources will be created.

  3. Create a Managed Service for Kubernetes cluster.

    1. If the configuration does not contain any errors, run this command:

      terraform apply
      
    2. Confirm that you want to create the resources.

    After this, all required resources will be created in the specified folder and the IP addresses of the VMs will be displayed in the terminal. You can check the new resources and their configuration using the management console.

Specify the encryption key when creating a Managed Service for Kubernetes cluster. To do this, use the create REST API method for the Cluster resource or the ClusterService/Create gRPC API call.

Provide the key ID in the relevant kmsProvider field parameter.

Managed Service for Kubernetes works with Key Management Service using the Key Management Service provider mechanism. Managed Service for Kubernetes supports the Key Management Service plugin which is used to encrypt and decrypt data encryption keys (DEK) in Key Management Service. Secrets are encrypted using standard Kubernetes tools.

See alsoSee also

  • Getting started with Managed Service for Kubernetes
  • Envelope encryption
  • Creating secrets in Kubernetes

Was the article helpful?

Previous
Encrypting data using Google Tink
Next
Signing and verifying Docker images in Managed Service for Kubernetes
© 2025 Direct Cursus Technology L.L.C.