hobby-kube / guide

Kubernetes clusters for the hobbyist.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ingress with rewrite-target annotation (or any)

raine opened this issue · comments

Hello. I've followed this guide for the most part, including the ingress setup, and the issue I've now encountered is that the nginx controller does not seem to be responding to any annotations I add to my Ingress.

I'm checking with kubectl exec -it -n ingress nginx-ingress-controller-8cd96ddb8-sqfvl cat /etc/nginx/nginx.conf what generated the nginx.conf contains, and have confirmed with diff that adding or removing annotations have no impact on the nginx.conf. Changing the path property in yaml does however change the respective location <path> { declaration in the config so the changes are being applied, just not the annotations.

This my Ingress currently, where the intent is to have the path /fillaripollari send requests to my API as if they were coming from the root (hence the need for rewrite).

Aside from rewrite not getting applied, the ingress is working perfectly from what I can tell.

Any ideas how to

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fillaripolleri
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: "/"
spec:
  rules:
  - host: mydomain.com
    http:
      paths:
      - path: /fillaripolleri
        backend:
          serviceName: fillaripolleri-server
          servicePort: 3000
Name:             fillaripolleri
Namespace:        default
Address:
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  mydomain.com
              /fillaripolleri   fillaripolleri-server:3000 (<none>)
Annotations:
  kubectl.kubernetes.io/last-applied-configuration:  {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.class":"nginx","nginx.ingress.kubernetes.io/rewrite-target":"/"},"name":"fillaripolleri","namespace":"default"},"spec":{"rules":[{"host":"mydomain.com","http":{"paths":[{"backend":{"serviceName":"fillaripolleri-server","servicePort":3000},"path":"/fillaripolleri"}]}}]}}

  kubernetes.io/ingress.class:                 nginx
  nginx.ingress.kubernetes.io/rewrite-target:  /
Events:
  Type    Reason  Age   From                Message
  ----    ------  ----  ----                -------
  Normal  CREATE  24s   ingress-controller  Ingress default/fillaripolleri

Just as I finish writing this issue, I realize this might be an issue with nginx-ingress-controller version.

So, after changing the image to the latest version, quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.20.0, nothing seems to break but annotations start working. 🎉

I updated the manifest to version 0.20.0 and changed everything related across the project.

Please be aware that the annotations prefix changed from ingress.kubernetes.io to nginx.ingress.kubernetes.io.