title: How to create a Kubernetes ingress to work with SparkJava port 4567?
body: <p>I have created a Java based web service which utilizes SparkJava.  By default this web service binds and listens to port 4567.  My company requested this be placed in a Docker container.  I created a Dockerfile and created the image, and when I run I expose port 4567...</p>
  
  <pre><code>docker run -d -p 4567:4567 -t myservice
  </code></pre>
  
  <p>I can invoke my web service for testing my calling a CURL command...</p>
  
  <pre><code>curl -i -X "POST" -H "Content-Type: application/json" -d "{}" "http://localhost:4567/myservice"
  </code></pre>
  
  <p>...  and this is working.  My company then says it wants to put this in Amazon EKS Kubernetes so I publish my Docker image to the company's private Dockerhub.  I create three yaml files...</p>
  
  <ul>
  <li>deployment.yaml</li>
  <li>service.yaml</li>
  <li>ingress.yaml</li>
  </ul>
  
  <p>I see my objects are created and I can get a /bin/bash command line to my container running in Kubernetes and from there test localhost access to my service is working correctly including references to external web service resources, so I know my service is good.</p>
  
  <p>I am confused by the ingress.  I need to expose a URI to get to my service and I am not sure how this is supposed to work.  Many examples show using NGINX, but I am not using NGINX.</p>
  
  <p>Here are my files and what I have tested so far.  Any guidance is appreciated.</p>
  
  <h2>service.yaml</h2>
  
  <pre><code>kind: Service
  apiVersion: v1
  metadata:
    name: my-api-service
  spec:
    selector:
      app: my-api
    ports:
      - name: main
        protocol: TCP
        port: 4567
        targetPort: 4567
  </code></pre>
  
  <h2>deployment.yaml</h2>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: my-api-deployment
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          app: my-api
      spec:
        containers:
        - name: my-api-container
          image: hub.mycompany.net/myproject/my-api-service
          ports:
          - containerPort: 4567
  </code></pre>
  
  <h2>ingress.yaml</h2>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: my-api-ingress
  spec:
    backend:
      serviceName: my-api-service
      servicePort: 4567
  </code></pre>
  
  <p>when I run the command ...</p>
  
  <pre><code>kubectl get ingress my-api-ingress
  </code></pre>
  
  <p>... shows ...</p>
  
  <pre><code>NAME                    HOSTS   ADDRESS   PORTS   AGE
  my-api-ingress          *                 80      9s
  </code></pre>
  
  <p>when I run the command ...</p>
  
  <pre><code>kubectl get service my-api-service
  </code></pre>
  
  <p>... shows ...</p>
  
  <pre><code>NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
  my-api-service          ClusterIP   172.20.247.225   &lt;none&gt;        4567/TCP   16h
  </code></pre>
  
  <p>When I run the following command...</p>
  
  <pre><code>kubectl cluster-info
  </code></pre>
  
  <p>... I see ...</p>
  
  <pre><code>Kubernetes master is running at https://12CA0954AB5F8E1C52C3DD42A3DBE645.yl4.us-east-1.eks.amazonaws.com
  </code></pre>
  
  <p>As such I try to hit the end point using CURL by issuing...</p>
  
  <pre><code>curl -i -X "POST" -H "Content-Type: application/json" -d "{}" "http://12CA0954AB5F8E1C52C3DD42A3DBE645.yl4.us-east-1.eks.amazonaws.com:4567/myservice"
  </code></pre>
  
  <p>After some time I receive a time-out error...</p>
  
  <pre><code>curl: (7) Failed to connect to 12CA0954AB5F8E1C52C3DD42A3DBE645.yl4.us-east-1.eks.amazonaws.com port 4567: Operation timed out
  </code></pre>
  
  <p>I believe my ingress is at fault but I am having difficulties finding non-NGINX examples to compare.  </p>
  
  <p>Thoughts?</p>