<p>I have a docker image, that contains a python file that accepts arguments from command line using sys.stdin(). I can run the image using the following command</p>

<blockquote>
  <p>cat file.csv | docker run -i -t my_image</p>
</blockquote>

<p>It pipes the contents of file.csv to the image, and i get the output as expected.</p>

<p>Now i want to deploy this image to kubernetes. I can run the image on the server using docker without any problems. But if i curl to it, it should send a response back, but i am not getting it because i do not have a web server listening on any port. I went ahead and built a deployment using the following command.</p>

<blockquote>
  <p>kubectl run -i my_deployment --image=gcr.io/${PROJECT_ID}/my_image:v1 --port 8080</p>
</blockquote>

<p>It built the deployment and i can see the pods running. Then i expose it.</p>

<blockquote>
  <p>kubectl expose deployment my_deployment --type=LoadBalancer --port 80 --target-port 8080</p>
</blockquote>

<p>But if i try to access it using the IP assigned using curl,</p>

<blockquote>
  <p>curl <a href="http://allocated_ip" rel="nofollow noreferrer">http://allocated_ip</a></p>
</blockquote>

<p>i get a response "connection refused".</p>

<p>How can deploy this docker image as a service on kubernetes and send contents of a file as an input to the service? Do i need a web server for that?</p>

sid0972
<p>I am assuming Kubernetes is running on premises. I would do the following.</p>

<ul>
<li>Create a nginx or apache deployment. Using Helm, it is pretty easy with </li>
</ul>

<blockquote>
  <p>helm install stable/nginx-ingress</p>
</blockquote>

<ul>
<li><p>Create a deployment with the port 8080, or whatever you would expose from running it from with docker. The actual deployment would have an API which I could send content via a POST.</p></li>
<li><p>Create a service with port 8080 and targetPort 8080. It should be type ClusterIP.</p></li>
<li><p>Create a ingress with the hostname, and servicePort of 8080.</p></li>
</ul>
