Unable to create Ingress after nginx-ingress controller is created

Viewed 6427

I am trying to create a static Internal Ingress in GKE. It seems that we don't have a direct way so. I have followed a workaround following How to set static internal IP to the GKE internal Ingress .

Here is the Ingress.yaml file that I am using to deploy some sample workloads and Ingress.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-app
spec:
  selector:
    matchLabels:
      app: hello
  replicas: 3
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
        - name: hello
          image: "gcr.io/google-samples/hello-app:2.0"
---
apiVersion: v1
kind: Service
metadata:
  name: hello-service
  labels:
    app: hello
spec:
  type: NodePort
  selector:
    app: hello
  ports:
    - name: hello-port
      port: 80
      targetPort: 8080
      protocol: TCP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes-deployment
spec:
  selector:
    matchLabels:
      greeting: hello
      department: kubernetes
  replicas: 3
  template:
    metadata:
      labels:
        greeting: hello
        department: kubernetes
    spec:
      containers:
        - name: hello-again
          image: "gcr.io/google-samples/node-hello:1.0"
          env:
            - name: "PORT"
              value: "8080"
---
apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes
spec:
  type: NodePort
  selector:
    greeting: hello
    department: kubernetes
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: hello-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
    - host:
      http:
        paths:
          - path: /
            backend:
              serviceName: hello-service
              servicePort: hello-port
          - path: /kube
            backend:
              serviceName: ....
              servicePort: ....

I am able to create Ingress only if have applied this Yaml to create "hello-ingress" first and nginx-ingress-controller.yaml (https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud/deploy.yaml)later. But I am unable to make changes to "hello-ingress" like adding new backends.

I am getting the following error with no other logs: Error: Error from server (Timeout): error when creating "ingress.yaml": Timeout: request did not complete within requested timeout 30s

Please help me to fix this>

here are the logs:

All commands ran successfully to install nginx-ingress controller. I don't see any change in the logs.

kubectl get svc -n ingress-nginx

NAME                                 TYPE           CLUSTER-IP   EXTERNAL-IP    PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.0.70.63   34.89.23.101   80:31487/TCP,443:30883/TCP   4m31s
ingress-nginx-controller-admission   ClusterIP      10.0.70.77   <none>         443/TCP                      4m33s

kubectl logs ingress-nginx-controller-7656c59dc4-lxzr8 -n ingress-nginx

-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:       0.33.0
  Build:         git-589187c35
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.19.0

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

I0626 12:37:33.117229       6 flags.go:204] Watching for Ingress class: nginx
W0626 12:37:33.117726       6 flags.go:249] SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)
W0626 12:37:33.117819       6 client_config.go:552] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0626 12:37:33.118042       6 main.go:218] Creating API client for https://10.0.70.1:443
I0626 12:37:33.129303       6 main.go:262] Running in Kubernetes cluster version v1.14+ (v1.14.10-gke.36) - git (clean) commit 34a615f32e9a0c9e97cdb9f749adb392758349a6 - platform linux/amd64
I0626 12:37:33.423095       6 main.go:103] SSL fake certificate created /etc/ingress-controller/ssl/default-fake-certificate.pem
I0626 12:37:33.427971       6 ssl.go:528] loading tls certificate from certificate path /usr/local/certificates/cert and key path /usr/local/certificates/key
I0626 12:37:33.489675       6 nginx.go:263] Starting NGINX Ingress controller
I0626 12:37:33.514359       6 event.go:278] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"ingress-nginx-controller", UID:"b61c2d49-b7a9-11ea-b6c6-4201ac100064", APIVersion:"v1", ResourceVersion:"10997045", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/ingress-nginx-controller
I0626 12:37:34.690278       6 nginx.go:307] Starting NGINX process
I0626 12:37:34.690278       6 leaderelection.go:242] attempting to acquire leader lease  ingress-nginx/ingress-controller-leader-nginx...
I0626 12:37:34.691363       6 nginx.go:327] Starting validation webhook on :8443 with keys /usr/local/certificates/cert /usr/local/certificates/key
I0626 12:37:34.692058       6 controller.go:139] Configuration changes detected, backend reload required.
I0626 12:37:34.702054       6 leaderelection.go:252] successfully acquired lease ingress-nginx/ingress-controller-leader-nginx
I0626 12:37:34.702550       6 status.go:86] new leader elected: ingress-nginx-controller-7656c59dc4-lxzr8
I0626 12:37:34.832600       6 controller.go:155] Backend successfully reloaded.
I0626 12:37:34.832669       6 controller.go:164] Initial sync, sleeping for 1 second.

kubectl apply -f ingress.yaml

deployment.apps/hello-app created
service/hello-service created
Error from server (Timeout): error when creating "ingress.yaml": Timeout: request did not complete within requested timeout 30s

kubectl logs ingress-nginx-controller-7656c59dc4-lxzr8 -n ingress-nginx

-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:       0.33.0
  Build:         git-589187c35
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.19.0

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

I0626 12:37:33.117229       6 flags.go:204] Watching for Ingress class: nginx
W0626 12:37:33.117726       6 flags.go:249] SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)
W0626 12:37:33.117819       6 client_config.go:552] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0626 12:37:33.118042       6 main.go:218] Creating API client for https://10.0.70.1:443
I0626 12:37:33.129303       6 main.go:262] Running in Kubernetes cluster version v1.14+ (v1.14.10-gke.36) - git (clean) commit 34a615f32e9a0c9e97cdb9f749adb392758349a6 - platform linux/amd64
I0626 12:37:33.423095       6 main.go:103] SSL fake certificate created /etc/ingress-controller/ssl/default-fake-certificate.pem
I0626 12:37:33.427971       6 ssl.go:528] loading tls certificate from certificate path /usr/local/certificates/cert and key path /usr/local/certificates/key
I0626 12:37:33.489675       6 nginx.go:263] Starting NGINX Ingress controller
I0626 12:37:33.514359       6 event.go:278] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"ingress-nginx", Name:"ingress-nginx-controller", UID:"b61c2d49-b7a9-11ea-b6c6-4201ac100064", APIVersion:"v1", ResourceVersion:"10997045", FieldPath:""}): type: 'Normal' reason: 'CREATE' ConfigMap ingress-nginx/ingress-nginx-controller
I0626 12:37:34.690278       6 nginx.go:307] Starting NGINX process
I0626 12:37:34.690278       6 leaderelection.go:242] attempting to acquire leader lease  ingress-nginx/ingress-controller-leader-nginx...
I0626 12:37:34.691363       6 nginx.go:327] Starting validation webhook on :8443 with keys /usr/local/certificates/cert /usr/local/certificates/key
I0626 12:37:34.692058       6 controller.go:139] Configuration changes detected, backend reload required.
I0626 12:37:34.702054       6 leaderelection.go:252] successfully acquired lease ingress-nginx/ingress-controller-leader-nginx
I0626 12:37:34.702550       6 status.go:86] new leader elected: ingress-nginx-controller-7656c59dc4-lxzr8
I0626 12:37:34.832600       6 controller.go:155] Backend successfully reloaded.
I0626 12:37:34.832669       6 controller.go:164] Initial sync, sleeping for 1 second.
1 Answers

So, The problem that I was facing is with the firewall.

I created the nginx-ingress in a private cluster and I had to open ports 8443 and 10254 from master Address range to nodes.

Related