minikube
kubernetes
service-access
external-connection
tutorial

How to connect to minikube services from outside

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Minikube is a popular tool for setting up a local Kubernetes cluster on your machine. By default, Minikube runs services within the local network of your machine, but there are cases where you'd want to access these services from outside of your local network. This article will guide you through the steps to connect to Minikube services from outside and offer helpful tips and techniques to facilitate this process.

Understanding Minikube Networking

Before we dive into accessing Minikube services externally, it's essential to understand how networking works in a Minikube environment:

  1. NodePort: This is the simplest way to expose a service. Minikube assigns a static port on the host machine, and services can be accessed via this port.
  2. LoadBalancer: Minikube supports a LoadBalancer-type service, but since it's primarily for cloud environments, it might require additional configurations.
  3. Ingress: Acts as an entry point for external traffic to reach the services inside the cluster. Minikube supports the ingress addon which helps set this up.

Each of these methods has its use-cases and steps to configure, as discussed below.

Exposing Minikube Services

Using NodePort

The NodePort exposes a service on a port on every node in the cluster. To expose a service using NodePort, we can modify the Kubernetes Service object:

  • protocol: TCP
  • nodePort: Assign it to NodePort type to enable external traffic.
  • port: Port on which service is exposed within the cluster.
  • targetPort: The port where your service or application listens.
    • protocol: TCP
    • host: example.minikube.local
      • path: /
  • Firewall Settings: Ensure any firewall or network security mechanisms allow traffic on the ports you're using.
  • Correct IP/Port: Always verify that you are trying to connect to the right IP address or port.
  • Minikube Status: Always check if Minikube is running with minikube status .
  • DNS Resolution: If using a domain name, ensure DNS resolution is properly set up.
  • Ingress Controllers: Besides the default NGINX Ingress controller, explore Traefik and Istio for advanced traffic routing features.
  • Security: Consider using HTTPS for secure connections using TLS certificates with Ingress.
  • Minikube Guides: Minikube documentation covers advanced scenarios such as multi-cluster management and persistent storage, which are worth exploring.

Course illustration
Course illustration

All Rights Reserved.