<p>I am trying to perform my first deployment of an application in a Kubernetes cluster in GCP.</p>

<p>I have the image of my application in Container Registration.</p>

<pre><code>eu.gcr.io/diaphanum/bonsai-landing:v1
</code></pre>

<p>The manifest file I use is deploy-ironia.yaml:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: bonsai-landing
spec:
  selector:
    matchLabels:
      app: bonsai-landing
  replicas: 3
  template:
    metadata:
      labels:
        app: bonsai-landing
spec:
  containers:
  - name: bonsai-landing
    image: "eu.gcr.io/diaphanum/bonsai-landing:v1"
    ports:
    - containerPort: 8080
</code></pre>

<p>Use the following command to deploy from the GCP shell:</p>

<pre><code>kubectl apply -f deploy-ironia.yaml
</code></pre>

<p>And I get the following error:</p>

<pre><code>error: error validating "deploy-ironia.yaml": error validating data: [ValidationError (Deployment.spec): unknown field "containers" in io.k8s.api.apps.v1.DeploymentSpec, ValidationError (Deployment.spec) : "mandatory" field selector "is missing in io.k8s.api.apps.v1.DeploymentSpec, ValidationError (Deployment.spec): the mandatory field" template "is missing in io.k8s.api.apps.v1.DeploymentSpec]; if you choose to ignore these errors, disable validation with --validate = false
</code></pre>

<p>Any suggestions to solve it?</p>

<p>UPDATE:1 </p>

<p>When run with --validate=false the message is:</p>

<pre><code>The Deployment "landing" is invalid:
* 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
</code></pre>

<p><code>deploy-ironia.yaml</code> file should be : </p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: bonsai-landing
spec:
  selector:
    matchLabels:
      app: bonsai-landing
  replicas: 3
  template:
    metadata:
      labels:
        app: bonsai-landing
    spec:
     containers:
     - name: bonsai-landing
       image: "eu.gcr.io/diaphanum/bonsai-landing:v1"
       ports:
       - containerPort: 8080
</code></pre>
