I need to create two instances using the same Ubuntu Image in Kubernetes. Each instance used two ports i.e. 8080 and 9090. How can I access these two ports externally? Can we use the IP address of the worker in this case?
CodePudding user response:
If you want to access your Ubuntu instances from outside the k8s cluster you should place pods behind the service.
You can access services through public IPs:
- create
Serviceof typeNodePort- theservicewill be available on<NodeIp>:<NodePort> - create
Serviceof typeLoadBalancer- if you are running your workload in the cloud creating service of typeLoadBalancerwill automatically deploy LoadBalancer for you.
Alternatively you can deploy Ingress to expose your Service. You would also need Ingress Controller.
Useful links:
