HiveBrain v1.2.0
Get Started
← Back to all entries
patternkubernetesMinor

Expose kubernetes deployment on master's IP

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
kubernetesexposemasterdeployment

Problem

I have simple deployment which has 3 replicas. I want this deployment to be load balanced between this 3 replicas, but available under IP of my master and on some specified port.

This cluster was created by using kubeadm, I have one master and 20 worker nodes.

  • I tried to expose the service as LoadBalancer, but this only works when you have cloud load balancer configured. I don't have such thing and EXTERNAL-IP is always `.



  • I tried to expose the service as NodePort, but this only works on nodes where pods were created. So for example after rollout, when pods will be created on different nodes, it will stop working. Also I guess this is not load balanced properly.



-
I tried to create
ingress` to make it work, but unsuccessfully.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: registry-ingress
  namespace: registry
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
    paths:
      - path: /registry
        backend:
          serviceName: registry-service
          servicePort: 5000


What is the proper approach here?

If the above is possible then second question: is it possible to expose it on 2 masters if I will want to create 2nd one?

Solution

I was wrong about the NodePort approach. It was firewall blocking the connection to my master on ports 30000-32767.

After unblocking this ports everything was working fine with NodePort service.

Context

StackExchange DevOps Q#3638, answer score: 1

Revisions (0)

No revisions yet.