Access Minikube Loadbalancer Service From Host Machine Access Minikube Loadbalancer Service From Host Machine kubernetes kubernetes

Access Minikube Loadbalancer Service From Host Machine


This is expected. Do note that LoadBalancer is for cloud to create external load balancer like ALP/NLP in AWS and something similar in GCP/Azure etc.

Update the service as shown here. here i assume 192.168.64.2 is your minikube ip. if not, update it with minikube ip to make it work.

kind: ServiceapiVersion: v1metadata:  name: exampleservicespec:  selector:    app: myapp  ports:  - protocol: "TCP"    # Port accessible inside cluster    port: 8081    # Port to forward to inside the pod    targetPort: 80    # Port accessible outside cluster    nodePort: 30002  type: LoadBalancer  externalIPs:  - 192.168.64.2

Now you can access your application at http://192.168.64.2:8081/


If you need to access the application at 30002, you can use it like this

    kind: Service    apiVersion: v1    metadata:      name: exampleservice    spec:      selector:        app: myapp      ports:      - protocol: "TCP"        # Port accessible inside cluster        port: 8081        # Port to forward to inside the pod        targetPort: 80        # Port accessible outside cluster        nodePort: 30002      type: NodePort

Your deployment file does not look correct to me.

delete it kubectl delete deploy/myappdeployment

use this to create again.

apiVersion: apps/v1beta1kind: Deploymentmetadata:  labels:    app: myapp  name: myappdeploymentspec:  replicas: 5  selector:    matchLabels:      app: myapp  strategy: {}  template:    metadata:      labels:        app: myapp    spec:      containers:      - image: tutum/hello-world        name: myapp        ports:        - containerPort: 80


NOTE: Minikube support LoadBalancer services(via minikube tunnel)

you can get the IP and port through which youcan access the service by running

minikube service kubia-http #to open a browser with an IP and port

OR

minikube service kubia --url #to get the IP and port in the terminal