k8s安装ingress报错:Warning FailedScheduling 29s (x2 over 29s) default-scheduler 0/3 nodes are ava...

1、今天安装ingress的时候,设置启动了两个pod,但有一个pod总是启动失败

[root@k8s-master Ingress]# kubectl get pods -n ingress-nginx -o wide

NAME                                        READY   STATUS    RESTARTS   AGE     IP               NODE        NOMINATED NODE   READINESS GATES

nginx-ingress-controller-6dcc964795-jwscf   1/1     Running   0          5m52s   192.168.10.254   k8s-node1              

nginx-ingress-controller-6dcc964795-xkzsj   0/1     Pending   0          10s                                 

2、让我们来分析一下是什么原因,查看结果显示,一个node已经没有端口可以使用,另两个设置了污点

[root@k8s-master Ingress]# kubectl describe pod nginx-ingress-controller-6dcc964795-xkzsj -n ingress-nginx

Name:           nginx-ingress-controller-6dcc964795-xkzsj

Namespace:      ingress-nginx

Priority:       0

Node:           

Labels:         app.kubernetes.io/name=ingress-nginx

                app.kubernetes.io/part-of=ingress-nginx

                pod-template-hash=6dcc964795

Annotations:    prometheus.io/port: 10254

                prometheus.io/scrape: true

Status:         Pending

IP:             

Controlled By:  ReplicaSet/nginx-ingress-controller-6dcc964795

Containers:

  nginx-ingress-controller:

    Image:       registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:0.26.1

    Ports:       80/TCP, 443/TCP

    Host Ports:  80/TCP, 443/TCP

    Args:

      /nginx-ingress-controller

      --configmap=$(POD_NAMESPACE)/nginx-configuration

      --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services

      --udp-services-configmap=$(POD_NAMESPACE)/udp-services

      --publish-service=$(POD_NAMESPACE)/ingress-nginx

      --annotations-prefix=nginx.ingress.kubernetes.io

    Liveness:   http-get http://:10254/healthz delay=10s timeout=10s period=10s #success=1 #failure=3

    Readiness:  http-get http://:10254/healthz delay=0s timeout=10s period=10s #success=1 #failure=3

    Environment:

      POD_NAME:       nginx-ingress-controller-6dcc964795-xkzsj (v1:metadata.name)

      POD_NAMESPACE:  ingress-nginx (v1:metadata.namespace)

    Mounts:

      /var/run/secrets/kubernetes.io/serviceaccount from nginx-ingress-serviceaccount-token-bflxd (ro)

Conditions:

  Type           Status

  PodScheduled   False

Volumes:

  nginx-ingress-serviceaccount-token-bflxd:

    Type:        Secret (a volume populated by a Secret)

    SecretName:  nginx-ingress-serviceaccount-token-bflxd

    Optional:    false

QoS Class:       BestEffort

Node-Selectors:  kubernetes.io/os=linux

Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s

                 node.kubernetes.io/unreachable:NoExecute for 300s

Events:

  Type     Reason            Age                From               Message

  ----     ------            ----               ----               -------

  Warning  FailedScheduling  29s (x2 over 29s)  default-scheduler  0/3 nodes are available: 1 node(s) didn't have free ports for the requested pod ports, 2 node(s) had taints that the pod didn't tolerate.

3:我们来检查一下,查看node是否被打污点

[root@k8s-master Ingress]# kubectl describe nodes | grep Tain

Taints:             node-role.kubernetes.io/master:NoSchedule

Taints:             

Taints:             web=no:NoExecute

果不其然,之前打的污点忘记取消掉了

4:让我们去掉污点

[root@k8s-master Ingress]# kubectl taint nodes k8s-node2 web=no:NoExecute-

node/k8s-node2 untainted
[root@k8s-master Ingress]# kubectl describe nodes | grep Tain

Taints:             node-role.kubernetes.io/master:NoSchedule

Taints:             

Taints:             

5:验证结果

[root@k8s-master Ingress]# kubectl get pods -n ingress-nginx

NAME                                        READY   STATUS    RESTARTS   AGE

nginx-ingress-controller-6dcc964795-jwscf   1/1     Running   0          8m34s

nginx-ingress-controller-6dcc964795-xkzsj   1/1     Running   0          2m52s