0
0
Kubernetesdevops~10 mins

Secret types (Opaque, docker-registry, TLS) in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Secret types (Opaque, docker-registry, TLS)
Create Secret YAML
kubectl apply secret
Secret stored in Kubernetes
Pod references Secret
Secret data injected into Pod
Pod uses Secret for auth/config
This flow shows how different secret types are created, stored, and used by pods in Kubernetes.
Execution Sample
Kubernetes
kubectl create secret generic mysecret --from-literal=key1=value1
kubectl create secret docker-registry regsecret --docker-username=user --docker-password=pass --docker-server=registry.example.com
kubectl create secret tls tlssecret --cert=cert.pem --key=key.pem
Commands to create three secret types: opaque, docker-registry, and TLS.
Process Table
StepCommandSecret TypeData StoredResult
1kubectl create secret generic mysecret --from-literal=key1=value1Opaquekey1=value1Opaque secret 'mysecret' created
2kubectl create secret docker-registry regsecret --docker-username=user --docker-password=pass --docker-server=registry.example.comdocker-registryusername, password, serverDocker-registry secret 'regsecret' created
3kubectl create secret tls tlssecret --cert=cert.pem --key=key.pemTLStls.crt, tls.keyTLS secret 'tlssecret' created
4kubectl get secret mysecret -o yamlOpaquekey1: dmFsdWUx (base64)Opaque secret data shown in base64
5kubectl get secret regsecret -o yamldocker-registry.dockerconfigjson (base64)Docker-registry secret data shown in base64
6kubectl get secret tlssecret -o yamlTLStls.crt, tls.key (base64)TLS secret data shown in base64
7Pod mounts secret 'mysecret'Opaquekey1=value1Pod can read key1 from secret
8Pod uses 'regsecret' for image pulldocker-registryauth to registryPod can pull private images
9Pod uses 'tlssecret' for TLSTLScert and keyPod can establish secure connections
10End--All secrets created and usable by pods
💡 All secret types created and verified for pod usage
Status Tracker
Secret NameBefore CreationAfter Step 1After Step 2After Step 3Final
mysecretNoneOpaque secret with key1=value1Opaque secret with key1=value1Opaque secret with key1=value1Opaque secret with key1=value1
regsecretNoneNoneDocker-registry secret with credentialsDocker-registry secret with credentialsDocker-registry secret with credentials
tlssecretNoneNoneNoneTLS secret with cert and keyTLS secret with cert and key
Key Moments - 3 Insights
Why is the secret data shown in base64 when we get the secret YAML?
Kubernetes encodes secret data in base64 for safe storage and transmission. See execution_table rows 4-6 where secret data is base64 encoded.
Can we use an opaque secret to store TLS certificates?
Technically yes, but Kubernetes has a special TLS secret type that expects specific keys (tls.crt and tls.key) for easier use. See steps 1 and 3 for difference.
How does a pod use a docker-registry secret?
The pod uses the docker-registry secret to authenticate to private container registries when pulling images. See execution_table row 8.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what secret type is created at step 2?
AOpaque
BTLS
Cdocker-registry
DConfigMap
💡 Hint
Check the 'Secret Type' column at step 2 in the execution_table.
At which step does the pod get the TLS secret data?
AStep 9
BStep 7
CStep 8
DStep 10
💡 Hint
Look for the step where the pod uses 'tlssecret' in the execution_table.
If you change the docker password in step 2, which part of the execution_table changes?
AStep 1 data
BStep 5 secret data
CStep 9 pod usage
DStep 4 opaque secret
💡 Hint
Changing docker password affects the secret data shown in step 5.
Concept Snapshot
Kubernetes Secrets store sensitive data.
Opaque: generic key-value pairs.
Docker-registry: stores container registry credentials.
TLS: stores certificate and key.
Secrets are base64 encoded.
Pods mount or reference secrets for secure access.
Full Transcript
This visual execution shows how Kubernetes manages three secret types: opaque, docker-registry, and TLS. First, secrets are created using kubectl commands with specific flags for each type. The secret data is stored encoded in base64 inside Kubernetes. Pods can then reference these secrets to access sensitive information like passwords, certificates, or registry credentials. The execution table traces each step from creation to pod usage, showing how secrets change state and how pods consume them securely. Key moments clarify why data is base64 encoded, the difference between opaque and TLS secrets, and how docker-registry secrets enable private image pulls. The quiz tests understanding of secret types, pod usage, and data changes.