【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
相关推荐
黄毛火烧雪下4 小时前
【Ruby 】脚本和自动化语言 常用的内容
运维·自动化·ruby
小白不想白a5 小时前
【shell】每日shell练习:安全日志入侵检测/系统配置文件合规检查
运维·服务器
洛克大航海6 小时前
Linux 中新建用户
linux·运维·服务器
dehuisun6 小时前
jenkins流水线部署springboot项目
运维·jenkins
蜜蜜不吃糖7 小时前
解决Vcenter告警datastore存储容量不足问题
linux·运维·服务器
东城绝神8 小时前
《Linux运维总结:基于ARM64+X86_64架构CPU使用docker-compose一键离线部署redis 7.4.5容器版分片集群》
linux·运维·redis·架构·分片集群
迷路爸爸1808 小时前
解决GitHub SSH密钥冲突:一台电脑多账户配置
运维·ssh·github
panplan.top9 小时前
Tornado + Motor 微服务架构(Docker + 测试 + Kubernetes)
linux·python·docker·微服务·k8s·tornado
newxtc9 小时前
【浙江政务服务网-注册_登录安全分析报告】
运维·selenium·安全·政务
FJW0208149 小时前
【Linux】系统中的文件管理
linux·运维·服务器