Answers: <p>I was wrong about the <code>NodePort</code> approach. It was firewall blocking the connection to my master on ports <code>30000-32767</code>.</p>
  
  <p>After unblocking this ports everything was working fine with <code>NodePort</code> service.</p>
  
Answers: CC BY-SA 3.0
Answers: 2018-03-16T10:43:33.270Z
Answers: 2018-03-16T10:43:33.270Z
Answers: Morishiri
Body: <p>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 <code>master</code> and on some specified port.</p>
  
  <p>This cluster was created by using <code>kubeadm</code>, I have one master and 20 worker nodes.</p>
  
  <ul>
  <li>I tried to expose the service as <code>LoadBalancer</code>, but this only works when you have cloud load balancer configured. I don't have such thing and <code>EXTERNAL-IP</code> is always <code>&lt;pending&gt;</code>.</li>
  <li>I tried to expose the service as <code>NodePort</code>, but this only works on nodes where <code>pods</code> were created. So for example after rollout, when <code>pods</code> will be created on different nodes, it will stop working. Also I guess this is not load balanced properly.</li>
  <li><p>I tried to create <code>ingress</code> to make it work, but unsuccessfully.</p>
  
  <pre><code>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
  </code></pre></li>
  </ul>
  
  <p>What is the proper approach here?</p>
  
  <hr>
  
  <p>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?</p>
  
Tags: <kubernetes>
Title: Expose kubernetes deployment on master's IP
UserDisplayName: Morishiri
ThreadText: # Expose kubernetes deployment on master's IP
  
  (Asked by: username_0 on 2018-03-15)
  
  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 `<pending>`.
  * 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?
  
  **Tags:** kubernetes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-03-16. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  