<p>I built an application using Docker Compose which included an Nginx instance accepting connections on port 80:</p>

<pre><code>  nginx:
    image: nginx:1.15.12-alpine
    container_name: nginx
    volumes:
      - etc.
    ports:
      - 80:80
</code></pre>

<p>I'd like to spin up this application on Kubernetes running on my local machine (macOS). So I've run <code>kompose convert</code>, <a href="https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/#kompose-convert" rel="nofollow noreferrer">documented here</a>.</p>

<p>This generated <code>nginx-service.yaml</code> which looks like this:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.18.0 ()
  creationTimestamp: null
  labels:
    io.kompose.service: nginx
  name: nginx
spec:
  ports:
  - name: "80"
    port: 80
    targetPort: 80
  selector:
    io.kompose.service: nginx
status:
  loadBalancer: {}
</code></pre>

<p>I ran <code>kubectl apply</code> with all of the YAML files produced by <code>kompose</code>, and then <code>kubectl describe svc nginx</code>:</p>

<pre><code>Name:              nginx
Namespace:         myproject
Labels:            io.kompose.service=nginx
Annotations:       kompose.cmd=kompose convert
                   kompose.version=1.18.0 ()
                   kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"kompose.cmd":"kompose convert","kompose.version":"1.18.0 ()"},"creationTimestamp":null,...
Selector:          io.kompose.service=nginx
Type:              ClusterIP
IP:                172.30.110.242
Port:              80  80/TCP
TargetPort:        80/TCP
Endpoints:         
Session Affinity:  None
Events:            &lt;none&gt;
</code></pre>

<p>However, I cannot access the web server by navigating to <code>http://172.30.110.242:80</code> on the same machine.</p>

<p>There is documentation on <a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-services/" rel="nofollow noreferrer">accessing services running on clusters</a>. I'm new to k8s and I'm not sure how to diagnose the problem and pick the right solution of the options they list.</p>

<p>Is it a defect in <code>kompose</code> that it did not generate a comparable service config file? </p>

<p>See:</p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport</a></p>

<p>Your "connect to" URL from your local machine to a K8 world will not be "172.x.x.x".  It will probably be 192.168.99.100:33333  (port number wil be different).. run this:  </p>

<p><code>minikube service myservicename  -n "default" --url</code>      </p>

<p>see what that gives you</p>

<p>but basically, you need to "expose" the k8 world to the outside world.</p>

<p>this yml should help</p>

<pre><code>apiVersion: v1
kind: Service
metadata: 
  name: myservicename
  namespace: mycustomnamespace
  labels: 
    name: myservicemetadatalabel
spec: 
  type: NodePort
  ports:
  - name: myfirstportname
    port: 80
    targetPort: 80    
  selector: 
    myexamplelabelone: mylabelonevalue
    myexamplelabeltwo: mylabeltwovalue
</code></pre>

<p>the selector will refer to your pod/container setup.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: myfirstpodmetadataname
  namespace: mycustomnamespace
  labels:
    myexamplelabelone: mylabelonevalue
    myexamplelabeltwo: mylabeltwovalue
</code></pre>

<p>"selectors" is outside scope of this question...but the above will give you the breadcrumb you need</p>

<p>also see:</p>

<p><a href="https://stackoverflow.com/questions/48361841/how-to-expose-k8-pods-to-the-public-internet/48366206#48366206">How to expose k8 pods to the public internet?</a></p>
