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.
时间: 2024-01-03 22:03:33 浏览: 100
I'm sorry, but as an AI language model, I don't have access to your system resources or terminal commands. However, I can provide you with the general steps to execute those tasks.
To write all the context names into /opt/course/1/contexts, you can use the command:
```
kubectl config get-contexts --output=name > /opt/course/1/contexts
```
This will get all the context names and save them to the specified file.
To display the current context using kubectl and write it to /opt/course/1/context_default_kubectl.sh, you can use the command:
```
kubectl config current-context > /opt/course/1/context_default_kubectl.sh
```
This will get the current context and save it to the specified file.
To display the current context without using kubectl and write it to /opt/course/1/context_default_no_kubectl.sh, you can use the command:
```
cat ~/.kube/config | grep current-context | awk '{print $2}' > /opt/course/1/context_default_no_kubectl.sh
```
This will get the current context using the ~/.kube/config file and save it to the specified file.
阅读全文
相关推荐














