3

I want to know what are production alternatives to make http://192.168.49.2:30001 this accessible http://host_machine_ip:8007 here

I have set up minikube cluster with mobile-api service on it.

minikube service mobile-api-service --url this returns http://192.168.49.2:30001

curl http://192.168.49.2:30001 returns

{"mobileApi/dashboard":"http://192.168.49.2:30001/mobileApi/dashboard/",
"mobileApi/notification":"http://192.168.49.2:30001/mobileApi/notification/",
"mobileApi/feedback":"http://192.168.49.2:30001/mobileApi/feedback/"}

so my API is accessible on http://192.168.49.2:30001 from the host machine.

but i want to make it accessible http://host_machine_ip:8007.

when I do

kubectl port-forward --address 0.0.0.0 service/mobile-api-service 8007:8007

it makes http://host_machine_ip:8007 work as I want but I am sure this is not a production-like case.

Update

apiVersion: v1
kind: Service
metadata:
  name: mobile-api-service
spec:
  selector:
    app: mobile-api
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 8007
      targetPort: 8007
      nodePort: 30001

this is service it is loadBalancer

2 Answers 2

0

Either make service/mobile-api-service of LoadBalancer type or use Kubernetes Ingress to expose the workload to external connectivity. Using LoadBalancer service would be the easiest. However, your cloud provider needs to support provisioning LoadBalancers.

I described a demo of Kubernetes Ingress. The post also talks about Kubernetes Load Balancer service limitations.

To play with minikube loadbalancers use minikube tunnel command.

0

You can try and experiment with metallb and use Loadbalancer service Another option is to use node port with external Loadbalancer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.