2
  • Kubernetes Version: 1.16
  • OS: CentOS7 hosted on Google Cloud

Tried to run a deployment on master node with the following manifest file:

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"

And it trowed the following error:

**[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**

Please advise regarding what I am missing here.

  • I tried to kubectl apply your config and everything worked as expected. Can you check your kubectl version to see if the client/master version is in compliance with the version skew policy? You can also try your kubectl apply again with the -v=10 flag to get some debug information. – Eduardo Baitello Oct 15 '19 at 01:39

0 Answers0