skip to Main Content

I am learning Kubernetes and trying to deploy an app using MiniKube.

I have managed to expose the service mapped to nginx pod on Minikube IP. I can access the nginx service on url $(minikube ip):$(serviceport). which is fine, however I am looking to expose this to the public network. Currently this service is only accessible via my local machine, any other machine on my wifi network is not able to access it as it is exposed only on minikube ip. I dont want to forward the port in my local linux via IPtables, and I am looking for a built in solution to expose the port to world (and not just on minikube ip). I know it can be achieved as minikube dashboard by default expose the service on localhost, this implies that minikube can talk to other network adapters and can register the port, I am not sure how.

Here is my service yaml:

apiVersion: v1
kind: Service
metadata:
  annotations:
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
  name: nginxservice
  labels:
    app: nginxservice
spec:
  type: NodePort
  ports:
  - port: 80
    name: http
    targetPort: 80
    nodePort: 32756
  selector:
    app: nginxcontainer

2

Answers


  1. You have to create ingress.
    Follow the steps in this doc – https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/

    Login or Signup to reply.
  2. @subudear is right – you need Ingress.

    An API object that manages external access to the services in a
    cluster, typically HTTP. Ingress may provide load balancing, SSL
    termination and name-based virtual hosting.

    Ingress exposes HTTP and
    HTTPS routes from outside the cluster to services within the cluster.
    Traffic routing is controlled by rules defined on the Ingress
    resource.

    enter image description here

    To be able use regularly use ingress(Im not talking about minikube right now) – it is not enough simply create Ingress object. You should first install related ingress controller.

    There are lot of them, most popular are:

    First 2 are very similar, but use absolutely different annotations. It often happens people confuse them


    Talking about minikube:
    As per guidelines, in order to install ingress the only you have to do is

    minikube addons enable ingress

    Please note that by default, minikube installing exactly NGINX Ingress controller

    nginx-ingress-controller-5984b97644-rnkrg 1/1 Running 0 1m

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search