Answers: <p>Sure enough, everything and including the last <code>spec:</code> needed to be tabbed to the left once:</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: client-deployment
  spec:
    replicas: 3
    selector:
      matchLabels:
        component: web
    template:
      metadata:
        labels:
          component: web
      spec:
        containers:
          - name: client
            image: ldco2016/multi-client
            ports:
              - containerPort: 3000
  </code></pre>
  
  <p>Unfortunately, you can't tell the difference with how <code>yaml</code> is formatted when pasted here, so it would not have been an easy catch, but if you would be looking at the original file configuration you would have noticed it like I did when I looked a third time.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-03-26T01:50:51.830Z
Answers: 2019-03-26T01:50:51.830Z
Answers: Daniel
Body: <p>I know that <code>yml</code> files are temperamental and I still struggle to figure it out. Can anyone help out here to understand what is it about my <code>client-deployment.yml</code> file that makes Kubernetes want to issue the above error?</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: client-deployment
  spec:
    replicas: 1
    selector:
      matchLabels:
        component: web
    template:
      metadata:
        labels:
          component: web
      spec:
        containers:
          - name: client
            image: ldco2016/multi-client:v1.2
            ports:
              - containerPort: 3000
  </code></pre>
  
  <p>I got the above error running <code>kubectl apply -f k8s</code></p>
  
  <p><code>k8s</code> being one of the folders in the project with the <code>yml</code> configuration files.</p>
  
Tags: <kubernetes><yaml>
Title: error validating data: ValidationError(Deployment): unknown field "spec" in
UserDisplayName: Daniel
ThreadText: # error validating data: ValidationError(Deployment): unknown field "spec" in
  
  (Asked by: username_0 on 2019-03-26)
  
  I know that `yml` files are temperamental and I still struggle to figure it out. Can anyone help out here to understand what is it about my `client-deployment.yml` file that makes Kubernetes want to issue the above error?
  
  ```
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: client-deployment
  spec:
    replicas: 1
    selector:
      matchLabels:
        component: web
    template:
      metadata:
        labels:
          component: web
      spec:
        containers:
          - name: client
            image: ldco2016/multi-client:v1.2
            ports:
              - containerPort: 3000
  
  ```
  
  I got the above error running `kubectl apply -f k8s`
  
  `k8s` being one of the folders in the project with the `yml` configuration files.
  
  **Tags:** kubernetes, yaml
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-03-26. Score: 3 | Accepted answer
  
  Sure enough, everything and including the last `spec:` needed to be tabbed to the left once:
  
  ```
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: client-deployment
  spec:
    replicas: 3
    selector:
      matchLabels:
        component: web
    template:
      metadata:
        labels:
          component: web
      spec:
        containers:
          - name: client
            image: ldco2016/multi-client
            ports:
              - containerPort: 3000
  
  ```
  
  Unfortunately, you can't tell the difference with how `yaml` is formatted when pasted here, so it would not have been an easy catch, but if you would be looking at the original file configuration you would have noticed it like I did when I looked a third time.
  
  
  ---
  
  