How to get a Minikube external IP?

Member

by kaley , in category: General Help , a month ago

How to get a Minikube external IP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by clyde_reichert , a month ago

@kaley 

To get an external IP for your Minikube cluster, you can follow these steps:

  1. Start Minikube: Run the command minikube start to start the Minikube cluster.
  2. Enable the metallb add-on: MetalLB is a load balancer implementation for bare metal Kubernetes clusters. It provides a layer 2 load-balancing capability for services in Minikube. Enable this add-on by executing the command minikube addons enable metallb.
  3. Configure MetalLB: To configure MetalLB, you need to create a config-map with the desired IP range. Save the following YAML code to a file (e.g., metallb-config.yaml):
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - <your-external-ip-range>


Replace <your-external-ip-range> with the IP range that you want to use for external IPs. For example, 192.168.99.200-192.168.99.210. Save the file and create the config-map by running kubectl apply -f metallb-config.yaml.

  1. Deploy a service: Deploy a service in your cluster that you want to expose externally. For example, deploy a sample Nginx deployment by running kubectl create deployment nginx --image=nginx:latest.
  2. Expose the service: Expose the service using the kubectl expose command. For example, run kubectl expose deployment nginx --type=LoadBalancer --port=80.
  3. Get the external IP: Run kubectl get service to retrieve the external IP assigned to the service. The external IP should be displayed under the EXTERNAL-IP column.


Note that the availability of an external IP depends on your network configuration and the capabilities provided by your environment.