无法在 Ubuntu 上的 kubernetes cluser 中访问 Kibana 仪表板服务

Gay*_*riB 2 elasticsearch fluentd kibana kubernetes

我尝试在本地设置 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"}
Run Code Online (Sandbox Code Playgroud)

有人可以建议我如何解决这个问题吗?

chr*_*oph 5

经过讨论后,似乎更清楚了什么似乎是错误的。

您正在使用没有负载均衡器的本地集群。您必须设置入口或使用 NodePort 作为服务类型。我将用 NodePort 来描述解决方案。采取两个步骤:

  1. 修改kibana-deployment.yaml并删除以下内容env
- name: SERVER_BASEPATH
  value: /api/v1/namespaces/kube-system/services/kibana-logging/proxy
Run Code Online (Sandbox Code Playgroud)

所以你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
Run Code Online (Sandbox Code Playgroud)
  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
Run Code Online (Sandbox Code Playgroud)

然后执行

kubectl apply -f kibana-deployment.yaml
kubectl apply -f kibana-service.yaml
Run Code Online (Sandbox Code Playgroud)

Kibana 应该可以访问 http://<clusterip>:30601

背景

您将在http://clusterip:30601没有给定基本路径的情况下直接访问。所以必须删除它,以便 kibana/用作基本路径。否则,它会尝试将基本路径 /api/v1/[...] 附加到您的 url。如果你想测试它,你可以尝试一下。

这个来自弹性搜索专家的评论提到,如果你想使用/.

将服务修改为 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
Run Code Online (Sandbox Code Playgroud)

你有没有相应地设置它们?

假设您有一个直接连接到 kibana 实例的入口、负载均衡器或 NodePort,以便您想通过http://yourserver:9200/直接访问它。然后SERVER_BASEPATH/