模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

更新在 namespace frontend 中的 Deployment 使其使用现有的 ServiceAccount app

参考:

kubectl --help

解答:

切换环境

kubectl config use-context k8s

方法1: 直接通过命令设置

kubectl -n frontend get deployments.apps
kubectl -n frontend set serviceaccount deployments frontend-deployment app
kubectl -n frontend describe deployments.apps frontend-deployment

file

方法2: 编辑现有deployment

kubectl -n frontend edit deployments.apps frontend-deployment

spec.template.spec下添加

       serviceAccount: app
       serviceAccountName: app

file