Before I had one single vm (centos 7.4, hostname kube-2.novalocal,ip 172.50.10.10
), I installed both master and kubelet in it and I could access my ingress by 172.50.10.10/uaa/login
. 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 http://172.50.10.10/uaa/login
. And it works fine.
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 http://kube-2.novalocal/uaa/login or http://kube-3.novalocal/uaa/login?
Why it restarts so frequently?
I put all related yaml files, log file, console commands output and dashboard information here.
[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
Access ingress url in kube-3.novalocal(172.50.10.4):
[centos@kube-2 ingress]$ curl http://172.50.10.4/uaa/login
curl: (7) Failed connect to 172.50.10.4:80; Connection refused
ingress-nginx logs:
[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
Dashborad images is as follows:
ingress-nginx-res.yaml
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
ingress-nginx-ctl.yaml
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
kubeadm.yaml
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
\=================================================
Ingress-nginx controller is updated to 0.16.2, same deployment as before, ingress-nginx continue restart almost every two minutes.
NAME READY STATUS RESTARTS AGE
ingress-nginx-59b74f9684-lgm2k 0/1 CrashLoopBackOff 9 20m 192.168.179.5 kube-3.novalocal
The root reason could be deployment hardware environment. With my virtualbox, there is no restart. When I use company vm based on openstack, the ingress-nginx controller always restarts.
Usage of NodePort assumes that you are able to access all your pods, so you should be able to use both the http://kube-2.novalocal/uaa/login and the http://kube-3.novalocal/uaa/login.
You can find more information about NodePort here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types "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 :."
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: https://github.com/kubernetes/ingress-nginx
Also, take a look at this article with the similar issue: https://github.com/kubernetes/ingress-nginx/issues/2450