属于自己的网站,中山市两学一做网站,批量爆破wordpress后台密码,网站开发协同List-Watch
Kubernetes 是通过 List-Watch的机制进行每个组件的协作#xff0c;保持数据同步的#xff0c;每个组件之间的设计实现了解耦。
List-Watch机制 工作机制#xff1a;用户通过 kubectl请求给 APIServer 来建立一个 Pod。APIServer会将Pod相关元信息存入 etcd 中…List-Watch
Kubernetes 是通过 List-Watch的机制进行每个组件的协作保持数据同步的每个组件之间的设计实现了解耦。
List-Watch机制 工作机制用户通过 kubectl请求给 APIServer 来建立一个 Pod。APIServer会将Pod相关元信息存入 etcd 中待写入操作完成APIServer 即会返回确认信息至客户端。当etcd 接受创建 Pod 信息后会发送ReplicaSet事件给 APIServer。由于 Controller Manager 会监听Watch通过https的6443端口APIServer 中的事件。此时 APIServer 接受到了 Create 事件就会发送给 Controller Manager。Controller Manager 在接到 Create 事件以后调用其中的 Replication Controller 来保证 Node 上面需要创建的副本数量。在 Controller Manager 创建 Pod 副本以后APIServer 会在 etcd 中记录这个 Pod 的详细信息。之后etcd 会将创建 Pod 的信息通过事件发送给 APIServer。Scheduler 在监听WatchAPIServer它会将待调度的 Pod 按照调度算法和策略绑定到集群中 Node 上。Scheduler 调度完毕以后会更新更详细 Pod 的信息并将上面的 Pod 信息更新至 API Server由 APIServer 更新至 etcd 中保存起来。etcd 将更新成功的事件发送给 APIServerAPIServer 也开始反映此 Pod 对象的调度结果。kubelet 是在 Node 上面运行的进程它也通过 List-Watch 的方式监听Watch通过https的6443端口APIServer 发送的 Pod 更新的事件。kubelet 会尝试在当前节点上调用 Docker 启动容器并将 Pod 以及容器的结果状态回送至 APIServer。APIServer 将 Pod 状态信息存入 etcd 中。在 etcd 确认写入操作成功完成后APIServer将确认信息发送至相关的 kubelet事件将通过它被接受。 命令
指定调度节点
apiVersion: apps/v1
kind: Deployment
metadata:name: myapp
spec:replicas: 3selector:matchLabels:app: myapptemplate:metadata:labels:app: myappspec:nodeName: node01containers:- name: myappimage: soscscs/myapp:v1ports:- containerPort: 80
查看pod
kubectl get pods -o wide查看详细事件发现未经过 scheduler 调度分配
kubectl describe pod myapp-6bc58d7775-6wlpp
给 node 设置标签
kubectl get nodekubectl label nodes node01 qqq1
kubectl label nodes node02 qqq2kubectl get nodes --show-labels 修改label 的值
kubectl label nodes node02 kgca --overwrite Pod亲和性与反亲和性
节点的亲和性硬策略软策略podaffinity和满足标签的pod在同一个拓步域podAntiAffinity和满足标签的pod不在同一个拓步域
节点亲和性
pod.spec.nodeAffinity
●preferredDuringSchedulingIgnoredDuringExecution软策略
●requiredDuringSchedulingIgnoredDuringExecution硬策略
Pod 亲和性
pod.spec.affinity.podAffinity/podAntiAffinity
●preferredDuringSchedulingIgnoredDuringExecution软策略
●requiredDuringSchedulingIgnoredDuringExecution硬策略 污点和容忍
污点 节点亲和性是Pod的一种属性偏好或硬性要求它使Pod被吸引到一类特定的节点。污点则相反它使节点能够排斥一类特定的 Pod。 污点 和容忍相互配合可以用来避免 Pod 被分配到不合适的节点上。每个节点上都可以应用一个或多个 taint 这表示对于那些不能容忍这些 taint 的 Pod是不会被该节点接受的。如果将 toleration 应用于 Pod 上则表示这些 Pod 可以但不一定被调度到具有匹配污点的节点上。
使用 kubectl taint 命令可以给某个 Node 节点设置污点Node 被设置上污点之后就和 Pod 之间存在了一种相斥的关系可以让 Node 拒绝 Pod 的调度执行甚至将 Node 已经存在的 Pod 驱逐出去。
当前 taint effect 支持如下三个选项
NoSchedule表示 k8s 将不会将 Pod 调度到具有该污点的 Node 上
PreferNoSchedule表示 k8s 将尽量避免将 Pod 调度到具有该污点的 Node 上
NoExecute表示 k8s 将不会将 Pod 调度到具有该污点的 Node 上同时会将 Node 上已经存在的 Pod 驱逐出去设置污点
kubectl taint node node01 qqqvalue1:NoSchedule节点说明中查找 Taints 字段
kubectl describe node node-name去除污点
kubectl taint node node01 qqq:NoSchedule-