Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes load balancer External IP pending

I create RabbitMQ cluster inside Kubernetes. I am trying to add loadbalancer. But I cant get the loadbalancer External-IP it is still pending.

apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  labels:
    run: rabbitmq
spec:
  type: NodePort
  ports:
  - port: 5672
    protocol: TCP
    name: mqtt
  - port: 15672
    protocol: TCP
    name: ui
  selector:
    run: rabbitmq
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq
spec:
  replicas: 1
  selector:
    matchLabels:
      run: rabbitmq
  template:
    metadata:
      labels:
        run: rabbitmq
    spec:
      containers:
      - name: rabbitmq
        image: rabbitmq:latest
        imagePullPolicy: Always

And My load balancer is below. I gave loadbalancer nodePort is random, port number is from kubernetes created RabbitMQ mqtt port number, target port number is from kubernetes created RabbitMQ UI port number

apiVersion: v1
kind: Service
metadata:
  name: loadbalanceservice
  labels:
    app: rabbitmq
spec:
  selector:
    app: rabbitmq
  type: LoadBalancer
  ports:
  - nodePort: 31022
    port: 30601
    targetPort: 31533
like image 590
newUser Avatar asked Nov 04 '25 21:11

newUser


2 Answers

service type Loadbalancer only works on cloud providers which support external load balancers.Setting the type field to LoadBalancer provisions a load balancer for your Service.It's pending because the environment that you are in is not supporting Loadbalancer type of service.In a non cloud environment an easier option would be to use nodeport type service. Here is a guide on using Nodeport to access service from outside the cluster.

like image 185
Arghya Sadhu Avatar answered Nov 06 '25 16:11

Arghya Sadhu


LoadBalancer service doesn't work on bare metal clusters. Your LoadBalancer service will act as NodePort service as well. You can use nodeIP:nodePort combination to access your service from outside the cluster.

If you do want an external IP with custom port combination to access your service, then look into metallb which implements support for LoadBalancer type services on bare metal clusters.

like image 23
Shashank V Avatar answered Nov 06 '25 15:11

Shashank V