title: Creating a service for a DaemonSet
body: <p>I'm trying to reach a DaemonSet listening on port 18081 via a service but unsucessfully so far.</p>
  
  <p>The pod that was started by the DaemonSet works correctly. I can port-forward to the pod and port 18081 and talk to exposed API on the port.</p>
  
  <p>The service for the DaemonSet is configured as follows:</p>
  
  <pre><code>kind: Service
  apiVersion: v1
  metadata:
    name: monerod-service
  spec:
    selector:
      name: monerod
    ports:
    - protocol: TCP
      port: 18081
  </code></pre>
  
  <p>In the Kubernetes UI (kubectl proxy) the correct Pod is selected in the service, so the pod selectors seems to be fine.</p>
  
  <p>I can execute a ping on the pod that needs to connect to monerod-service and the correct IP is shown. But connection to the port via curl fails (same curl works in the port-forward test).</p>
  
  <p>What am I missing in the configuration. Is there a difference between DaemonSet/Deployment service creation?</p>
  
  <hr>
  
  <p>More playing around with Kubernetes</p>
  
  <p>I played around with the service and DaemonSet. I converted the DaemonSet to a "normal"
  Deployment, but the same behaviour is shown. So the behaviour has nothing to do with DaemonSets. It has to be something else with services/pods I do not understand.</p>
  
  <p>I created the service now with:</p>
  
  <pre><code>kubectl expose deployment monerod-deployment --type=ClusterIP
  </code></pre>
  
  <p>and this results in the following service:</p>
  
  <pre><code>{
    "kind": "Service",
    "apiVersion": "v1",
    "metadata": {
      "name": "monerod-deployment",
      "namespace": "default",
      "labels": {
        "app": "monerod"
      }
    },
    "spec": {
      "ports": [
        {
          "protocol": "TCP",
          "port": 18081,
          "targetPort": 18081
        }
      ],
      "selector": {
        "app": "monerod"
      },
      "clusterIP": "&lt;some-ip&gt;",
      "type": "ClusterIP",
      "sessionAffinity": "None"
    },
    "status": {
      "loadBalancer": {}
    }
  }
  </code></pre>
  
  <p>That looks pretty good. That should expose port 18081 for other services only in the cluster.</p>
  
  <p>If I execute now a</p>
  
  <pre><code>curl -X POST http://monerod-deployment:18081/json_rpc ...
  </code></pre>
  
  <p>in the pod that should talk to the monerod service this results in</p>
  
  <pre><code>port 18081: Connection refused
  </code></pre>
  
  <p>In the monerod-deployment docker container the container is exposed (with EXPOSE 18081)
  and the the deployment has the following port definition:</p>
  
  <pre><code>"ports": [
    {
      "containerPort": 18081,
      "protocol": "TCP"
    }
  ],
  </code></pre>
  
  <p>Doing a port-forward to the deployment with kubectl and executing the curl locally works perfectly fine.
  I do not understand, why the connection from the pod to the monerod-deployment cannot be established.</p>