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
7 months agoCheryll
8 months agoAhmed
8 months agoDion
8 months agoJulene
8 months agoMaxima
8 months agoGlendora
8 months agoLina
8 months agoWillie
9 months agoWillie
9 months agoLynsey
9 months agoAlesia
9 months agoTamar
9 months ago