Ingress controller pods not starting up

11/27/2019

Hello every one i have just started to try out kubernetes and cant get my ingress resource and controllers to work correctly and route external traffic to my service in the cluster. My Environment details Docker-desktop for windows kubernetes version 1.10.11 (obtained by command kubectl version) OS=windows10 64 bit

i have fetched ingress from the following link https://kubernetes.github.io/ingress-nginx/deploy/

by using these 2 commands

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud-generic.yaml

and then i have created an ingress resource such as

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
     kubernetes.io/ingress.class: nginx
  name: sample-ingress1
spec:
  rules:
  - host: mysuperbot.com
    http:
      paths:
      - path: /sampleingress
        backend:
          serviceName: tomcatappservice
          servicePort: 8082

my service resource is as follows

---
apiVersion: v1
kind: Service
metadata:
  name: tomcatappservice
  labels:
    app: tomcat-app
spec:
  ports:
    - port: 8082
      protocol: TCP
      targetPort: 8080
  selector:
    app: tomcat-app
  type: NodePort



---
apiVersion: apps/v1beta1
kind: Deployment
metadata: 
  name: tomcat-app
  labels:
    app: tomcat-app
spec:
  replicas: 5
  selector:
    matchLabels:
      app: tomcat-app
  template:
    metadata:
      labels:
        app: tomcat-app
    spec:
      containers:
        - image: tomcatapp:v1.0.0 
          name: tomcat-app
          ports:
            - containerPort: 8080

and my host file has entry

mysuperbot.com  localhost

but after all this when i try to access my service at mysuperbot.com/sampleingress i get error ERR_NAME_RESOLUTION_FAILED which leads me to believe my ingress controller isnt set up rightly so i check it with command

kubectl get pods -n ingress-nginx

and output is as follows

NAME                                        READY     STATUS    RESTARTS   AGE
nginx-ingress-controller-7d84dd6bdf-vnjx5   0/1       Pending   0          2h

which means my ingress pods arent starting up.Need help as to how can i test ingress on a local kubernetes cluster that comes with docker-desktop for windows

UPDATE

after running command

kubectl -n ingress-nginx describe pod nginx-ingress-controller-7d84dd6bdf-vnjx5

Name:           nginx-ingress-controller-7d84dd6bdf-vnjx5
Namespace:      ingress-nginx
Node:           <none>
Labels:         app.kubernetes.io/name=ingress-nginx
                app.kubernetes.io/part-of=ingress-nginx
                pod-template-hash=3840882689
Annotations:    prometheus.io/port=10254
                prometheus.io/scrape=true
Status:         Pending
IP:
Controlled By:  ReplicaSet/nginx-ingress-controller-7d84dd6bdf
Containers:
  nginx-ingress-controller:
    Image:       quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.26.1
    Ports:       80/TCP, 443/TCP
    Host Ports:  0/TCP, 0/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-7d84dd6bdf-vnjx5 (v1:metadata.name)
      POD_NAMESPACE:  ingress-nginx (v1:metadata.namespace)
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from nginx-ingress-serviceaccount-token-8md24 (ro)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  nginx-ingress-serviceaccount-token-8md24:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  nginx-ingress-serviceaccount-token-8md24
    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  14s (x583 over 3h)  default-scheduler  0/1 nodes are available: 1 node(s) didn't match node selector.
-- JayD
docker-desktop
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

11/27/2019

In your ingress controller you have the node-selector kubernetes.io/os=linux you have to edit some of your nodes /your ingress configuration to match this label.

kubectl get nodes - - show-labels
kubectl label nodes <node-name> <label-key>=<label-value>

https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/

-- iliefa
Source: StackOverflow