<p>Before I had one single vm (centos 7.4, hostname kube-2.novalocal,ip <code>172.50.10.10</code>), I installed both master and kubelet in it and I could access my ingress by <code>172.50.10.10/uaa/login</code>. Inside cluster, I use ClusterIP, and deployed ingress nginx as NodePort on ingress. Since it is redirect/rewrite, so I changed nodeport as 80 by avoiding port omitted. The service url is <code>http://172.50.10.10/uaa/login</code>. And it works fine.</p>

<p>Now I adding two nodes (kube-1.novalocal/172.50.10.1 and kube-3.novalocal/172.50.10.4). I could see ingress is deployed by kubernetes on kube-3.novalocal. And it restarts frequently, it restarts almost every minute. And I do not know ingress service url either. Is it <code>http://kube-2.novalocal/uaa/login or http://kube-3.novalocal/uaa/login?</code> Why it restarts so frequently?</p>

<p>I put all related yaml files, log file, console commands output and dashboard information here.</p>

<pre><code>[centos@kube-2 ingress]$ sudo kubectl get po
NAME                                     READY     STATUS    RESTARTS   AGE
gearbox-rack-api-gateway                 1/1       Running   0          15h
gearbox-rack-config-server               1/1       Running   0          15h
gearbox-rack-eureka-server               1/1       Running   0          15h
gearbox-rack-rabbitmq                    1/1       Running   0          15h
gearbox-rack-redis                       1/1       Running   0          15h
gearbox-rack-uaa-service                 1/1       Running   0          15h
gearbox-rack-zipkin-server               1/1       Running   0          15h
ingress-nginx-5c6d78668c-brlsv           1/1       Running   279        15h
nginx-default-backend-6647766887-nbwhl   1/1       Running   0          15h
</code></pre>

<p>Access ingress url in kube-3.novalocal(172.50.10.4):</p>

<pre><code>[centos@kube-2 ingress]$ curl http://172.50.10.4/uaa/login
curl: (7) Failed connect to 172.50.10.4:80; Connection refused
</code></pre>

<p>ingress-nginx logs:</p>

<pre><code>[centos@kube-2 ingress]$ sudo kubectl logs ingress-nginx-5c6d78668c-frb2r
-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:    0.15.0
  Build:      git-df61bd7
  Repository: https://github.com/kubernetes/ingress-nginx
-------------------------------------------------------------------------------
W0703 02:16:35.966965       7 client_config.go:533] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0703 02:16:35.967483       7 main.go:158] Creating API client for https://10.96.0.1:443
</code></pre>

<p>Dashborad images is as follows:</p>

<p><a href="https://i.stack.imgur.com/vqif2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vqif2.jpg" alt="enter image description here"></a></p>

<p>ingress-nginx-res.yaml</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
   - host:
     http:
       paths:
       - path: /
         backend:
           serviceName: gearbox-rack-api-gateway
           servicePort: 5555
</code></pre>

<p>ingress-nginx-ctl.yaml</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
spec:
  type: NodePort
  selector:
    app: ingress-nginx
  ports:
  - name: http
    port: 80
    nodePort: 80
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: ingress-nginx
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: ingress-nginx
    spec:
      terminationGracePeriodSeconds: 60
      serviceAccount: lb
      containers:
      - image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.15.0
        name: ingress-nginx
        imagePullPolicy: Always
        ports:
          - name: http
            containerPort: 80
            protocol: TCP
          - name: https
            containerPort: 443
            protocol: TCP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
          initialDelaySeconds: 30
          timeoutSeconds: 5
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/nginx-default-backend 
</code></pre>

<p>kubeadm.yaml</p>

<pre><code>apiVersion: kubeadm.k8s.io/v1alpha1
kind: MasterConfiguration
apiServerExtraArgs:
  service-node-port-range: 80-32767
networking:
  podSubnet: 192.168.0.0/16
kubernetesVersion: v1.10.3
featureGates:
  CoreDNS: true
</code></pre>

<p>=================================================</p>

<h1>edition two</h1>

<p>Ingress-nginx controller is updated to 0.16.2, same deployment as before, ingress-nginx continue restart almost every two minutes.</p>

<pre><code>NAME                                     READY     STATUS           RESTARTS  AGE
ingress-nginx-59b74f9684-lgm2k           0/1       CrashLoopBackOff   9          20m       192.168.179.5   kube-3.novalocal
</code></pre>

<p><a href="https://i.stack.imgur.com/xkzV3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xkzV3.jpg" alt="enter image description here"></a></p>

<p>Usage of NodePort assumes that you are able to access all your pods, so you should be able to use both the <a href="http://kube-2.novalocal/uaa/login" rel="nofollow noreferrer">http://kube-2.novalocal/uaa/login</a>  and the <a href="http://kube-3.novalocal/uaa/login" rel="nofollow noreferrer">http://kube-3.novalocal/uaa/login</a>.</p>

<p>You can find more information about NodePort here: <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types</a>
"NodePort: Exposes the service on each Node’s IP at a static port (the NodePort). A ClusterIP service to which the NodePort service will route is automatically created. You’ll be able to contact the NodePort service from outside the cluster by requesting :."</p>

<p>Regarding your ingress-nginx frequent restarts: Try to upgrade your nginx controller to the latest version and come back with the results. You can find it here: <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx</a></p>

<p>Also, take a look at this article with the similar issue:  <a href="https://github.com/kubernetes/ingress-nginx/issues/2450" rel="nofollow noreferrer">https://github.com/kubernetes/ingress-nginx/issues/2450</a></p>
