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
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.
If I understand what you want to achieve, you cannot do this using
GCE Ingress
, you would need to enforceNginx Ingress
.Rewrite behavior of
Nginx Ingress
cannot be replicated byGCE Ingress
. As I mentioned in the comment section,Nginx Ingress
contains much more features thanGCE Ingress
, for examplerewrite
/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:However, as I understand by your comment:
Rewrite
behavior is specific which cannot be replicated onGCE Ingress
. There is a request to add arewrite
feature toGCE 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.