Setting up Ingress (Kubernetes)

4/26/2018

I want to set up an Ingress, which routes traffic to my underlying Services. Unfortunately, I get an error when I deploy my ingress-controller-deployment.yaml and I don't know why... The pod with the ingress-controller crashes immediately, with the error message "CrashLoopBackOff".

With my understanding the Ingress-Control has to be deployed in a Pod and this pod can be accessed through the ingress-svc. The ingress-svc seems to work, but the Pod crashes. After the ingress-controller works I need an additional file that defines the routes and everything. But I don't see the point of continuing with out a working and deployable ingress-controller.


Pod description:

    Name:           ingress-controller-7749c785f-x94ll
    Namespace:      ingress
    Node:           gke-cluster-1-default-pool-8484e77d-r4wp/10.128.0.2
    Start Time:     Thu, 26 Apr 2018 14:25:04 +0200
    Labels:         k8s-app=nginx-ingress-lb
                    pod-template-hash=330573419
    Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"ingress","name":"ingress-controller-7749c785f","uid":"d8ff0a6d-494c-11e8-a840
    -420...
    Status:         Running
    IP:             10.8.0.14
    Created By:     ReplicaSet/ingress-controller-7749c785f
    Controlled By:  ReplicaSet/ingress-controller-7749c785f
    Containers:
      nginx-ingress-controller:
        Container ID:  docker://5654c7dffc44510132cba303d66ee570280f2cec235e4d4fa6ef8ad543e0c91d
        Image:         quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0
        Image ID:      docker-pullable://quay.io/kubernetes-ingress-controller/nginx-ingress-controller@sha256:39cc6ce23e5bcdf8aa78bc28bbcfe0999e449bf99fe2e8d60984b417facc5cd4
        Ports:         80/TCP, 443/TCP
        Args:
          /nginx-ingress-controller
          --admin-backend-svc=$(POD_NAMESPACE)/admin-backend
        State:          Waiting
          Reason:       CrashLoopBackOff
        Last State:     Terminated
          Reason:       Error
          Exit Code:    2
          Started:      Thu, 26 Apr 2018 14:26:57 +0200
          Finished:     Thu, 26 Apr 2018 14:26:57 +0200
        Ready:          False
        Restart Count:  4
        Liveness:       http-get http://:10254/healthz delay=10s timeout=5s period=10s #success=1 #failure=3
        Environment:
          POD_NAME:       ingress-controller-7749c785f-x94ll (v1:metadata.name)
          POD_NAMESPACE:  ingress (v1:metadata.namespace)
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-plbss (ro)
    Conditions:
      Type           Status
      Initialized    True
      Ready          False
      PodScheduled   True
    Volumes:
      default-token-plbss:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-plbss
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations: node.alpha.kubernetes.io/notReady:NoExecute for 300s
node.alpha.kubernetes.io/unreachable:NoExecute for 300s

Ingress-controller-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ingress-controller
spec:
  replicas: 1
  revisionHistoryLimit: 3
  template:
    metadata:
      labels:
        k8s-app: nginx-ingress-lb
    spec:
      containers:
        - args:
            - /nginx-ingress-controller
            - "--admin-backend-svc=$(POD_NAMESPACE)/admin-backend"
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          image: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0"
          imagePullPolicy: Always
          livenessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            timeoutSeconds: 5
          name: nginx-ingress-controller
          ports:
            - containerPort: 80
              name: http
              protocol: TCP
            - containerPort: 443
              name: https
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: ingress-svc
spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: http
  - name: https
    port: 443
    targetPort: https
  selector:
    k8s-app: nginx-ingress-lb
-- Leonard Michalas
google-cloud-platform
kubernetes
kubernetes-helm
nginx

1 Answer

4/26/2018

The issue is the args. The args on one of mine are

      args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
        - --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

I had also created the config maps for configuration, tcp and udp.

-- Jonah Benton
Source: StackOverflow