title: Configure Ingress Kubernetes - accessible only on single node
body: <p>I had setup ingress on my Kubernetes Cluster running on VMWAre virtual machines by following everything similar to the specifications here. All the ports are open and accessible.</p>
  
  <p><a href="https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example" rel="nofollow noreferrer">https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example</a></p>
  
  <p>My master is x.x.x.10 and nodes are x.x.x.12 and x.x.x.13. </p>
  
  <p>After the creation of ingress/controllers, I need to get the IP where the nginx-controller runs </p>
  
  <pre><code>nginx-ingress-rc-kgfmd          1/1       Running   0          21h       172.16.5.5   x.x.x.12
  </code></pre>
  
  <p>so, it usually runs either on x.x.x.12 or x.x.x.13, and then when I do this it hits my web service</p>
  
  <p>curl --resolve  master.federated.fds:80:x.x.x.12 <a href="https://master.federated.fds/coffee" rel="nofollow noreferrer">https://master.federated.fds/coffee</a></p>
  
  <p>where master.federated.fds is the DNS resolvable name of Master.</p>
  
  <p>I need to make it work without the help of IP address and only with the DNS resolvable name or else atleast with any of the node ip's </p>
  
  <p>Eg: <a href="http://node2.federated.fds/coffee" rel="nofollow noreferrer">http://node2.federated.fds/coffee</a>, when I curl this I get Connection refused error</p>
  
  <p>Updating with specifications</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: coffee-svc
    labels:
      app: coffee
  spec:
    ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      name: http
  #    nodePort: 30080
    type: NodePort
    selector:
      app: coffee
  </code></pre>
  
  <p>ingress</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: cafe-ingress
  spec:
    rules:
    - host: jciamaster.federated.fds
      http:
        paths:
        - path: /tea
          backend:
            serviceName: tea-svc
            servicePort: 80
        - path: /coffee
          backend:
            serviceName: coffee-svc
            servicePort: 80
  </code></pre>
  
  <p>nginx ing controller</p>
  
  <pre><code>    apiVersion: v1
  kind: ReplicationController
  metadata:
    name: nginx-ingress-rc
    labels:
      app: nginx-ingress
  spec:
    replicas: 1
    selector:
      app: nginx-ingress
    template:
      metadata:
        labels:
          app: nginx-ingress
      spec:
        containers:
        - image: nginxdemos/nginx-ingress:0.8.1
          imagePullPolicy: Always
          name: nginx-ingress
          ports:
          - containerPort: 80
            hostPort: 80
  </code></pre>
  
  <p>I see that the port 80 is listening only on the node where nginx pod runs and not on any other node. Could someone pls let me know how to access the application through all node ip's or thro a url like jciamaster.federated.fds?</p>
  
  <p>Thanks,</p>
  
  <p>Update:</p>
  
  <p>Tried to run with nginx controller as svc as suggested by Marc</p>
  
  <pre><code>apiVersion: v1
  kind: ReplicationController
  metadata:
    name: nginx-ingress-rc
    labels:
      app: nginx-ingress
  spec:
    replicas: 1
    selector:
      app: nginx-ingress
    template:
      metadata:
        labels:
          app: nginx-ingress
      spec:
        containers:
        - image: nginxdemos/nginx-ingress:0.8.1
          imagePullPolicy: Always
          name: nginx-ingress
          ports:
          - containerPort: 80
  
          # Uncomment the lines below to enable extensive logging and/or customization of
          # NGINX configuration with configmaps
          #args:
           #- -v=3
           #- -nginx-configmaps=default/nginx-config
  ---
  apiVersion: v1
  kind: Service
  metadata:
    labels:
      name: nginx-ingress-label
    name: nginx-ing-svc
  spec:
    ports:
     - port: 80
       targetPort: 80
       protocol: TCP
       name: http
       nodePort: 30000
    type: NodePort
    selector:
      name: nginx-ingress
  </code></pre>
  
  <p>When I hit <a href="http://x.x.x.:30000/coffee" rel="nofollow noreferrer">http://x.x.x.:30000/coffee</a> it just hangs and does nothing.Anything I am doing wrong?</p>