<p>I have a container with a backend processing application that only connects to other services, but does not expose any ports it listens to. For example in my case it connects to a JMS broker and uses the Rest API of another service. </p>

<p>I want to deploy that container along with the JMS broker and the server with the Rest API to kubernetes. Therefore I'm currently having these kubernetes API objects for the backend processing application:</p>

<pre><code>---
  kind: "Deployment"
  apiVersion: "extensions/v1beta1"
  metadata: 
    name: "foo-processing-module"
    namespace: "foo-4"
    labels: 
      foo.version: "0.0.1-SNAPSHOT"
      k8s-app: "foo-processing-module"
    annotations: 
      deployment.kubernetes.io/revision: "1"
      description: "Processing Modules App for foo"
  spec: 
    replicas: 1
    selector: 
      matchLabels: 
        foo.version: "0.0.1-SNAPSHOT"
        k8s-app: "foo-processing-module"
    template: 
      metadata: 
        name: "foo-processing-module"
        labels: 
          foo.version: "0.0.1-SNAPSHOT"
          k8s-app: "foo-processing-module"
        annotations: 
          description: "Processing Modules App for foo"
      spec: 
        containers: 
          - 
            name: "foo-processing-module"
            image: "foo/foo-processing-module-docker:0.0.1-SNAPSHOT"
            resources: {}
            terminationMessagePath: "/dev/termination-log"
            terminationMessagePolicy: "File"
            imagePullPolicy: "IfNotPresent"
            securityContext: 
              privileged: false
        restartPolicy: "Always"
        terminationGracePeriodSeconds: 30
        dnsPolicy: "ClusterFirst"
        securityContext: {}
        schedulerName: "default-scheduler"
    strategy: 
      type: "RollingUpdate"
      rollingUpdate: 
        maxUnavailable: "25%"
        maxSurge: "25%"
    revisionHistoryLimit: 10
    progressDeadlineSeconds: 600
---
  kind: "Service"
  apiVersion: "v1"
  metadata: 
    name: "foo-processing-module"
    namespace: "foo-4"
    labels: 
      foo.version: "0.0.1-SNAPSHOT"
      k8s-app: "foo-processing-module"
    annotations: 
      description: "Processing Modules App for foo"
  spec: 
    selector: 
      foo.version: "0.0.1-SNAPSHOT"
      k8s-app: "foo-processing-module"
    type: "LoadBalancer"
    sessionAffinity: "None"
    externalTrafficPolicy: "Cluster"
</code></pre>

<p>However when I use <code>kubectl create</code> I get the following error message when the above API objects should be created:</p>

<pre><code>Error from server (Invalid): error when creating "foo.yml": Service "foo-processing-module" is invalid: spec.ports: Required value
error converting YAML to JSON: yaml: line 22: did not find expected &lt;document start&gt;
</code></pre>

<p>What do I have to do to resolve the error? Is a kubernetes <code>Service</code> even the correct API object to use in this case?</p>

<p>Simply remove the entire <code>Service</code> object. Since you have an app that doesn't need to communicate via the network, you don't need a service. Think of the service as a kind of specialized load-balancer in front of an (HTTP?) API your pods expose. Since you don't have that API, you don't need it. The <code>Deployment</code> does the actual supervision of the worker pods, that is, whatever goes on in <code>foo/foo-processing-module-docker:0.0.1-SNAPSHOT</code>.</p>

<p>Also, always use <code>kubectl apply</code> and not <code>create</code> and if you want to keep track of the revisions deployed, add the <code>--record</code> option so you can access the history.</p>
