The kubeconfig felt warm in your hands. You knew one wrong move could expose secrets across the cluster. Field-level encryption with kubectl was no longer a theoretical safeguard—it was the line between control and chaos.
Traditional Kubernetes secrets store data base64-encoded, not encrypted. Anyone with access can read them. Field-level encryption changes this. Instead of encrypting entire resources, it locks down specific fields—like passwords, API keys, or tokens—inside YAML manifests before they ever hit etcd. This ensures sensitive parts are unreadable to anyone without the right key, even if the rest of the resource remains visible.
Implementing field-level encryption with kubectl requires integrating an encryption provider. Common choices include KMS solutions such as AWS KMS, Google Cloud KMS, or HashiCorp Vault. The workflow looks like this:
- Define encryption configuration
Create anEncryptionConfigurationspecifying the resources and fields to encrypt. Example:
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources:
- secrets
providers:
- kms:
name: my-kms-key
endpoint: unix:///tmp/kms.socket
- Apply configuration to the API server
Update the--encryption-provider-configflag in your API server manifest to point to the configuration file. Restart the control plane pods. - Use
kubectlto create or update encrypted fields
With the provider active,kubectl applywrites encrypted values at the field level. Reading the resource viakubectl getwill show only ciphertext unless you have decryption rights. - Rotate keys
Regular key rotation is essential. Update the provider with a new key, re-encrypt the fields, and confirm the data remains operational.
Field-level encryption with kubectl strengthens Kubernetes security without fully locking down resources. It protects what matters most while keeping operational visibility intact. Engineers can audit configs without touching secrets. Attackers face unreadable gibberish even with partial access.