K8S控制平面组件API Server----高可用及apima
2023-06-16 本文已影响0人
青衣敖王侯
1.启动API Server示例

2.构建高可用的多副本API Server

2.1 预留充足的CPU、内存资源

2.2 善用速率限制


2.3 设置合适的缓存大小


2.4客户端尽量使用长链接
我们要优先用侦听,少用轮询,因为后台是一个分布式存储,其支持能力较弱。所以用户不要一直来轮询,导致etcd和API Server的压力过大

2.5如何访问API Server

同一个API Server有不同的访问入口,外部是从负载均衡过来的,比如F5,一个是从集群内部 KubeProxy来的。所有控制面的组件是希望用同一个访问入口,要么全用负载均衡上的VIP,要么全部用Kube-proxy提供的service-cluster IP.
3.搭建多租户的K8S集群

3.1认证

3.2授权

4.ApiMachinery
4.1 GKV回顾

K8S里面的对象有很多重要的属性,第一个就是TypeMeta,它定义了对象是什么。TypeMeta分为三类:
Group:根据对象所适应的业务场景来进行分类
Kind:这个对象真正的类型是什么,比如Pod,ConfigMap,Secret,Service,这些属于K8S的core Group.
Version:任何社区的代码都是从V1, alpha1开始的。External是针对外部客户端的请求来说的,Internal是针对集群内部来说的。外部所有的请求发到K8S的时候,K8S会在存入etcd之前,转成Internal Version.
4.1.1 如何定义Group

4.1.2 定义对象类型 types.go

List就是类似Pod这样的