Lab Information
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:
We already have a secret key file official.txt under /opt location on jump host. Create a generic secret named official, it should contain the password/license-number present in official.txt file.
Also create a pod named secret-devops.
Configure pod's spec as container name should be secret-container-devops, image should be fedora with latest tag (remember to mention the tag with image). Use sleep command for container so that it remains in running state. Consume the created secret and mount it under /opt/demo within the container.
To verify you can exec into the container secret-container-devops, to check the secret key under the mounted path /opt/demo. Before hitting the Check button please make sure pod/pods are in running state, also validation can take some time to complete so keep patience.
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.
Lab Solutions
Step 1: Check the Secret Key File
First, let's verify the content of the official.txt file:
cat /opt/official.txt
This will show you the password/license-number that needs to be stored as a secret.
Step 2: Create the Kubernetes Secret
Create a generic secret named official from the file:
kubectl create secret generic official --from-file=official=/opt/official.txt
Step 3: Verify the Secret was Created
Check if the secret was created successfully:
kubectl get secrets
To see more details:
kubectl describe secret official
Step 4: Create the Pod Configuration
Create a file named secret-devops.yaml:
apiVersion: v1
kind: Pod
metadata:
name: secret-devops
spec:
containers:
- name: secret-container-devops
image: fedora:latest
command: ["/bin/bash", "-c", "sleep infinity"]
volumeMounts:
- name: secret-volume
mountPath: /opt/demo
readOnly: true
volumes:
- name: secret-volume
secret:
secretName: official
Step 5: Deploy the Pod
Apply the pod configuration:
kubectl apply -f secret-devops.yaml
Step 6: Verify the Pod is Running
Check the pod status:
kubectl get pods
Step 7: Verify the Secret is Mounted Correctly
# Once the pod is running, execute into the container to verify the secret:
kubectl exec -it secret-devops -- /bin/bash
# Inside the container, check the mounted secret:
ls -la /opt/demo/
# You should see the secret file. Then check its content:
cat /opt/demo/official
# Exit the container:
exit






Top comments (0)