Task weight: 1%

You have access to multiple clusters from your main terminal through kubectl contexts. Write all those context names into /opt/course/1/contexts.

Next write a command to display the current context into /opt/course/1/context_default_kubectl.sh, the command should use kubectl.

Finally write a second command doing the same thing into /opt/course/1/context_default_no_kubectl.sh, but without the use of kubectl.


译文:

你可以通过kubectl contexts 从你的主终端访问多个集群。把所有这些上下文的名字写进 /opt/course/1/contexts

接下来写一条显示当前环境的命令到/opt/course/1/context_default_kubectl.sh,该命令应使用kubectl。

最后写第二条命令做同样的事情到/opt/course/1/context_default_no_kubectl.sh,但不使用kubectl。


解答:

k config get-contexts # copy manually
k config get-contexts -o name > /opt/course/1/contexts

file

kubectl config current-context
echo "kubectl config current-context" > /opt/course/1/context_default_kubectl.sh
bash /opt/course/1/context_default_kubectl.sh

file

cat ~/.kube/config | grep current | awk '{printf $2}'
echo "cat ~/.kube/config | grep current | awk '{printf $2}'" > /opt/course/1/context_default_no_kubectl.sh

file


Killer.sh CKA模拟题目 汇总