100-Days-Of-DevOps-Challenge-KodeKloud

Manage Secrets in Kubernetes

The Nautilus DevOps team is working to deploy some tools in Kubernetes cluster. Some of the tools are licence based so that licence information needs to be stored securely within Kubernetes cluster. Therefore, the team wants to utilize Kubernetes secrets to store those secrets. Below you can find more details about the requirements:

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.

Steps

  1. To create a generic secret from file:

     kubectl create secret generic media --from-file=/opt/media.txt
    

    To check:

     kubectl describe secret media
    
  2. Create the k3s-pod.yaml file, copy-paste contents from this YAML file

  3. Run the pod

     kubectl apply -f k3s-pod.yaml
    
  4. Verify results

     kubectl get secret
     kubectl get pod
     kubectl exec -it secret-devops -c secret-container-devops -- cat /opt/cluster
    

    You can see secret data, running pods and execute the command to verify the secret is placed inside the container

Good to Know?

Kubernetes Secrets

Secret Types

Secret Usage

Security Best Practices