Search code examples
kuberneteskibanaelastic-stackistio

ERR_TOO_MANY_REDIRECTS 302 with ELK Operator 7.10.0 using Server.basePath


I have an Elastic stack with elasticsearch and kibana version 7.10.0 using elk operator in kubernetes

Whenever I enter the link https://monitoring.cloudapp.azure.com/kibana I'm getting this redirection:

https://monitoring.cloudapp.azure.com/kibana/login?next=%2Fkibana%2Fkibana%2Flogin%3Fnext%3D%2Fkibana%2Fkibana%2Flogin%3Fnext%3D%252Fkibana%252Fkibana%

In the Pod logs:

"type":"response","@timestamp":"2020-12-23T15:38:27Z","tags":,"pid":7,"method":"get","statusCode":302,"req":{"url":"/kibana/login?next=%2Fkibana%2Fkibana%2Flogin%3Fnext%3D%252Fkibana%252.....

Kibana.yaml

apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: kibana
spec:
  version: 7.10.0
  count: 1
  elasticsearchRef:
    name: elastic-https
  http:
    service:
      spec:
        type: ClusterIP
    tls:
      selfSignedCertificate:
        disabled: true
  podTemplate:
    spec:
      containers:
      - name: kibana
        env:
        - name: SERVER_BASEPATH
          value: "/kibana"
        resources:
          requests:
            memory: 4Gi
            cpu: 1
          limits:
            memory: 8Gi
            cpu: 2
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: "true"

kibana.ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: istio
  name: kibana-ingress
spec:
  rules:
    - host: "monitoring.cloudapp.azure.com"
      http:
        paths:
          - path: /kibana/login.*
            backend:
              serviceName: kibana-kb-http
              servicePort: 5601
          - path: /kibana
            backend:
              serviceName: kibana-kb-http
              servicePort: 5601
          - path: /kibana/*
            backend:
              serviceName: kibana-kb-http
              servicePort: 5601

No way with incognito window, I have the same problem whenever I do a kubectl port-forward I stumble upon the same problem with the redirection (with HTTP)

> http://localhost:52000/kibana/login?next=%2Fkibana%2Fkibana%2Flogin%3Fnext%

Solution

  • The solution is to add server.rewriteBasePath: true like this

    ---
    apiVersion: kibana.k8s.elastic.co/v1
    kind: Kibana
    metadata:
      name: kibana
    spec:
      config:
        server.rewriteBasePath: true
    

    and update the readinessProbe like :

     podTemplate:
        spec:
          containers:
          - name: kibana
            readinessProbe:
              httpGet:
                scheme: HTTP
                path: /kibana
                port: 5601
            env:
            - name: SERVER_BASEPATH
              value: "/kibana"
    

    don't forget with more than 1 replica set the redirect from / kibana to /kibana/login doesn't works