Kubernetes中DeploymentSpec对象的必填YAML属性有哪些?是否含指定字段?
Kubernetes DeploymentSpec 对象的必填 YAML 属性
首先要明确:你提到的 metadata、apiVersion、kind 是整个 Deployment YAML 资源的必填字段,而非 DeploymentSpec 对象本身的属性。
DeploymentSpec(即 Deployment YAML 中 spec 字段下的内容)的必填属性仅有两个:
selector:用于匹配 Deployment 管控的 Pod,其matchLabels必须与template.metadata.labels完全对应template:定义 Pod 的模板,包含 Pod 的元数据和容器配置,是生成 Pod 的核心蓝图
以下是包含完整必填项的最简 Deployment YAML 示例:
apiVersion: apps/v1 kind: Deployment metadata: name: minimal-deployment spec: selector: matchLabels: app: demo-app template: metadata: labels: app: demo-app spec: containers: - name: demo-container image: nginx:alpine
内容的提问来源于stack exchange,提问作者Happy Classics
相关产品推荐
相关产品推荐

