2024 CKS题库+详尽解析| 1. kube-bench 修复不安全项

目录

免费获取并激活 CKA_v1.31_模拟系统

[1.kube-bench 修复不安全项](#1.kube-bench 修复不安全项)

题目

开始操作:

1)、切换集群

2)、登录到Master节点并提权、登录到Master节点并提权)

3)、直接按照考试题目要求修改kube-apiserver.yaml、直接按照考试题目要求修改kube-apiserver.yaml)

[4)、修改 kubelet](#4)、修改 kubelet)

[5)、修改 etcd](#5)、修改 etcd)

[7)、再检查一下所有 pod](#7)、再检查一下所有 pod)

8)、退回到node01


免费获取并激活 CKA_v1.31_模拟系统

1.kube-bench 修复不安全项

题目

您必须在以下Cluster/Node上完成此考题:

Cluster Master node Worker node

CKS00101 master node01

.

设置配置环境:

candidate@node01\]$ kubectl config use-context CKS001001 . **Context** **.** 针对 kubeadm 创建的 cluster 运行 CIS 基准测试工具时,发现了多个必须立即解决的问题。 . **Task** **.** 通过配置修复所有问题并重新启动受影响的组件以确保新的设置生效。 修复针对 API 服务器发现的所有以下违规行为: 1.2.7 Ensure that the --authorization-mode argument is not set to AlwaysAllow FAIL 1.2.8 Ensure that the --authorization-mode argument includes Node FAIL 1.2.9 Ensure that the --authorization-mode argument includes RBAC FAIL 1.2.18 Ensure that the --insecure-bind-address argument is not set FAIL 修复针对 kubelet 发现的所有以下违规行为: Fix all of the following violations that were found against the kubelet: 4.2.1 Ensure that the anonymous-auth argument is set to false FAIL 4.2.2 Ensure that the --authorization-mode argument is not set to AlwaysAllow FAIL 注意:尽可能使用 Webhook 身份验证/授权。 修复针对 etcd 发现的所有以下违规行为: Fix all of the following violations that were found against etcd: 2.2 Ensure that the --client-cert-auth argument is set to true FAI

开始操作:

1)、切换集群

bash 复制代码
kubectl config use-context CKS00101

2)、登录到Master节点并提权

bash 复制代码
ssh master
sudo -i

3)、直接按照考试题目要求修改kube-apiserver.yaml

bash 复制代码
#配置文件备份
cp /etc/kubernetes/manifests/kube-apiserver.yaml /tmp

#编辑配置文件
vim /etc/kubernetes/manifests/kube-apiserver.yaml

具体修改配置如下:

bash 复制代码
#修改、添加、删除相关内容
#修改 authorization-mode,注意 Node 和 RBAC 之间的符号是英文状态的逗号,而不是点。
 - --authorization-mode=Node,RBAC

#删除 insecure-bind-address。实际考试中,有可能本来就没写这行。
 - --insecure-bind-address=0.0.0.0

4)、修改 kubelet

bash 复制代码
#查看kubelet配置文件位置
systemctl status kubelet   

CKS模拟系统截图

修改配置文件

bash 复制代码
vim /var/lib/kubelet/config.yaml

具体内容

bash 复制代码
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
  anonymous:
    enabled: false                           #将true改成false
  webhook:
    cacheTTL: 0s
    enabled: true                            #将false改成true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook                              #模式改成Webhook,注意W大写
  webhook:
    cacheAuthorizedTTL: 0s
    cacheUnauthorizedTTL: 0s

CKS模拟系统截图

5)、修改 etcd

改之前,备份一下配置文件

bash 复制代码
cp /etc/kubernetes/manifests/etcd.yaml /tmp
vim /etc/kubernetes/manifests/etcd.yaml

修改具体配置项

bash 复制代码
    - --client-cert-auth=true          #将值改为true

6)、编辑完后重新加载配置文件,并重启 kubelet

bash 复制代码
systemctl daemon-reload
systemctl restart kubelet

7)、再检查一下所有 pod

bash 复制代码
kubectl get pod -A

8)、退回到node01

bash 复制代码
exit

CKA高仿真环境简短演示视频

CKA高仿真环境简短视频演示

相关推荐
人工智能训练11 小时前
【极速部署】Ubuntu24.04+CUDA13.0 玩转 VLLM 0.15.0:预编译 Wheel 包 GPU 版安装全攻略
运维·前端·人工智能·python·ai编程·cuda·vllm
微露清风12 小时前
系统性学习Linux-第二讲-基础开发工具
linux·运维·学习
阳光九叶草LXGZXJ13 小时前
达梦数据库-学习-48-DmDrs控制台命令(同步之Manager、CPT模块)
linux·运维·数据库·sql·学习
小二李14 小时前
第11章 nestjs服务端开发:登录鉴权
运维·服务器
i建模15 小时前
如何在Arch Linux中重设忘记的root密码
linux·运维·服务器
chatexcel16 小时前
元空AI+Clawdbot:7×24 AI办公智能体新形态详解(长期上下文/自动化任务/工具粘合)
运维·人工智能·自动化
青岑CTF16 小时前
攻防世界-Ics-05-胎教版wp
开发语言·安全·web安全·网络安全·php
kida_yuan16 小时前
【Linux】运维实战笔记 — 我常用的方法与命令
linux·运维·笔记
小陈phd17 小时前
混合知识库搭建:本地Docker部署Neo4j图数据库与Milvus向量库
数据库·docker·neo4j
Wpa.wk18 小时前
容器编排 - 了解K8s(pod, deployment,service,lable等概念)
经验分享·测试工具·docker·云原生·容器·kubernetes