Bird
Raised Fist0
Kubernetesdevops~20 mins

Secrets are not encrypted by default in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Secrets Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the default state of Kubernetes Secrets?
In Kubernetes, what is the default way Secrets are stored in etcd?
ASecrets are stored as plain base64-encoded strings without encryption.
BSecrets are encrypted using AES-256 by default.
CSecrets are hashed with SHA-256 before storage.
DSecrets are stored in an external vault by default.
Attempts:
2 left
💡 Hint
Think about how base64 encoding works and if it is a form of encryption.
💻 Command Output
intermediate
1:30remaining
Output of viewing a Kubernetes Secret
What is the output of the command kubectl get secret mysecret -o yaml if the secret contains a password 'mypassword'?
Kubernetes
kubectl get secret mysecret -o yaml
A
data:
  password: mypassword
metadata:
  name: mysecret
B
data:
  password: encrypted:mypassword
metadata:
  name: mysecret
C
data:
  password: bXlwYXNzd29yZA==
metadata:
  name: mysecret
D
data:
  password: SHA256:mypassword
metadata:
  name: mysecret
Attempts:
2 left
💡 Hint
Remember how base64 encoding looks for the string 'mypassword'.
❓ Configuration
advanced
2:30remaining
Enable encryption of Secrets at rest in Kubernetes
Which configuration snippet correctly enables encryption of Secrets at rest in Kubernetes using AES-CBC with a key named 'mykey'?
A
apiVersion: v1
kind: EncryptionConfig
resources:
- secrets
providers:
- aescbc:
    keys:
    - name: mykey
      secret: c2VjcmV0a2V5MTIzNDU2Nzg5MA==
B
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources:
  - secrets
  providers:
  - aescbc:
      keys:
      - name: mykey
        secret: c2VjcmV0a2V5MTIzNDU2Nzg5MA==
  - identity: {}
C
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- secrets
providers:
- aescbc:
    keys:
    - name: mykey
      secret: c2VjcmV0a2V5MTIzNDU2Nzg5MA==
D
apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
- resources:
  - secrets
  providers:
  - aescbc:
      keys:
      - name: mykey
        secret: c2VjcmV0a2V5MTIzNDU2Nzg5MA==
Attempts:
2 left
💡 Hint
Check the indentation and structure carefully; 'resources' is nested under the first list item.
❓ Troubleshoot
advanced
2:00remaining
Why are Secrets still visible in plain text after enabling encryption?
After configuring encryption at rest for Secrets, you still see base64-encoded Secrets in plain text when running kubectl get secret. Why?
AEncryption only works for ConfigMaps, not Secrets.
BEncryption configuration was not applied to the API server; it needs a restart.
CSecrets are cached in the client and not refreshed after encryption enabled.
Dkubectl shows Secrets decoded from etcd; encryption is only for storage, not for kubectl output.
Attempts:
2 left
💡 Hint
Think about where encryption applies and what kubectl displays.
✅ Best Practice
expert
3:00remaining
Best practice to secure Kubernetes Secrets beyond encryption at rest
Which approach is the best practice to enhance Kubernetes Secrets security beyond enabling encryption at rest?
AIntegrate an external secrets management system like HashiCorp Vault and use Kubernetes External Secrets.
BStore Secrets as plain text in ConfigMaps for easier access.
CDisable RBAC to allow all users to access Secrets freely.
DUse base64 encoding with longer keys for Secrets.
Attempts:
2 left
💡 Hint
Think about centralized secret management and access control.

Practice

(1/5)
1. What is the default way Kubernetes stores Secrets?
easy
A. Hashed using SHA-256 before storage
B. As base64 encoded plain text in etcd
C. Stored in an external vault automatically
D. Encrypted with AES-256 by default

Solution

  1. Step 1: Understand Kubernetes default Secret storage

    Kubernetes stores Secrets in etcd as base64 encoded strings, which is not encryption but simple encoding.
  2. Step 2: Confirm encryption is not enabled by default

    Encryption at rest must be explicitly configured; by default, Secrets are not encrypted.
  3. Final Answer:

    As base64 encoded plain text in etcd -> Option B
  4. Quick Check:

    Default Secret storage = base64 plain text [OK]
Hint: Remember: base64 is encoding, not encryption [OK]
Common Mistakes:
  • Confusing base64 encoding with encryption
  • Assuming Secrets are encrypted by default
  • Thinking Kubernetes uses external vault automatically
2. Which of the following is the correct way to enable encryption of Secrets in Kubernetes?
easy
A. Configure EncryptionConfiguration file in API server flags
B. Set encryption: true in the Secret manifest
C. Add --encryption-provider flag to kubelet
D. Use kubectl encrypt secret command

Solution

  1. Step 1: Identify where encryption is configured

    Encryption at rest is enabled by configuring the API server with an EncryptionConfiguration file and passing it via flags.
  2. Step 2: Verify other options are invalid

    Kubelet does not handle encryption, Secret manifests do not have encryption fields, and kubectl has no encrypt command.
  3. Final Answer:

    Configure EncryptionConfiguration file in API server flags -> Option A
  4. Quick Check:

    Encryption enabled via API server config [OK]
Hint: Encryption config is on API server, not kubelet or kubectl [OK]
Common Mistakes:
  • Trying to encrypt Secrets via kubectl commands
  • Assuming kubelet manages encryption
  • Adding encryption fields in Secret YAML
3. Given this snippet from an EncryptionConfiguration file:
{
  "kind": "EncryptionConfiguration",
  "apiVersion": "apiserver.config.k8s.io/v1",
  "resources": [
    {
      "resources": ["secrets"],
      "providers": [
        {"aescbc": {"keys": [{"name": "key1", "secret": "c2VjcmV0MTIzNDU2Nzg5MDEyMzQ1Njc4OTA="}]}},
        {"identity": {}}
      ]
    }
  ]
}
What does this configuration do?
medium
A. Encrypts Secrets using AES-CBC with key1, falling back to no encryption
B. Encrypts all resources except Secrets
C. Disables encryption for Secrets
D. Encrypts Secrets using identity provider only

Solution

  1. Step 1: Analyze the providers list for Secrets

    The providers list has an AES-CBC encryption provider with a key named key1, followed by identity (no encryption) as fallback.
  2. Step 2: Understand the effect on Secrets

    This means Secrets are encrypted with AES-CBC using key1; if decryption fails, identity provider returns plain data.
  3. Final Answer:

    Encrypts Secrets using AES-CBC with key1, falling back to no encryption -> Option A
  4. Quick Check:

    Encryption config with AES-CBC + identity fallback [OK]
Hint: First provider encrypts, second is fallback identity [OK]
Common Mistakes:
  • Thinking identity means encryption is disabled
  • Assuming all resources are encrypted, not just Secrets
  • Confusing provider order effect
4. You configured encryption for Secrets but still see base64 encoded plain text in etcd. What is the most likely cause?
medium
A. Secrets manifest missing encryption annotation
B. Encryption key is too short
C. kubectl version is outdated
D. API server was not restarted after adding EncryptionConfiguration

Solution

  1. Step 1: Check if API server reload is needed

    EncryptionConfiguration changes require API server restart to take effect.
  2. Step 2: Verify other options are irrelevant

    Secrets do not need annotations for encryption, kubectl version does not affect encryption, and key length would cause errors, not silent failure.
  3. Final Answer:

    API server was not restarted after adding EncryptionConfiguration -> Option D
  4. Quick Check:

    API server restart required for encryption config [OK]
Hint: Restart API server after config changes [OK]
Common Mistakes:
  • Forgetting to restart API server
  • Adding encryption annotations to Secrets
  • Blaming kubectl version for encryption issues
5. You want to ensure all Secrets in your cluster are encrypted at rest. Which steps should you follow? Select the correct sequence.
hard
A. Enable encryption in kube-proxy config, restart kube-proxy, check logs
B. Add encryption field to Secret manifests, restart kubelet, verify kubectl output
C. Create EncryptionConfiguration file, update API server flags, restart API server, verify etcd data
D. Run kubectl encrypt secrets, update RBAC, restart API server

Solution

  1. Step 1: Prepare EncryptionConfiguration file

    Create a file defining encryption providers for Secrets, typically AES-CBC or AES-GCM.
  2. Step 2: Update API server flags and restart

    Pass the EncryptionConfiguration file path to the API server via flags and restart it to apply changes.
  3. Step 3: Verify Secrets are encrypted in etcd

    Check etcd data to confirm Secrets are stored encrypted, not just base64 encoded.
  4. Final Answer:

    Create EncryptionConfiguration file, update API server flags, restart API server, verify etcd data -> Option C
  5. Quick Check:

    Encryption setup = config file + API server restart + verify [OK]
Hint: Encryption needs config file + API server restart + verify [OK]
Common Mistakes:
  • Trying to encrypt Secrets via manifest changes
  • Restarting wrong components like kubelet or kube-proxy
  • Using non-existent kubectl encrypt command
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard