Configure a Pod to Use a Projected Volume for Storage
Note: serviceAccountToken
is not a volume type.
You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:
To check the version, enter kubectl version
.
Here is the configuration file for the Pod:
Create the Secrets:
echo -n "admin" > ./username.txt
echo -n "1f2d1e2e67df" > ./password.txt
# Package these files into secrets:
kubectl create secret generic user --from-file=./username.txt
In another terminal, get a shell to the running container:
kubectl exec -it test-projected-volume -- /bin/sh
Delete the Pod and the Secrets:
kubectl delete pod test-projected-volume
kubectl delete secret user pass
- Learn more about projected volumes.