elastic / cloud-on-k8s

Elastic Cloud on Kubernetes
Other
2.52k stars 686 forks source link

Fleet server pod not created when Kibana is set with `SERVER_BASEPATH` #7909

Open msapitree opened 2 weeks ago

msapitree commented 2 weeks ago

Bug Report

What did you do?

Following quickstart 1) Deployed ECK 2) Deployed Elastic resource 3) Deployed Kibana resource 4) Redeployed Kibana resource with config modification (to setup public access to Kibana via k8s ingress on https://xxx.mydomain.com/monitoring/kibana): 5) Deployed Fleet Server Agent (together with ClusterRole, ClusterRoleBinding and ServiceAccount)

What did you expect to see?

What did you see instead? Under which circumstances?

NAME HEALTH NODES VERSION AGE apmserver.apm.k8s.elastic.co/monitoring green 1 8.14.0 5d21h

NAME HEALTH NODES VERSION PHASE AGE elasticsearch.elasticsearch.k8s.elastic.co/monitoring green 3 8.14.0 Ready 5d22h

NAME HEALTH NODES VERSION AGE kibana.kibana.k8s.elastic.co/monitoring green 1 8.14.0 114m


**Environment**

* ECK version: 2.13.0

* Kubernetes information: AKS

Client Version: v1.29.3 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.28.9


* Resource definition:
- Kibana with `SERVER_BASEPATH`

```yaml
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: monitoring
  namespace: monitoring-at
spec:
  version: 8.14.0
  count: 1
  elasticsearchRef:
    name: monitoring
  http:
    tls:
      selfSignedCertificate:
        disabled: true
  podTemplate:
    spec:
      containers:
      - env:
        - name: SERVER_BASEPATH
          value: /monitoring/kibana
        - name: SERVER_REWRITEBASEPATH
          value: "true"
        name: kibana
pebrc commented 7 hours ago

What you are trying to do is currently not supported. The operator, as you have found out is not aware of the server.basePath setting. The only work around I can think of is to try to do the rewrite proxy side with an ingress implementation specific path (e.g for nginx)

We could potentially inspect the Kibana config and adjust the paths. But it is a bit tricky your example shows. You are using environment variables while the more idiomatic way would be to use the config attribute:

apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: kibana
spec:
  version: 8.14.0
  count: 1
  elasticsearchRef:
    name: elasticsearch
  config:
    server:
      basePath: /kibana
      rewriteBasePath: true

A potential "fix" for this bug would probably only look at the config element.