Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Connecting to a node over SSH
    • Updating Kubernetes
    • Configuring autoscaling
    • Connecting to a cluster
      • Connection method overview
      • Configuring security groups
      • Creating a static configuration file
    • Installing applications from Cloud Marketplace
      • Basics of working with Cloud Marketplace
      • Installing Argo CD
      • Installing Container Storage Interface for S3
      • Installing Crossplane
      • Installing External Secrets Operator
      • Installing Filebeat
      • Installing Fluent Bit
      • Installing Gateway API
      • Installing GitLab Agent
      • Installing GitLab Runner
      • Installing HashiCorp Vault
      • Installing the Application Load Balancer Ingress controller
      • Installing Jaeger
      • Installing Kyverno & Kyverno Policies
      • Installing Metrics Provider
      • Installing NodeLocal DNS
      • Installing Policy Reporter
      • Installing Thumbor
    • Network scenarios
      • Granting access to an app running in a Kubernetes cluster
      • Configuring the Calico network policy controller
      • Configuring the Cilium network policy controller
      • Configuring NodeLocal DNS for the Cilium network policy controller
    • Working with persistent volumes
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Expanding a pod volume
      • Expanding a StatefulSet controller volume
      • Mounting a volume in Block mode
      • Integration with Object Storage
    • Managing a Kubernetes cluster
      • Getting information about a Kubernetes cluster
      • Creating a Kubernetes cluster
      • Editing a Kubernetes cluster
      • Creating a namespace in a Kubernetes cluster
      • Deleting a Kubernetes cluster
    • Managing a node group
      • Information about existing node groups
      • Creating a node group
      • Connecting to a node over SSH
      • Configuring autoscaling
      • Changing a node group
      • Managing Kubernetes cluster node labels
      • Deleting a node group
    • Connecting external nodes to the cluster
  • Practical guidelines
    • All tutorials
    • Creating a new Kubernetes project in Yandex Cloud
    • Integration with Container Registry
    • Running workloads with GPUs
    • Installing an NGINX Ingress controller with Let's Encrypt®
    • Installing an NGINX Ingress controller with a certificate from Certificate Manager
    • Backups to Object Storage
    • Horizontal application scaling in a cluster
    • Vertical application scaling in a cluster
    • Deploying and load testing a gRPC service with scaling
    • Working with snapshots
    • Integrating into a corporate DNS zone
    • Automatic DNS scaling by cluster size
    • Setting up local DNS caching
    • Checking DNS Challenge for Let's Encrypt® certificates
    • Monitoring a cluster using Prometheus and Grafana
    • Continuous deployment of containerized applications using GitLab
    • Using Cloud Marketplace products
      • Integrating with Argo CD
      • Integration with Crossplane
      • Syncing with Yandex Lockbox secrets
      • Configuring Fluent Bit for Cloud Logging
      • Setting up Gateway API
      • Configuring the Application Load Balancer Ingress controller
      • Using Jaeger to trace requests in Managed Service for YDB
      • Using Metrics Provider to stream metrics
  • Concepts
    • Relationships between service resources
    • Release channels and updates
    • Encrypting secrets
    • Using Kubernetes API objects
      • Volumes
      • Service
    • Node groups
      • Cluster autoscaler
      • Evicting pods from nodes
      • Dynamic resource allocation for a node
      • Node groups with GPUs
    • Network in Managed Service for Kubernetes
    • External cluster nodes
    • Network settings and cluster policies
    • Automatic scaling
    • Quotas and limits
    • Recommendations for using Managed Service for Kubernetes
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ClusterService
      • NodeGroupService
      • VersionService
      • OperationService
    • REST
      • Overview
      • Cluster
        • Overview
        • create
        • delete
        • get
        • list
        • listNodeGroups
        • listNodes
        • listOperations
        • start
        • stop
        • update
      • NodeGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listNodes
        • listOperations
        • update
      • Version
        • Overview
        • list
  • Questions and answers
    • General questions
    • Data storage
    • Configuring and updating
    • Automatic scaling
    • Resources
    • Logs
    • All questions on one page
  1. Step-by-step instructions
  2. Installing applications from Cloud Marketplace
  3. Installing HashiCorp Vault

Installing HashiCorp Vault with Key Management Service support

Written by
Yandex Cloud
  • Creating a service account and keys
  • Installing HashiCorp Vault
  • Initializing the vault

HashiCorp Vault is an open source tool for securely storing and accessing secrets (such as passwords, certificates, and tokens).

The application image contains a pre-installed build of HashiCorp Vault with added support for Auto Unseal via Yandex Key Management Service. The build is based on HashiCorp Vault 1.8.2.

To install HashiCorp Vault:

  1. Create a service account and keys.
  2. Install HashiCorp Vault.
  3. Initialize the vault.

Creating a service account and keys

To use HashiCorp Vault, you need:

  • A service account with the kms.keys.encrypterDecrypter role.
  • An authorized key.
  • A symmetric encryption key.
  1. Create a service account:

    yc iam service-account create --name vault-kms
    
  2. Create an authorized key for the service account and save it to a file named authorized-key.json:

    yc iam key create \
      --service-account-name vault-kms \
      --output authorized-key.json
    
  3. Create a Key Management Service symmetric key:

    yc kms symmetric-key create \
      --name example-key \
      --default-algorithm aes-256 \
      --rotation-period 24h
    

    Save the key ID (id). You will need it when installing the application.

  4. Assign the role kms.keys.encrypterDecrypter to the Key Management Service key:

    yc resource-manager folder add-access-binding \
      --id <folder ID> \
      --service-account-name vault-kms \
      --role kms.keys.encrypterDecrypter
    

    You can fetch the folder ID with a list of folders.

Installing HashiCorp Vault

Installation using Yandex Cloud Marketplace
Installation using a Helm chart
  1. Go to the folder page and select Managed Service for Kubernetes.
  2. Click the name of the desired cluster and open the Marketplace tab.
  3. Under Applications available for installation, select HashiCorp Vault 1.8.2 with Key Management Service support and click Use.
  4. Configure the application:
    • Namespace: Select a namespace or create a new one.
    • Application name: Enter an application name.
    • Service account key for Vault: Copy the contents of the authorized-key.json file to this field.
    • KMS key ID for Vault: Specify the previously obtained Key Management Service key ID.
  5. Click Install.
  1. Install the Helm package manager.

  2. To install a Helm chart with HashiCorp Vault , run the following command:

    export HELM_EXPERIMENTAL_OCI=1 && \
    cat authorized-key.json | helm registry login cr.yandex --username 'json_key' --password-stdin && \
    helm pull oci://cr.yandex/yc-marketplace/yandex-cloud/vault/chart/vault \
      --version <Helm chart version> \
      --untar && \
    helm install \
      --namespace hashicorp \
      --create-namespace \
      --set-file yandexKmsAuthJson=authorized-key.json \
      hashicorp ./vault/
    

    This command also creates a new hashicorp namespace required for HashiCorp Vault.

    You can check the current version of the Helm chart on the application page.

Initializing the vault

Once HashiCorp Vault is installed, you need to initialize one of its servers. The initialization process generates credentials required to unseal all the vault servers.

Note

While initializing the vault, there is no need to perform the unseal operation, since the application image is integrated with Key Management Service.

For more information, see Auto Unseal and the HashiCorp Vault documentation.

To initialize the vault:

  1. Make sure that the application switched to Running and has 0/1 ready pods:

    kubectl get pods --selector='app.kubernetes.io/name=vault'
    

    Command result:

    NAME              READY  STATUS   RESTARTS  AGE
    <vault pod name>  0/1    Running  0         58s
    
  2. Initialize the vault:

    kubectl exec \
      --stdin=true \
      --tty=true <vault pod name> \
      -- vault operator init
    

    Command result:

    Recovery Key 1: ulbugw4IKttmCCPprF6JwmUCyx1YfieCQPQiI2S0VV9o
    Recovery Key 2: S0kcValC6qSfEI4WJBovSbJWZntBUwtTrtisSIcS3n0e
    Recovery Key 3: t44ZRqbzLZNzfChinZNzLCNnwvFN/R52vbDq/UueHPPg
    ...
    Recovery key initialized with 5 key shares and a key threshold of 3. Please
    securely distribute the key shares printed above.
    
  3. Query the list of application pods again and make sure that one pod is ready:

    kubectl get pods --selector='app.kubernetes.io/name=vault'
    

    Command result:

    NAME               READY  STATUS   RESTARTS  AGE
    vault-yckms-k8s-0  1/1    Running  0         5m
    

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Creating a service account and keys
  • Installing HashiCorp Vault
  • Initializing the vault