K8s发现和负载均衡-Ingress
K8s发现和负载均衡-Ingress 基于1.25 什么是Ingress对集群中服务的外部访问进行管理的API对象,典型的访问时间是HTTP Ingress:提供了负载均衡、SSL终结和基于名称的虚拟托管 Ingress公开集群外部到集群内部的HTTP服务和HTTPS路由 Inress不会随意公开端口和协议 仅仅创建Ingress不会有效果,需要Ingress控制器 IngressSpec Ref:https://github.com/kubernetes/api/blob/f7b7ea4f0fcc6cb8c8dd42eb46a94c7e163d1b9d/networking/v1/types.go#L302 12345678910111213141516171819202122232425262728293031323334353637383940414243// IngressSpec describes the Ingress the user wishes to exist.type IngressSpec struct { // IngressCl...
K8s发现和负载均衡-Service
K8s发现和负载均衡-Service 基于1.25 什么是ServiceK8s中,Pod随时消亡,控制器Pod集合不断变化,每个服务调用者不知道发送到哪个IP,Service就是为了解决这个问题,提供了以下的能力: Pod有自己的IP Service被赋予唯一的DNS Name Service通过标签选择器选择一组Pod Service实现负载均衡,可以将请求均衡放到一组Pod ServiceSpec Ref:https://github.com/kubernetes/api/blob/f7b7ea4f0fcc6cb8c8dd42eb46a94c7e163d1b9d/core/v1/types.go#L4359 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596...
K8s工作负载-CronJob
K8s工作负载-CronJob 1.25 什么是CronJobCronJob按照预定时间计划创建Job CronJob的限制CronJob在时间计划中执行,但是Job依旧还可能失败,所以Job不是唯一的,因此Job必须是幂等的,当满足以下俩个条件,Job至少运行一次 StartingDeadlineSeconds:设置为一个较大的值,或者不设置该值(有默认值) ConcurrencyPolicy:设置为Allow 如果设置了StaringDeadlineSeconds,CronJob控制器按照从StaringDeadlineSeconds之前到现在为止的时间段计算错过的执行次数 CronJobSpec Ref:https://github.com/kubernetes/api/blob/f7b7ea4f0fcc6cb8c8dd42eb46a94c7e163d1b9d/batch/v1/types.go#L504 1234567891011121314151617181920212223242526272829303132333435363738394041424344...
K8s工作负载-Job
K8s工作负载-Job 基于1.25 什么是JobJob会创建一个或多个Pod,并持续重试Pod的执行,直至指定数量的Pod成功终止 随着Pod成功终止,Job会记录成功的Pod个数,Pod到达指定数量,Job终止 删除Job,会删除Job的所有Pod JobSpec Ref:https://github.com/kubernetes/api/blob/f7b7ea4f0fcc6cb8c8dd42eb46a94c7e163d1b9d/batch/v1/types.go#L206 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912...
K8s工作负载-DaemonSet
K8s工作负载-DaemonSet 基于1.25 什么是DaemonSetDaemonSet 控制器确保所有(或一部分)的节点都运行了一个指定的 Pod 副本,缩写DS 使用场景 在每个节点上运行集群的存储守护进程,例如 glusterd、ceph 在每个节点上运行日志收集守护进程,例如 fluentd、logstash 在每个节点上运行监控守护进程,例如 Prometheus Node Exporter (opens new window)、Sysdig Agent (opens new window)、collectd、Dynatrace OneAgent (opens new window)、APPDynamics Agent (opens new window)、Datadog agent (opens new window)、New Relic agent (opens new window)、Ganglia gmond、Instana Agent (opens new window)等 DaemonSetSpec Ref:https://github.com/ku...
K8s工作负载-StatefulSet
K8s工作负载-StatefulSet 基于1.25 什么是StatefulSetStatefulSet负责管理有状态应用,缩写sts 要求管理的Pod具有稳定的网络标识符和存储卷,实现又状态应用的数据持久化和数据访问 管理Pod,会对Pod有一个按照顺序增大的ID 使用场景 具有稳定、唯一的网络标识符(DNS Name) 每个Pod是中对应各自的存储路径(PersistVolumeClaimTempleate) 按照顺序增加副本、减少副本,并且在减少副本的时执行清理 按照顺序执行滚动更新 限制 Pod存储的要么由Storage Class的PVC提供,要么事先创建 删除或缩容一个StatefulSet不会删除对应的数据卷,确保数据安全 在删除StatefulSet,无法确保Pod的终止的正常的 如果需要,需要使用优雅的终止,需要先Scale Down到0 在使用默认的Pod Management Policy(OraderReady)进行滚动更新,可能会进入到错误状态,需要人工介入 ⚠️:不要时强制删除StatefulSet管理的Pod,本身机制,只会最多提供一...
K8s工作负载-ReplicaSet
K8s工作负载-ReplicaSet 基于1.25 什么是ReplicaSetReplicaSet的为指定Pod维护一个副本数量的集合,缩写RS 一般新版本,用户不直接操作RS 通过Deployment的生命周期,来管理RS ReplicaSetSpec Ref:https://github.com/kubernetes/kubernetes/blob/88e994f6bf8fc88114c5b733e09afea339bea66d/pkg/apis/apps/types.go#L818 1234567891011121314151617181920212223242526272829// ReplicaSetSpec is the specification of a ReplicaSet.// As the internal representation of a ReplicaSet, it must have// a Template set.type ReplicaSetSpec struct { // Replicas is the number o...
K8s工作负载-Deployment
K8s工作负载-Deployment 基于1.25 什么是DeploymentDeployment 最常见就是部署无状服务,缩写Deploy Deployment实现声明的方法控制Pod和ReplicaSet 支持滚定升级和回滚应用 支持扩容和缩容 暂停和继续Deployment DeploymentSpec Ref:https://github.com/kubernetes/api/blob/271c79cac830e76e5e563330b3ec60d46948464e/apps/v1/types.go#L377 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455// DeploymentSpec is the specification of the desired behavior of the Deployment.type DeploymentSpec struct { // Number of de...
K8s核心资源对象-Pod(状态以及原地升级)
K8s核心资源对象-Pod(状态以及原地升级) 基于1.25 Pod的PodStatus Ref:https://github.com/kubernetes/kubernetes/blob/88e994f6bf8fc88114c5b733e09afea339bea66d/pkg/apis/core/types.go#L3365 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061// PodStatus represents information about the status of a pod. Status may trail the actual// state of a system.type PodStatus struct { // +optional // Pod生命周期,包含Pending、Running、Succeeded、Failed和Unknown Phase Pod...
K8s核心资源对象-Pod(健康检查)
K8s核心资源对象-Pod(健康检查) 基于1.25 什么是健康检查K8s支持三种健康检查: livenessProbe:存活探针 表示容器是否在运行,是否需要重启 如果liveness探测为Failure,kubelete会终止容器,按照策略重启 readinessProbe:就绪探针 表示容器是准备好接受请求 如果readiness探测失败,从Endpoint控制器种移除改PodIP startupProbe:启动探针 设置了启动探针,其他的被暂时禁用,直至启动探针成功 启动探针失败,按照策略重启 对于启动时间长的场景 ProbeManagerProbeManager负责管理Pod探针,是一个Manager的接口声明。 当执行AddPod func,会为Pod每一个容器创建一个探测的worker worker会对分配的容器,定期周期性探测,并且缓存探测结果 执行UpdatePodStatus func,Manager会使用缓存结果把PodStatus设置类似Ready状态 相关接口说明: AddPod:为Pod每个容器添加对应的探测worker Sto...


