https://drive.google.com/file/d/1sU2A8o26AZGml3tADoaY0gnO_GresyXy/view?usp=sharing
Kubernetes Secrets support two ways to define sensitive values:
data: Requires base64-encoded strings (hard to read/write)stringData: Accepts plain-text strings (Kubernetes auto-encodes them)β Always prefer stringData β itβs human-readable, less error-prone, and easier to manage.
Writing a password:
data: You manually encode it βcGFzc3dvcmQ=stringData: You write it normally βpasswordβ system handles encoding
stringData (Recommended)Step 1: Define Secret with stringData
# api-secret.yaml
apiVersion: v1
kind: Secret
meta
name: github-creds
namespace: ci
# Plain text β no base64!
token: "ghp_AbC123xYz456"
username: "dev-team-bot"
Apply it:
kubectl apply -f api-secret.yaml
Step 2: Verify Kubernetes Encoded It
kubectl get secret github-creds -n ci -o yaml
β Youβll see:
token: Z2hwX0FiQzEyM3hZejQ1Ng== # auto-encoded
username: ZGV2LXRlYW0tYm90 # auto-encoded
Step 3: Use in a Pod
spec:
containers:
- name: ci-runner
image: alpine
env:
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: github-creds
key: token