試験CKA トピック1 問題41 スレッド
Linux Foundation CKAのリアル試験問題集
問題 #: 41
トピック #: 1
問題 #: 41
トピック #: 1
You have a Deployment named 'mysql-deployment' running a MySQL database server. You need to store the MySQL root password securely using a Secret. This password should be used by the database server when it starts.
おすすめの解答:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Create the Secret:
- Create a Secret named 'mysql-password' to store the root password.
- Use the 'kubectl create secret generic' command with the '--from-literal' flag to create a generic Secret with a key-value pair:
kubectl create secret generic mysql-password -from-literal=mysql-root password="your_strong_password"
2. Modify the Deployment:
- Update the 'mysql-deployment' Deployment's Pod template to mount the mysql-password' Secret as a volume.
- Use 'volumeMounts' to specify where the Secret should be mounted within the container, and 'volumes' to define the Secret as a volume source.
- Update the MySQL server's configuration (e.g., the 'my.cnf file) to read the password from the mounted volume.

3. Apply the Changes: - Apply the modified Deployment YAML using 'kubectl apply -f mysql-deployment.yamP. 4. Restart the MySQL Pod: - Restart the MySQL pod for it to read the password from the mounted volume. This can be achieved using 'kubectl delete pod'. 5. Verify the Password: - Connect to the MySQL database using the provided password and confirm it works correctly.
Explanation:
Solution (Step by Step) :
1. Create the Secret:
- Create a Secret named 'mysql-password' to store the root password.
- Use the 'kubectl create secret generic' command with the '--from-literal' flag to create a generic Secret with a key-value pair:
kubectl create secret generic mysql-password -from-literal=mysql-root password="your_strong_password"
2. Modify the Deployment:
- Update the 'mysql-deployment' Deployment's Pod template to mount the mysql-password' Secret as a volume.
- Use 'volumeMounts' to specify where the Secret should be mounted within the container, and 'volumes' to define the Secret as a volume source.
- Update the MySQL server's configuration (e.g., the 'my.cnf file) to read the password from the mounted volume.

3. Apply the Changes: - Apply the modified Deployment YAML using 'kubectl apply -f mysql-deployment.yamP. 4. Restart the MySQL Pod: - Restart the MySQL pod for it to read the password from the mounted volume. This can be achieved using 'kubectl delete pod'. 5. Verify the Password: - Connect to the MySQL database using the provided password and confirm it works correctly.
Horiuchi 2026-06-25 04:11:04
コメント
他人の解答コメントを賛成するのも、その解答に一票を入れることになります。したがって、すでに同じ意見の投票コメントが存在する場合、新規コメントをする代わりに賛成することもできます。
コメントを通報する
コメント中
今すぐ 新規登録 / ログイン (無料です)。