How to connect to minikube services from outside
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
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:
- 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.
- LoadBalancer: Minikube supports a LoadBalancer-type service, but since it's primarily for cloud environments, it might require additional configurations.
- 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
NodePorttype 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.
Related reading
- how to control access for pods/exec only in kubernetes rbac without pods create binded?
- How to control Flink jobs to be distributed/load-balanced properly amongst task-managers in a cluster?
- How to copy file from container in a pod in a specific namespace?
- How to copy files from Kubernetes Pods to local system
- How to copy files from pod in one namespace to pod in another namespace
- How to copy home directory file into new persistent volume with Kubernetes?
- How to copy PVC between different storage classes?
- How to create a config map from a file in helm?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.