Calling an external service from within Minikube
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 that allows developers to run a Kubernetes cluster locally on their machine. It is an excellent environment for development and testing, providing an isolated setting to deploy applications without the need for a full-fledged multi-node Kubernetes cluster. One common requirement in Kubernetes applications is to communicate with external services, whether for accessing APIs, databases, or other endpoints outside the Minikube cluster. This article will guide you through the necessary steps and considerations when calling external services from within Minikube.
Table of Contents
Overview of Minikube Networking
Minikube runs a single-node Kubernetes cluster in a virtual machine by default. This setup uses a network bridge to connect the Minikube cluster to the host machine network, providing an interface for network traffic between the cluster and external networks.
Key Networking Components:
- Minikube IP: The IP address used by the Minikube cluster, assigned by the virtual machine.
- Kubernetes Services: These are defined to expose your applications both internally within the cluster and potentially externally.
- Add-ons: Minikube supports various network-related add-ons, such as Ingress controllers, which can facilitate external access.
Accessing External Services
Public Internet Access
By default, containers running inside Minikube can access the public internet directly. This is due to the NAT (Network Address Translation) configured within the virtual machine environment, which allows outgoing traffic.
Accessing Specific Services
To call a specific external service or API from within a Minikube-deployed application, developers usually need to ensure the necessary network policies and DNS resolution are configured:
- DNS Resolution: External DNS names must resolve correctly from within the Minikube environment. This is facilitated by Kubernetes DNS services that handle the forwarding of requests.
- Network Policies: By default, no NetworkPolicy constraints are present, allowing unrestricted egress traffic. However, if your setup uses NetworkPolicies, ensure rules are defined to allow traffic to the desired external IPs or subnets.
Configuring Network Policy
If using NetworkPolicies, you can configure them as YAML resources to control the ingress and egress traffic:
- Egress
- to:
- ipBlock:
- name: auth-service
- name: OAUTH_URL
- port: 80
Related reading
- Can a Persistent Volume be resized?
- Can a PVC be bound to a specific PV?
- Can an ExternalName service point to the host machine?
- Can I access my Kubernetes Dashboard via DomainName pointing to specific server instead of localhost
- Calling redis-cli in docker-compose setup
- Can a reference to an element inside an stdmap be invalidated?
- Can a database be replicated to an EC2 instance from outside Amazon?
- Can Amazon Glacier mirror an Amazon S3 bucket?

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.