---
title: "💭 Kubernetes Secrets in 5 Minutes! - YouTube"
description: "!https://www.youtube.com/watch?v=cQAEK9PBY8U&t=186"
date: 2023-10-30
published: true
tags:
  - infra
  - k8s
  - thought
template: link
---


<div class="embed-card embed-card-external embed-card-provider-youtube">
  <div class="embed-card-rich">
<lite-youtube videoid="cQAEK9PBY8U" title="Kubernetes Secrets in 5 Minutes!" playlabel="Play: Kubernetes Secrets in 5 Minutes!"></lite-youtube>
  </div>
</div>


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.

``` bash
kubectl create secret generic minio-access-key --from-literal=ACCESS_KEY=7FkTV**** -n shot
```

If you don't use the `--from-literal` you will have to base64 encode it.

``` bash
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.

``` yaml
    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
```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
