<p>I am new to DevOps. I wrote a deployment.yaml file for a Kubernetes cluster I just created on Digital Oceans. Creating the deployment keeps bringing up errors that I can't decode for now. This is just a test deployment in preparation for the migration of my company's web apps to kubernetes. </p>

<p>I tried editing the content of the deployment to look like conventional examples I've found. I can't even get this simple example to work. You may find the deployment.yaml content below.</p>

<pre><code>---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: testit-01-deployment
spec:
  replicas: 4
  #number of replicas generated
  selector:
    #assigns labels to the pods for future selection
    matchLabels:
      app: testit
      version: v01
  template:
    metadata:
      Labels:
        app: testit
        version: v01
    spec:
      containers:
        -name: testit-container
        image: teejayfamo/testit
        ports:
          -containerPort: 80
</code></pre>

<p>I ran this line on cmd in the folder container: </p>

<p><code>kubectl apply -f deployment.yaml --validate=false</code></p>

<blockquote>
  <p>Error from server (BadRequest): error when creating "deployment.yaml":
  Deployment in version "v1" cannot be handled as a Deployment:
  v1.Deployment.Spec: v1.DeploymentSpec.Template:
  v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: decode
  slice: expect [ or n, but found {, error found in #10 byte of
  ...|tainers":{"-name":"t|..., bigger context
  ...|:"testit","version":"v01"}},"spec":{"containers":{"-name":"testit-container","image":"teejayfamo/tes|...</p>
</blockquote>

<p>I couldn't even get any information on this from my search. I can't just get the deployment created. Pls, who understands and can put me through?</p>

<p>Since this is the top result of the search, I thought I should add another case when this can occur. In my case, it was coming because there was no double quote on numeric env. var. Log did provide a subtle hint, but it was not very helpful.</p>
<p><strong>Log</strong></p>
<pre><code>..., bigger context ...|c-server-service&quot;},{&quot;name&quot;:&quot;SERVER_PORT&quot;,&quot;value&quot;:80}]
</code></pre>
<p><strong>Env variable</strong> - the value of <code>SERVER_PORT</code> needs to be in double quote.</p>
<pre><code>env:
  - name: SERVER_HOST
    value: grpc-server-service
  - name: SERVER_PORT
    value: &quot;80&quot;
</code></pre>
<p><a href="https://github.com/kubernetes/kubernetes/issues/82296" rel="noreferrer">Kubernetes issue</a> is still open.</p>
