Discussions
Categories
- 17.9K All Categories
- 3.4K Industry Applications
- 3.3K Intelligent Advisor
- 62 Insurance
- 536.1K On-Premises Infrastructure
- 138.2K Analytics Software
- 38.6K Application Development Software
- 5.7K Cloud Platform
- 109.4K Database Software
- 17.5K Enterprise Manager
- 8.8K Hardware
- 71.1K Infrastructure Software
- 105.2K Integration
- 41.6K Security Software
HOW TO: expose multiple nodeports in Kubernetes(OKE) via single public IP adress

Hello,
Is there any solution, how to expose multiple nodeports inside Kubernetes cluster via single public IP address?
Example:
prometheus nodeport: 30001
elastic nodeport: 30002
And all these nodeports will be handle by single public IP address. Then If I need to configure output for some app that needs to reach elastic I will use IP xxx.xxx.xxx.xxx:30002
Same with output for prometheus. The IP will be same xxx.xxx.xxx.xxx only nodeport will be different.
I know I can create LB for each of these but then I will have different IPs.
Is there any way how to do that?
Many thanks in advance.
Martin
Answers
-
Yes, you can create a service, but you can create it for multiple ports.
apiVersion: v1 kind: Service metadata: name: external-shared-lb annotations: oci.oraclecloud.com/load-balancer-type: "nlb" spec: type: LoadBalancer ports: - name: nodered-anexo-pv1c port: 8080 targetPort: nodered-port - name: influxdb1 port: 8081 targetPort: influxdb-port selector: lbtype: external-shared
Here I create a network loadbalancer that will receive a single IP, but it will listen to port 8080 and 8081.
In you deployment you have to name the target-ports
spec: containers: - name: influxdb1 image: *** ports: - containerPort: 8086 name: influxdb-port
So, external traffic on my loadbalancer on 8081 will be directed to the pod(s) on port 8086
-
Sorry, I forgot the lbtype tag in the selector.
The full deployment example
apiVersion: apps/v1 kind: Deployment metadata: name: influxdb1 spec: selector: matchLabels: app: influxdb1app replicas: 1 template: metadata: labels: app: influxdb1app lbtype: external-shared spec: containers: - name: influxdb1 image: **** ports: - containerPort: 8086 name: influxdb-port imagePullSecrets: - name: classified