当前位置: 首页 > news >正文

[CKS] K8S ServiceAccount Set Up

最近准备花一周的时间准备CKS考试,在准备考试中发现有一个题目关于Rolebinding的题目。

Question 1

The buffy Pod in the sunnydale namespace has a buffy-sa ServiceAccount with permissions the Pod doesn’t need. Modify the attached Role so that it only has the ability to list pods.
Then, create a new Role called watch-services-secrets that grants permission to watch, services, and secrets.
Bind the Role to the ServiceAccount with a RoleBinding called buffy-sa-watch-rb.
这段话的意思是:在 Sunnydale 命名空间中的 buffy Pod 有一个名为 buffy-sa 的 ServiceAccount,该 ServiceAccount 具有 Pod 不需要的权限。修改附加的 Role,使其只能具有列出 Pod 的能力。 然后,创建一个名为 watch-services-secrets 的新 Role,该 Role 授予观看 services 和 secrets 的权限。 使用名为 buffy-sa-watch-rb 的 RoleBinding 将该 Role 绑定到该 ServiceAccount。

Practice

修改 sunnydale下的rolebinding

先查看sunnydale下面的rolebinding然后对rolebinding进行修改

# 获取sunnydale下面的rolebinding
kubectl get rolebinding -n sunnydale
# 获取buffy-rb下面的rolebinding的serviceaccount name
kubectl describe rolebinding -n sunnydale buffy-rb

可以看到buffy-rb对应绑定的role是buffy-role

修改buffy-role

修改需要达到一下目的

  • 只能列出pod的能力
kubectl edit role buffy-role

修改成以下内容:
在这里插入图片描述

创建watch-services-secrets新的role

Tips:如果你不知道怎么创建,可以参照上面我们修改的这个yaml文件进行修改

vi watch-services-secrets.yml

在这里插入图片描述

kubectl create -f watch-services-secrets.yml

好了 现在你就讲role创建好了

Bind the role to a SA

如果你不知道怎么绑定,在考试的时候你可以参考buffy-role是怎么绑定的
在这里插入图片描述
创建新的rolebinding
在这里插入图片描述

kubectl create -f buffy-sa-watch-rb.yml

Question 2

A Pod in the cluster cannot be created properly because its ServiceAccount is misconfigured.

The Pod is meant to live in the bespin namespace. Delete the existing ServiceAccount from this namespace.
Create a new ServiceAccount called lando-sa.
Configure the Pod to use the lando-sa ServiceAccount.
Create the Pod.
这个问题的意思是在集群中的一个 Pod 无法正确创建,因为它的 ServiceAccount 配置有误。
这个 Pod 应该存在于 bespin 命名空间中。首先删除该命名空间下已存在的 ServiceAccount。 创建一个名为 lando-sa 的新的 ServiceAccount。 配置 Pod 使用 lando-sa ServiceAccount。 最后创建 Pod。

查看bespin下面的serviceaccount

kubectl get serviceaccount -n bespin

删除查找到的serviceaccount

kubectl delete serviceaccount -n bespin lando

创建新的serviceaccount lando-sa

kubectl create serviceaccount -n bespin lando-sa

创建pod(pod文件已经存在 你只需要修改serviceAccountName就可以了)在这里插入图片描述

kuebctl create -f lando.yml
http://www.lryc.cn/news/480159.html

相关文章:

  • QML:Menu详细使用方法
  • 时间复杂度和空间复杂度 part2
  • 【电机控制器】STC8H1K芯片——UART串口通信
  • STM32移植RT-Thread---时钟管理
  • Jasypt 实现 yml 配置加密
  • uniapp—android原生插件开发(2原生插件开发)
  • NLP之ASR之moonshine:moonshine的简介、安装和使用方法、案例应用之详细攻略
  • albert模型实现微信公众号虚假新闻分类
  • OceanBase 应用实践:如何处理数据空洞,降低存储空间
  • 计算机的错误计算(一百四十八)
  • MySQL记录锁、间隙锁、临键锁(Next-Key Locks)详解
  • SLM401A系列42V商业照明线性恒流芯片 线性照明调光在LED模组及灯带智能球泡灯上应用
  • 京东零售推荐系统可解释能力详解
  • 蓝桥杯 懒洋洋字符串--字符串读入
  • SDL打开YUV视频
  • 微服务架构面试内容整理-Archaius
  • 实现 Nuxt3 预览PDF文件
  • udp为什么会比tcp 有更低的延迟
  • 基于java+SpringBoot+Vue的洗衣店订单管理系统设计与实现
  • HarmonyOS-消息推送
  • 数据分析:宏基因组DESeq2差异分析筛选差异物种
  • 出海企业如何借助云计算平台实现多区域部署?
  • 硬件---1电路设计安全要点以及欧姆定律
  • Linux如何更优质调节系统性能
  • 第三十五章 Vue路由进阶之声明式导航(跳转传参)
  • python爬虫自动库DrissionPage保存网页快照mhtml/pdf/全局截图/打印机另存pdf
  • 基于毫米波雷达和TinyML的车内检测、定位与分类
  • 小E的射击训练
  • React的概念以及发展前景如何?
  • PDF生成:全面解析,C# 如何使用iTextSharp库(或其他类似库)生成PDF文档,包括如何将位图图像嵌入PDF中。