1
votes

I am using K8s 1.21.0 in a bare metal configuration without a loadbalancer. I've installed nginx ingress in a NodePort configuration using helm:

helm install ********** nginx-stable/nginx-ingress --set "controller.service.type=NodePort" --namespace=nginx-ingress

Edit: I've also tried this as a LoadBalancer, but the result is the same.

I've deployed a simple nginx web server with the following yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: www-deployment
spec:
  selector:
    matchLabels:
      app: www
  replicas: 1
  template:
    metadata:
      labels:
        app: www
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

and a service:

apiVersion: v1
kind: Service
metadata:
  name: webserver-service
spec:
  selector:
    app: www
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

with the following ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: k8stest.************.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: webserver-service
            port:
              number: 80

From my control plane I can curl the cluster IP for the service fine. I get what I expect:

curl 10.103.183.94
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>....

However, If I curl my ingress controller via its service, I always get a 404.

curl -H "Host: k8stest.**********.com" http://10.106.95.61
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.19.9</center>
</body>
</html>

I've tried removing the rewrite target annotation, but this leads to the same result. 404.

It seems that the ingress controller is not communicating with my service.

In the ingress controller logs I am just seeing:

[06/May/2021:08:31:53 +0000] "GET / HTTP/1.1" 404 153 "-" "curl/7.68.0" "-"

I've also tried with and without the host value in the ingress configuration and also tried using /test instead of just / in the ingress path. Nothing ever gets sent to the backend nginx service.

1

1 Answers

1
votes

Ok, I ditched the helm installed nginx ingress controller and went with the bare metal installation as documented here:

https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal

As soon as this was up and running, everything sprang into life as expected.