Kubernetes Secrets in 5 Minutes! - YouTube
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

!https://www.youtube.com/watch?v=cQAEK9PBY8U&t=186

Date: October 30, 2023

I am converting my docker compose env secrets over to k8s secrets. This guide was clear and to the point how I can replicate this exact workflow.

First set the secret, the easiest way is to use kubectl wtih –from-literal because it automatically base64 encodes for you.

[38;2;248;248;242m[code][0m
  kubectl create secret generic minio-access-key --from-literal=ACCESS_KEY=7FkTV**** -n shot

If you don’t use the [38;2;189;147;249m--from-literal[0m you will have to base64 encode it.

[38;2;248;248;242m[code][0m
  echo "7FkTV****" | openssl base64

Once you have your secret deployed, you have to update the container spec in your deployment manifest to get the valueFrom secretKeyRef.

[38;2;248;248;242m[code][0m
      spec:
        containers:
          - env:
              - name: ACCESS_KEY
                valueFrom:
                  secretKeyRef:
                    key: ACCESS_KEY
                    name: minio-access-key
              - name: SECRET_KEY
                valueFrom:
                  secretKeyRef:
                    key: SECRET_KEY
                    name: minio-secret-key
            image: registry.wayl.one/shot-scraper-api
            name: shot-wayl-one
            ports:
              - containerPort: 5000
                protocol: TCP
            resources: {}
        restartPolicy: Always
