Cloud-on-k8s: Operator provide option to configure kibana server.basePath for nginx reverse proxy.

Created on 26 May 2019  路  7Comments  路  Source: elastic/cloud-on-k8s

Currently applying kibana ingress to non-root path fails.
Reason:
Kibana intially redirect to /login?next
Post successful authentication redirects to /app/kibana

Solution:
In order to solve this we need to configure the server.basePath, Operator is not providing any option to configure the same. Please plan to add it.

Most helpful comment

This one works for me with kibana operator, Thanks @sebgl

`apiVersion: kibana.k8s.elastic.co/v1alpha1
kind: Kibana
metadata:
  name: kibana
  namespace: elastic-system
spec:
  http:
    tls:
      selfSignedCertificate:
        disabled: true
  podTemplate:
    spec:
      containers:
      - name: kibana
        env:
        - name: SERVER_BASEPATH
          value: "/kibana"
  version: 7.2.0
  nodeCount: 1
  elasticsearchRef:
    name: elasticsearch-logging`

ingress changes

`apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx-app
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^/kibana/(.*)$ /$1 break;
      proxy_set_header Authorization "";
    nginx.ingress.kubernetes.io/rewrite-target: /
  generation: 1
  labels:
    groupid: DEFAULT
  name: kibana-ingress
  namespace: elastic-system
spec:
  rules:
  - host: %(HOSTNAME)s
    http:
      paths:
      - backend:
          serviceName: kibana-kb-http
          servicePort: 5601
        path: /kibana
  tls:
  - hosts:
    -  %(HOSTNAME)s
    secretName: nginx-app-certs`

All 7 comments

Related: https://github.com/elastic/cloud-on-k8s/issues/740

This is very high priority in our roadmap @kuldeeps88. Should be fixed for the next release.

Running into this as a road block in using the operator as well. I tried doing the following in the podTemplate which is how I made it work when using the Kibana image directly on Kubernetes without the operator:

  podTemplate:                                                                                                                                                                                                        
    metadata:                                                                                                                                                                                                         
      labels:                                                                                                                                                                                                         
        app: kibana                                                                                                                                                                                                   
        function: logging                                                                                                                                                                                             
    spec:                                                                                                                                                                                                             
      containers:                                                                                                                                                                                                     
      - name: kibana                                                                                                                                                                                                  
        env:                                                                                                                                                                                                          
          - name: SERVER_BASEPATH                                                                                                                                                                                     
            value: /kibana 

@djschny , it seems that env variables are not picked up by pod, eventhough you specify them in podTemplate.spec.env. Any idea if there should be another structure for injecting env or is this currently not supported?

This is fixed with https://github.com/elastic/cloud-on-k8s/pull/952.
Injecting environment variables is not supported in release 0.8, but will be in release 0.9 @BostjanBozic @djschny @kuldeeps88.
Thanks for reporting this!

@sebgl
With operator version 0.9 injecting environment variable is still not working.

`apiVersion: kibana.k8s.elastic.co/v1alpha1
kind: Kibana
metadata:
name: kibana
namespace: elastic-system
spec:
http:
tls:
selfSignedCertificate:
disabled: true
containers:

  • name: kibana
    env:

    • name: SERVER_BASEPATH

      value: "/kibana"

      version: 7.2.0

      nodeCount: 1

      elasticsearchRef:

      name: elasticsearch-logging`

@kuldeeps88 this should be under the podTemplate.spec section of the Kibana spec:

`apiVersion: kibana.k8s.elastic.co/v1alpha1
kind: Kibana
metadata:
  name: kibana
  namespace: elastic-system
spec:
  http:
    tls:
      selfSignedCertificate:
        disabled: true
  podTemplate:
    spec:
      containers:
      - name: kibana
         env:
         - name: SERVER_BASEPATH
            value: "/kibana"
  version: 7.2.0
  nodeCount: 1
  elasticsearchRef:
    name: elasticsearch-logging`

This one works for me with kibana operator, Thanks @sebgl

`apiVersion: kibana.k8s.elastic.co/v1alpha1
kind: Kibana
metadata:
  name: kibana
  namespace: elastic-system
spec:
  http:
    tls:
      selfSignedCertificate:
        disabled: true
  podTemplate:
    spec:
      containers:
      - name: kibana
        env:
        - name: SERVER_BASEPATH
          value: "/kibana"
  version: 7.2.0
  nodeCount: 1
  elasticsearchRef:
    name: elasticsearch-logging`

ingress changes

`apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx-app
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^/kibana/(.*)$ /$1 break;
      proxy_set_header Authorization "";
    nginx.ingress.kubernetes.io/rewrite-target: /
  generation: 1
  labels:
    groupid: DEFAULT
  name: kibana-ingress
  namespace: elastic-system
spec:
  rules:
  - host: %(HOSTNAME)s
    http:
      paths:
      - backend:
          serviceName: kibana-kb-http
          servicePort: 5601
        path: /kibana
  tls:
  - hosts:
    -  %(HOSTNAME)s
    secretName: nginx-app-certs`
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Pandoraemon picture Pandoraemon  路  5Comments

sebgl picture sebgl  路  5Comments

sebgl picture sebgl  路  5Comments

spencergilbert picture spencergilbert  路  3Comments

SebastianCaceresUltra picture SebastianCaceresUltra  路  3Comments