<p>I have tried to deploy the <code>producer-service</code> app with MySQL database in the Kubernetes cluster. When i try to deploy <code>producer app</code> then the following validation error has thrown.</p>
<pre><code>error: error validating &quot;producer-deployment.yml&quot;: error validating data: apiVersion not set; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>
<p><strong>producer-deployment.yml</strong></p>
<pre><code>apiVerion: v1
kind: Service
metadata:
  name: producer-app
  labels:
    name: producer-app
spec:
  ports:
    -nodePort: 30163
    port: 9090
    targetPort: 9090
    protocol: TCP
  selector:
    app: producer-app
  type: NodePort

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: producer-app
spec:
  selector:
    matchLabels:
      app: producer-app
  replicas: 3
  template:
    metadata:
      labels:
        app: producer-app
    spec:
      containers:
        - name: producer
          image: producer:1.0
          ports:
            - containerPort: 9090
          env:
            - name: DB_HOST
              valueFrom:
               configMapKeyRef:
                name: db-config
                key: host
            - name: DB_NAME
              valueFrom:
               configMapKeyRef:
                name: db-config
                key: name
            - name: DB_USERNAME
              valueFrom:
               secretKeyRef:
                name: db-user
                key: username
            - name: DB_PASSWORD
              valueFrom:
               secretKeyRef:
                name: db-user
                key: password
</code></pre>
<p>i have tried to find the error or typo within the config file but still, couldn't. What is wrong with the <code>producer-deployment.yml</code> file</p>

Nafaz M N M
<p>Multiple issues:</p>
<ol>
<li><p>It would be <code>apiVersion: v1</code> not <code>apiVerion: v1</code> in the <code>Service</code></p>
</li>
<li><p>wrong <code>Spec.ports</code> formation of <code>Service</code>. As <code>nodePort</code>, <code>port</code>, <code>targetPort</code> and  <code>protocol</code> are under the <code>ports</code> as a list but your did wrong formation.</p>
</li>
</ol>
<p>your service yaml should be like below:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: producer-app
  labels:
    name: producer-app
spec:
  ports:
    - nodePort: 30163
      port: 9090
      targetPort: 9090
      protocol: TCP
  selector:
    app: producer-app
  type: NodePort
</code></pre>
<p>So your overall <code>yaml</code> should be:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: producer-app
  labels:
    name: producer-app
spec:
  ports:
    - nodePort: 30163
      port: 9090
      targetPort: 9090
      protocol: TCP
  selector:
    app: producer-app
  type: NodePort

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: producer-app
spec:
  selector:
    matchLabels:
      app: producer-app
  replicas: 3
  template:
    metadata:
      labels:
        app: producer-app
    spec:
      containers:
        - name: producer
          image: producer:1.0
          ports:
            - containerPort: 9090
          env:
            - name: DB_HOST
              valueFrom:
                configMapKeyRef:
                  name: db-config
                  key: host
            - name: DB_NAME
              valueFrom:
                configMapKeyRef:
                  name: db-config
                  key: name
            - name: DB_USERNAME
              valueFrom:
                secretKeyRef:
                  name: db-user
                  key: username
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-user
                  key: password
</code></pre>
