华为云UCS
华为云UCS
- 最新动态
- 服务公告
- 产品介绍
- 计费说明
- 快速入门
-
用户指南
- UCS集群
- 容器舰队
- 集群联邦
- 镜像仓库
- 权限管理
-
策略中心
- 策略中心概述
- 策略定义与策略实例的基本概念
- 启用策略中心
- 创建和管理策略实例
- 示例:使用策略中心实现Kubernetes资源合规性治理
-
使用策略定义库
- 策略定义库概述
- k8spspvolumetypes
- k8spspallowedusers
- k8spspselinuxv2
- k8spspseccomp
- k8spspreadonlyrootfilesystem
- k8spspprocmount
- k8spspprivilegedcontainer
- k8spsphostnetworkingports
- k8spsphostnamespace
- k8spsphostfilesystem
- k8spspfsgroup
- k8spspforbiddensysctls
- k8spspflexvolumes
- k8spspcapabilities
- k8spspapparmor
- k8spspallowprivilegeescalationcontainer
- k8srequiredprobes
- k8srequiredlabels
- k8srequiredannotations
- k8sreplicalimits
- noupdateserviceaccount
- k8simagedigests
- k8sexternalips
- k8sdisallowedtags
- k8sdisallowanonymous
- k8srequiredresources
- k8scontainerratios
- k8scontainerrequests
- k8scontainerlimits
- k8sblockwildcardingress
- k8sblocknodeport
- k8sblockloadbalancer
- k8sblockendpointeditdefaultrole
- k8spspautomountserviceaccounttokenpod
- k8sallowedrepos
- 配置管理
- 服务网格
- 流量分发
- 可观测性
- 云原生服务中心
- 容器迁移
- 流水线
- 错误码
- 最佳实践
- API参考
- 常见问题
- 文档下载
- 通用参考
本文导读
链接复制成功!
k8srequiredprobes
作用
要求Pod具有Readiness或Liveness Probe。
策略实例示例
以下策略实例展示了策略定义生效的资源类型,parameters展示了probes的类型和probeTypes。
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: K8sRequiredProbes metadata: name: must-have-probes spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] parameters: probes: ["readinessProbe", "livenessProbe"] probeTypes: ["tcpSocket", "httpGet", "exec"]
符合策略实例的资源定义
Pod中有livenessProbe和readinessProbe,probeType为tcpSocket,符合策略实例。
apiVersion: v1 kind: Pod metadata: name: test-pod1 spec: containers: - name: tomcat image: tomcat ports: - containerPort: 8080 livenessProbe: tcpSocket: port: 80 initialDelaySeconds: 5 periodSeconds: 10 readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 5 periodSeconds: 10 volumes: - name: cache-volume emptyDir: {}
不符合策略实例的资源定义
Pod中有livenessProbe,但是没有定义probeType,不符合策略实例。
apiVersion: v1 kind: Pod metadata: name: test-pod1 spec: containers: - name: nginx-1 image: nginx:1.7.9 ports: - containerPort: 80 livenessProbe: # tcpSocket: # port: 80 # initialDelaySeconds: 5 # periodSeconds: 10 volumeMounts: - mountPath: /tmp/cache name: cache-volume - name: tomcat image: tomcat ports: - containerPort: 8080 readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 5 periodSeconds: 10 volumes: - name: cache-volume emptyDir: {}
父主题: 使用策略定义库