CKAD Mock Test 1

Hello,

My answer to question 9 has been marked as incorrect by the system. I used a yaml file to create the secrets and below are the details:

controlplane $ cat db-secret-xxdf.yaml
apiVersion: v1
kind: Secret
metadata:
name: db-secret-xxdf
data:
DB_Host: c3FsMDEK
DB_User: cm9vdAo=
DB_Password: cGFzc3dvcmQxMjMK

On decoding the values, they look to be correct:

controlplane $ echo “c3FsMDEK” | base64 --decode
sql01
controlplane $ echo “cm9vdAo=” | base64 --decode
root
controlplane $ echo “cGFzc3dvcmQxMjMK” | base64 --decode
password123

Error message is:

[{“jmespath”:“items[?metadata.name==‘db-secret-xxdf’].metadata.name”,“name”:“db-secret-xxdf”,“object”:“Secret”,“spec”:“Secret Name: db-secret-xxdf”,“state”:“present”,“test_result”:true,“type”:“kubernetes”},{“err_message”:“c3FsMDE= not found!”,“jmespath”:“items[?metadata.name==‘db-secret-xxdf’] | [].data.DB_Host”,“name”:“c3FsMDE=”,“object”:“Secret”,“spec”:“Secret 1: DB_Host=sql01”,“state”:“present”,“test_result”:false,“type”:“kubernetes”},{“err_message”:“cm9vdA== not found!”,“jmespath”:“items[?metadata.name==‘db-secret-xxdf’] | [].data.DB_User”,“name”:“cm9vdA==”,“object”:“Secret”,“spec”:“Secret 2: DB_User=root”,“state”:“present”,“test_result”:false,“type”:“kubernetes”},{“err_message”:“cGFzc3dvcmQxMjM= not found!”,“jmespath”:“items[?metadata.name==‘db-secret-xxdf’] | [].data.DB_Password”,“name”:“cGFzc3dvcmQxMjM=”,“object”:“Secret”,“spec”:“Secret 3: DB_Password=password123”,“state”:“present”,“test_result”:false,“type”:“kubernetes”}]

Could you please look into it and let me know why my answer is not correct?

Thanks,
Pallav

How did you convert the data to base64? I have decoded your data and there is a next line included in your base64 content.
As per the kube document you have remove next line while encoding example : ```
echo -n ‘my-app’ | base64

Note there is a -n parameter needs to be passed while encoding.
As per the above error message DB_HOST value should be c3FsMDE= after adding -n parameter.

I was using echo “string” | base64 | tr -d “\n” which I now reliaze would give the wrong answer. The answer can be the one you suggested or echo “string” | tr -d “\n” | base64.

Thanks for your help!

Glad to hear you sort it out!..