【CKS最新模拟真题】获取多个集群的上下文名称并保存到指定文件中

文章目录


前言

月底考CKS,这是最新版的CKS模拟题

环境 k8s版本
ubuntu 1.31

一、TASK

题目要求

Solve this question on: ssh cks3477

You have access to multiple clusters from your main terminal through contexts. Write all context names into on , one per line.kubectl/opt/course/1/contextscks3477

From the kubeconfig extract the certificate of user and write it decoded to .restricted@infra-prod/opt/course/1/cert

中译

在以下位置解决此问题:ssh cks3477
您可以通过kubectl上下文从主终端访问多个集群 。将所有上下文名称写入 /opt/course/1/contextscks3477,每行一个。
从 kubeconfig 中提取restricted@infra-prod用户证书 并将其解码写入/opt/course/1/cert

二、解题过程

1、问题一解题

过程如下(示例):

shell 复制代码
#按要求连接对应的集群
candidate@terminal:~$ ssh cks3477                  

#切换到root用户下,防止普通用户操作写入文件没权限
candidate@cks3477:~$  sudo -i

#获取集群中所有的上下文名称,并写入到指定文件中进行记录
root@cks3477:~# kubectl config get-contexts
root@cks3477:~# kubectl config get-contexts -o name > /opt/course/1/contexts

2、问题二解题

过程如下(示例):

shell 复制代码
#按要求连接对应的集群
candidate@terminal:~$ ssh cks3477                  

#切换到root用户下,防止普通用户操作写入文件没权限
candidate@cks3477:~$  sudo -i

#获取集群中的restricted@infra-prod用户证书文件,并通过解码操作写入到指定文件中进行记录
root@cks3477:~# kubectl config view --raw 
root@cks3477:~# echo "xxx" |base64 -d >/opt/course/1/cert
相关推荐
RisunJan13 小时前
docker一键部署项目
运维·docker·容器
luyun02020214 小时前
Windows 11操作更丝滑,绝了
java·运维·figma
wanhengidc15 小时前
全面了解云手机的安全性
运维·服务器·游戏·智能手机·云计算
menge233316 小时前
Linux DNS域名解析服务器练习
linux·运维·服务器
努力成为一个程序猿.16 小时前
Clickhouse数据副本和分片
运维·clickhouse·debian
emiya_saber17 小时前
Linux 进程调度管理
linux·运维·服务器
yangzhi_emo17 小时前
配置dns主从服务
linux·运维·服务器
SongYuLong的博客18 小时前
Linux开源代码汇总
linux·运维·服务器
铭哥的编程日记18 小时前
【Linux网络】应用层协议HTTP
linux·运维·http
SakitamaX18 小时前
nginx
运维·nginx