【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
相关推荐
阿里云大数据AI技术13 小时前
阿里云 EMR AI 助手正式发布:从问答工具到全栈智能运维助手
运维·人工智能
SkyWalking中文站1 天前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
火车叼位2 天前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
小猿姐2 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
SkyWalking中文站3 天前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维
SkyWalking中文站3 天前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
雪梨酱QAQ4 天前
Kubeneters HA Cluster部署
运维
江华森4 天前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森4 天前
Matplotlib 数据绘图基础入门
运维
江华森4 天前
NumPy 数值计算基础入门
运维