Nginx ingress controller failed to run

2/14/2019

I'm trying to deploy nginx-ingress controller in my own server without load balancer and cloud provider. I did the following steps:

apiVersion: v1
kind: Namespace
metadata:
  name: ingress-nginx

Then, I created a cluster role named nginx-ingress for the serviceAccount.
My nginx-controller-service.yaml:

kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: NodePort
  selector:
    app: ingress-nginx
  ports:
  - name: http
    port: 80
    targetPort: http
  - name: https
    port: 443
    targetPort: https
  externalIPs:
    - my-external-node-ip

And nginx-ingress-controller.yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-ingress-controller
  namespace: ingress-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingress-nginx
  template:
    metadata:
      labels:
        app: ingress-nginx
      annotations:
        prometheus.io/port: '10254'
        prometheus.io/scrape: 'true'
    spec:
      serviceAccountName: nginx-ingress
      containers:
        - name: nginx-ingress-controller
          image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0-beta.17
          args:
            - /nginx-ingress-controller
            - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
          - name: http
            containerPort: 80
          - name: https
            containerPort: 443
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1

But, when I get the deployment status, it shows me:

NAMESPACE       NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
ingress-nginx   deployment.apps/default-http-backend       1/1     1            1           17m
ingress-nginx   deployment.apps/nginx-ingress-controller   0/1     0            0           17m

The controller is not available/not running.

What's going wrong here, how to get logs of that failed deployment?

-- Justinus Hermawan
docker
kubernetes
kubernetes-ingress
nginx-ingress

2 Answers

2/15/2019

The issue was caused due to missing service account.

58m Warning FailedCreate ReplicaSet Error creating: pods "nginx-ingress-controller-5b7f66f95f-" is forbidden: error looking up service account ingress-nginx/nginx-ingress: serviceaccount "nginx-ingress" not found

with the following command you can create the SA

kubectl create serviceaccount my-service-account

for further detail k8s-service-account

-- Suresh Vishnoi
Source: StackOverflow

2/14/2019

remove the below entries from service manifest

externalTrafficPolicy: Local
  externalIPs:
    - my-external-node-ip
-- P Ekambaram
Source: StackOverflow