繁体   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