Linux Foundation CKS Exam - Topic 1 Question 24 Discussion
Cluster: devMaster node:master1Worker node:worker1You can switch the cluster/configuration context using the following command:[desk@cli] $kubectl config use-context devTask:Retrieve the content of the existing secret namedadamin thesafenamespace.Store the username field in a file names/home/cert-masters/username.txt, and the password field in a file named/home/cert-masters/password.txt.1. You must create both files; they don't exist yet.2. Do not use/modify the created files in the following steps, create new temporary files if needed.Create a new secret namesnewsecretin thesafenamespace, with the following content:Username:dbadminPassword:moresecurepasFinally, create a new Pod that has access to the secretnewsecretvia a volume:Namespace: safePod name: mysecret-podContainer name: db-containerImage: redisVolume name: secret-volMount path: /etc/mysecret
A) Explanation:
1. Get the secret, decrypt it & save in files
k get secret adam -n safe -o yaml
2. Create new secret using --from-literal
[desk@cli] $k create secret generic newsecret -n safe --from-literal=username=dbadmin --from-literal=password=moresecurepass
3. Mount it as volume of db-container of mysecret-pod
Explanation
[desk@cli] $k create secret generic newsecret -n safe --from-literal=username=dbadmin --from-literal=password=moresecurepass
secret/newsecret created
[desk@cli] $vim /home/certs_masters/secret-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: mysecret-pod
namespace: safe
labels:
run: mysecret-pod
spec:
containers:
- name: db-container
image: redis
volumeMounts:
- name: secret-vol
mountPath: /etc/mysecret
readOnly: true
volumes:
- name: secret-vol
secret:
secretName: newsecret
[desk@cli] $k apply -f /home/certs_masters/secret-pod.yaml
pod/mysecret-pod created
[desk@cli] $k exec -it mysecret-pod -n safe -- cat /etc/mysecret/username
dbadmin
[desk@cli] $k exec -it mysecret-pod -n safe -- cat /etc/mysecret/password
moresecurepas
Lynna
9 months agoCheryll
9 months agoAhmed
9 months agoDion
9 months agoJulene
10 months agoMaxima
10 months agoGlendora
10 months agoLina
10 months agoWillie
10 months agoWillie
10 months agoLynsey
10 months agoAlesia
10 months agoTamar
10 months ago