【CKS最新模拟真题】Apiserver 安全

系列文章目录

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


文章目录


一、TASK

题目要求

Solve this question on: ssh cks7262

You received a list from the DevSecOps team which performed a security investigation of the cluster. The list states the following about the apiserver setup:

Accessible through a NodePort Service

Change the apiserver setup so that:

Only accessible through a ClusterIP Service

中译

在以下位置解决此问题:ssh cks7262

您收到了 DevSecOps 团队发送的列表,该团队对集群执行了安全调查。该列表说明了 apiserver 设置的以下内容:
1、可通过 NodePort 服务访问
2、更改 apiserver 设置,以便:

只能通过 ClusterIP 服务访问

二、问题解决过程

1、问题一解题

过程如下(示例):

shell 复制代码
#首先通过 ssh 进入 controlplane 节点,并检查 apiserver 进程正在使用哪些参数运行
#按要求连接对应的集群
candidate@terminal:~$ ssh cks7262

#切换到root用户下,防止普通用户操作写入文件没权限
candidate@cks7262:~$  sudo -i
root@cks7262:~# ps -ef |grep apiserver 
关注到这个 --kubernetes-service-node-port=31000

#检查 Service 并查看它的 NodePort 类型
root@cks7262:~# kubectl get svc
NAME         TYPE       CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
kubernetes   NodePort   10.96.0.1    <none>        443:31000/TCP   5d2h

#编辑apiserver.yml清单文件删除不安全的设置
root@cks7262:~# vim /etc/kubernetes/manifests/kube-apiserver.yaml
apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 192.168.100.11:6443
  creationTimestamp: null
  labels:
    component: kube-apiserver
    tier: control-plane
  name: kube-apiserver
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-apiserver
    ...
    - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
#    - --kubernetes-service-node-port=31000   # delete or set to 0
    - --proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt
    - --proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key
	...

#等待apiserver启动完成
root@cks7262:~# watch crictl ps

2、问题二解题

过程如下(示例):

shell 复制代码
#删除默认的svc,会自动创建新的svc,类型为clusterIP
root@cks7262:~# kubectl delete svc kubernetes 
相关推荐
ShirleyWang0123 天前
让headlamp控制台能访问
linux·服务器·python·k8s·k3s
spider_xcxc3 天前
K8s 部署学习笔记
docker·容器·kubernetes·云计算·k8s
ShirleyWang0123 天前
Day02 K3s NGF(Nginx Gateway Fabric)单 Worker 环境网关更新与故障处置 SOP
linux·服务器·python·k8s·k3s
ShirleyWang0123 天前
DAY01 K3s 私有化部署排障复盘与 SOP
linux·服务器·k8s·k3s·企业部署
XUHUOJUN7 天前
AKS 不是安装在 Windows Server 上,而是运行在 Windows Server 之上的 Azure 平台能力
windows·架构·k8s·azure local·azure stack
Geek-Chow7 天前
Connecting kubectl to a Private EKS Cluster Over an Internal Domain
kubernetes·k8s·aws
spider_xcxc9 天前
Docker Compose 容器通信详解:同一个 Compose 文件才能互通吗?
docker·容器·k8s·容器化·容器网络
欢醉14 天前
k8s调用服务异常cannot allocate memory
kubernetes·k8s
万里侯16 天前
GitOps 漂移检测:集群里改了配置,Git 还以为一切正常
微服务·容器·k8s
spider_xcxc18 天前
云上网络基石(阿里云):深入解读阿里云VPC及其应用生态
网络·阿里云·云计算·k8s·运维开发·虚拟化