Review Secret encryption at rest in Tencent Cloud TKE

Check Secret encryption at rest and access to the KMS key in TKE.

Description

Enabling KMS protection on a TKE cluster encrypts Kubernetes Secrets stored in etcd. Configure volume encryption and transport protection separately.

Potential impact

Exposure of the etcd store can disclose credentials and tokens. Encryption at rest still allows authorized reads through Kubernetes, so restrict Secret access through RBAC and limit access to the key.

Remediation

For a supported cluster, set cluster_id on tencentcloud_kubernetes_encryption_protection and enter the key ID and its region in kms_configuration. Grant TKE permission to use the key and protect it from disabling or deletion while in use.

Examples

Supply the omitted VPC data source. Set kms_region to the key’s region (ap-guangzhou in the example). After applying, check the cluster’s etcd encryption status and verify that workloads can use their Secrets.

Before

hcl
resource "tencentcloud_kubernetes_cluster" "platform_cluster" {
  vpc_id                  = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
  cluster_cidr            = "10.32.0.0/16"
  cluster_max_pod_num     = 32
  cluster_name            = "tf_example_cluster"
  cluster_desc            = "example cluster"
  cluster_max_service_num = 32
  cluster_deploy_type     = "MANAGED_CLUSTER"
}

After

hcl
resource "tencentcloud_kubernetes_cluster" "platform_cluster" {
  vpc_id                  = data.tencentcloud_vpc_subnets.vpc.instance_list.0.vpc_id
  cluster_cidr            = "10.32.0.0/16"
  cluster_max_pod_num     = 32
  cluster_name            = "tf_example_cluster"
  cluster_desc            = "example cluster"
  cluster_max_service_num = 32
  cluster_deploy_type     = "MANAGED_CLUSTER"
}

resource "tencentcloud_kms_key" "cluster_key" {
  alias       = "tf-example-kms-key"
  description = "Key for encrypting Kubernetes Secrets"
  key_usage   = "ENCRYPT_DECRYPT"
  is_enabled  = true
}

resource "tencentcloud_kubernetes_encryption_protection" "cluster_encryption" {
  cluster_id = tencentcloud_kubernetes_cluster.platform_cluster.id

  kms_configuration {
    key_id     = tencentcloud_kms_key.cluster_key.id
    kms_region = "ap-guangzhou"
  }
}

References