kubectl config use-context cluster6-admin@cluster6
k get secret db -n team-5 -o yaml
apiVersion: v1
data:
password: UGExNjM2d29yRA==
user: YWQtYWRtaW4=
kind: Secret
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","data":{"password":"UGExNjM2d29yRA==","user":"YWQtYWRtaW4="},"kind":"Secret","metadata":{"annotations":{},"creationTimestamp":null,"name":"db","namespace":"team-5"}}
creationTimestamp: "2023-09-27T16:47:13Z"
name: db
namespace: team-5
resourceVersion: "540"
uid: ba6e2888-6f02-4731-bba4-39df2fefc91d
type: Opaque
mkdir /var/work/tests/artifacts/5/ -p
echo {user} | base64 -d > /var/work/tests/artifacts/5/user
echo {password} | base64 -d > /var/work/tests/artifacts/5/password
k create secret generic db-admin -n team-5 --from-literal user=xxx --from-literal password=yyyy
k run db-admin --image viktoruj/cks-lab -n team-5 -o yaml --dry-run=client --command sleep 60000 >5.yaml
https://kubernetes.io/docs/concepts/configuration/secret/
# vim 5.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: db-admin
name: db-admin
namespace: team-5
spec:
volumes:
- name: db-admin
secret:
secretName: db-admin
containers:
- command:
- sleep
- "60000"
image: viktoruj/cks-lab
name: db-admin
volumeMounts:
- name: db-admin
readOnly: true
mountPath: "/mnt/secret"
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}