Kubernetes: Expose multiple services internally & externally

10/14/2020

Am using AKS for my cluster

Scenario: We have multiple API's (say svc1, svc2 & svc3 accessible on port 101, 102, 103). These API links need to be exposed to client and are also used internally in application.

Question: I want to expose this to both external & internal load balancer on same ports. Also when i access the service internally, i want them to be accessible by service name (Example: svc1:101)

-- Sunil Agarwal
azure-aks
kubernetes

2 Answers

11/12/2020

Well, I was able to fix the issue without using NodePort/ClusterIP.

Solution is pretty simple but seems its not documented.

Only thing we have to do is have multiple tags where 1 tag is same as of external load balancer and other tag you have same matching service.

This will map your replicaset to both service & external loadbalancer.

Detailed answer available on - https://www.linkedin.com/pulse/exposing-multiple-portsservices-same-load-balancer-sunil-agarwal

-- Sunil Agarwal
Source: StackOverflow

10/14/2020

In Kubernetes:

  • if you want to expose something internally only, you should use ClusterIP service type
  • if you want to expose both internally & externally, use LoadBalancer (or NodePort) service type.

Please check Kubernetes: Service Types for more details.

-- RafaƂ Leszko
Source: StackOverflow