Kubernetes 部署失败并出现错误

Kubernetes 部署失败并出现错误
  • Kubernetes 版本:1.16
  • 操作系统:托管在 Google Cloud 上的 CentOS7

尝试使用以下清单文件在主节点上运行部署:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
  namespace: deployment-demo
  annotations:
    monitoring: "true"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        ports:
        - containerPort: 80
        resources:
          limits:
            memory: "2Gi"
            cpu: "1000m"
          requests: 
            memory: "1Gi"
            cpu: "500m"

并引发以下错误:

**[root@kubemaster deployment-demo]# kubectl create -f nginx-deploy.yaml --validate=false
The Deployment "" is invalid:
* metadata.name: Required value: name or generateName is required
* spec.selector: Required value
* spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` 
   does not match template `labels`
* spec.template.spec.containers: Required value**

请告知我这里遗漏了什么。

相关内容