簡體   English   中英

無法在 Ubuntu 上的 kubernetes cluser 中訪問 Kibana 儀表板服務

[英]Unable to access Kibana dashboard service in kubernetes cluser on Ubuntu

我嘗試在本地設置 fluentd-elasticsearch 時嘗試訪問 Kibana 儀表板。 這是我遵循的鏈接 我檢查了 Kibana pod 的日志。 它顯示以下錯誤:

{"type":"log","@timestamp":"2018-09-19T21:45:42Z","tags":["warning","config","deprecation"],"pid":1,"message":"You should set server.basePath along with server.rewriteBasePath. Starting in 7.0, Kibana will expect that all requests start with server.basePath rather than expecting you to rewrite the requests in your reverse proxy. Set server.rewriteBasePath to false to preserve the current behavior and silence this warning."}
root@mTrainer3:/logging# kubectl logs kibana-logging-66d577d965-mbbg5 -n kube-system
{"type":"log","@timestamp":"2018-09-19T21:45:42Z","tags":["warning","config","deprecation"],"pid":1,"message":"You should set server.basePath along with server.rewriteBasePath. Starting in 7.0, Kibana will expect that all requests start with server.basePath rather than expecting you to rewrite the requests in your reverse proxy. Set server.rewriteBasePath to false to preserve the current behavior and silence this warning."}
{"type":"log","@timestamp":"2018-09-19T21:46:08Z","tags":["status","plugin:kibana@6.4.1","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}

有人可以建議我如何解決這個問題嗎?

經過討論后,似乎更清楚了什么似乎是錯誤的。

您正在使用沒有負載均衡器的本地集群。 您必須設置入口或使用 NodePort 作為服務類型。 我將用 NodePort 來描述解決方案。 采取兩個步驟:

  1. 修改kibana-deployment.yaml並刪除env下的以下內容:
- name: SERVER_BASEPATH
  value: /api/v1/namespaces/kube-system/services/kibana-logging/proxy

所以你kibana-deployment.yaml看起來像:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kibana-logging
  namespace: kube-system
  labels:
    k8s-app: kibana-logging
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  replicas: 1
  selector:
  matchLabels:
    k8s-app: kibana-logging
  template:
    metadata:
      labels:
        k8s-app: kibana-logging
      annotations:
        seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
    spec:
      containers:
      - name: kibana-logging
        image: docker.elastic.co/kibana/kibana-oss:6.3.2
        resources:
          # need more cpu upon initialization, therefore burstable class
          limits:
            cpu: 1000m
          requests:
            cpu: 100m
        env:
          - name: ELASTICSEARCH_URL
            value: http://elasticsearch-logging:9200
        ports:
        - containerPort: 5601
          name: ui
          protocol: TCP
  1. 修改kibana-service.yaml將服務類型設置為 NodePort:
apiVersion: v1
kind: Service
metadata:
  name: kibana-logging
  namespace: kube-system
  labels:
    k8s-app: kibana-logging
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
    kubernetes.io/name: "Kibana"
spec:
  type: NodePort
  ports:
  - port: 5601
    protocol: TCP
    targetPort: ui
    nodePort: 30601
  selector:
    k8s-app: kibana-logging

然后執行

kubectl apply -f kibana-deployment.yaml
kubectl apply -f kibana-service.yaml

Kibana 應該可以通過http://<clusterip>:30601

背景

您將在沒有給定基本路徑的情況下直接訪問http://clusterip:30601 所以必須刪除它,以便 kibana 使用/作為基本路徑。 否則,它會嘗試將基本路徑 /api/v1/[...] 附加到您的 url。 如果你想測試它,你可以嘗試一下。

來自彈性搜索人員的這條評論提到,如果您想使用/ ,您必須完全刪除 base_path 。

將服務修改為 NodePort 是必要的,因為 K8s 默認不發布端口。 我剛剛在這個問題上回答了一個類似的問題

原答案(錯誤)

在您鏈接的存儲庫中,我可以看到 kibana-deployment.yaml 必須設置環境變量:

env:
  - name: ELASTICSEARCH_URL
    value: http://elasticsearch-logging:9200
  - name: SERVER_BASEPATH
    value: /api/v1/namespaces/kube-system/services/kibana-logging/proxy

你有沒有相應地設置它們?

假設您有一個直接連接到 kibana 實例的入口、負載均衡器或 NodePort,以便您想通過http://yourserver:9200/直接訪問它。 那么SERVER_BASEPATH/

或者,您也可以通過指定環境變量來指定 Kibana 來重寫服務器基本路徑。

修改kibana-deployment.yaml添加以下內容。

- name: SERVER_REWRITEBASEPATH
  value: "true"

現在申請: kubectl apply -f kibana-deployment.yaml

microk8smicrok8s測試,並與kubectl proxy

http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/kibana-logging/proxy/app/kibana

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM