skip to Main Content

I had a Kibana that was previously running behind the NGINX ingress controller using this Ingress configuration:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: es-kibana-ing
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: HTTPS
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
    - host: "example.com"
      http:
        paths:
          - path: /kibana(/|$)(.*)
            pathType: Prefix
            backend:
              serviceName: es-kibana-svc
              servicePort: 443
  tls: 
    - hosts:
      - example.com
      secretName: example-tls

With this configuration you had to go to www.example.com/kibana to access the kibana.
Since then we migrated to GCP and now I’m trying to achieve the same using the GCE ingress controller. For now I figured how to serve the kibana on path "/*" :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: es-kibana-ing
  annotations:
    kubernetes.io/ingress.class: gce
    kubernetes.io/ingress.global-static-ip-name: kibana-static-ip
    networking.gke.io/managed-certificates: managed-cert
spec:
  rules:
    - host: "example.com"
      http:
        paths:
          - path: /*
            pathType: ImplementationSpecific
            backend:
              service:
                name: es-kibana-svc
                port:
                  number: 443

Instead I would like to serve the Kibana on the /kibana (as in the previous Nginx configuration), but I can’t find an equivalent to rewrite-target for the gce controller. Any idea how this can be done?

2

Answers


  1. It seems you may be using a different NGINX ingress controller and therefore annotations don’t work as expected. You may find explanation of differences here.

    Plus this closed GitHub issue seems to be very similar to yours so hopefully you can try using the solution mentioned there.

    Login or Signup to reply.
  2. If I understand what you want to achieve, you cannot do this using GCE Ingress, you would need to enforce Nginx Ingress.

    Rewrite behavior of Nginx Ingress cannot be replicated by GCE Ingress. As I mentioned in the comment section, Nginx Ingress contains much more features than GCE Ingress, for example rewrite/capture groups or service type requirement (NodePort in GCE, ClusterIP or NodePort in Nginx).

    With GCE Ingress you can achieve some static path rules like in this example. Something like that:

      rules:
        - http:
            paths:
            - path: /hello
              backend:
                serviceName: hello-svc
                servicePort: 8080
            - path: /hello-v2
              backend:
                serviceName: hello-v2-svc
                servicePort: 8080
            - path: /kibana
              backend:
                serviceName: kibana
                servicePort: 443
            - path: /randomsvc
              backend:
                serviceName: randomsvc
                servicePort: 8080
    

    However, as I understand by your comment:

    I just want to replicate the behavior that I described for Nginx Ingress, that was allowing me to access my application through ‘/kibana’ using the rewrite-target feature.

    Rewrite behavior is specific which cannot be replicated on GCE Ingress. There is a request to add a rewrite feature to GCE Ingress since 2018 but it’s still open. More details about it you can find here.

    You can find some differences between both Ingress in this guide.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search