<p>I'm trying to expose my api so I can send request to it. However when I used the command <code>minikube service api --url</code> I get nothing. All my pods are running fine according to <code>kubectl get pods</code> so I'm abit stuck about what this could be.</p>

<pre><code>api-1007925651-0rt1n       1/1       Running   0          26m
auth-1671920045-0f85w      1/1       Running   0          26m
blankit-app                1/1       Running   5          5d
logging-2525807854-2gfwz   1/1       Running   0          26m
mongo-1361605738-0fdq4     1/1       Running   0          26m


jwl:.build jakewlace$ kubectl get services

NAME         CLUSTER-IP   EXTERNAL-IP   PORT(S)     AGE
api          10.0.0.194   &lt;none&gt;        3001/TCP    23m
auth         10.0.0.36    &lt;none&gt;        3100/TCP    23m
kubernetes   10.0.0.1     &lt;none&gt;        443/TCP     5d
logging      10.0.0.118   &lt;none&gt;        3200/TCP    23m
mongo        10.0.0.132   &lt;none&gt;        27017/TCP   23m

jwl:.build jakewlace$
jwl:.build jakewlace$ minikube service api --url
jwl:.build jakewlace$
</code></pre>

<p>Any help would be massively appreciated, thank you.</p>

<p>I realised that the question here could be perceived as being minimal, but that is because I'm not sure what more information I could show from the tutorials I've been following it should just work. If you need more information please do let me know I will let you know. </p>

<p><strong>EDIT:</strong></p>

<p>api-service.yml</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: api
  name: api
spec:
  ports:
  - name: "3001"
    port: 3001
    targetPort: 3001
  selector:
    io.kompose.service: api
status:
  loadBalancer: {}
</code></pre>

<p>api-deployment.yml</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: api
  name: api
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: api
    spec:
      containers:
      - image: blankit/web:0.0.1
        name: api
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3001
        resources: {}
      restartPolicy: Always
status: {}
</code></pre>

<p>Your configuration is fine, but only missing one thing.</p>
<p>There are many types of <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types" rel="noreferrer">Services</a> in Kubernetes, but in this case you should know about two of them:</p>
<blockquote>
<p><em><strong>ClusterIP Services:</strong></em><br />
Exposes the service on a cluster-internal IP. Choosing this value makes the service only reachable from within the cluster. This is the default.</p>
<p><em><strong>NodePort:</strong></em><br />
Exposes the service on each Node’s IP at a static port (the NodePort). A ClusterIP service, to which the NodePort service will route, is automatically created. You’ll be able to contact the NodePort service, from outside the cluster, by requesting <code>&lt;NodeIP&gt;:&lt;NodePort&gt;</code>.</p>
</blockquote>
<p><strong>Note:</strong><br />
If you have a multi-node cluster and you've exposed a <em>NodePort Service</em>, you can access is from any other node on the same port, not necessarily the same node the pod is deployed onto.</p>
<p>So, getting back to your service, you should specify the service type in your spec:</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  ...
spec:
  type: NodePort
  selector:
    ...
  ports:
  - protocol: TCP
    port: 3001
</code></pre>
<p>Now if you <code>minikube service api --url</code>, it should return a URL like <code>http://&lt;NodeIP&gt;:&lt;NodePort&gt;</code>.</p>
<p><strong>Note:</strong> The default Kubernetes configuration will chose a random port from 30000-32767. But you can override that if needed.</p>
<hr />
<p>Useful references:</p>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="noreferrer">Kubernetes / Publishing services - service types</a></li>
<li><a href="https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/" rel="noreferrer">Kubernetes / Connect a Front End to a Back End Using a Service</a></li>
</ul>
