【问题标题】:Connection refused on the Kibana kubernetes serviceKibana kubernetes 服务上的连接被拒绝
【发布时间】:2019-09-05 15:51:36
【问题描述】:

我使用自己修改过的 Helm 图表部署了 Open Distro

Kibana kubernetes 服务的样子

apiVersion: v1
kind: Service
metadata:
  annotations:
  creationTimestamp: "2019-09-05T15:29:04Z"
  labels:
    app: opendistro-es
    chart: opendistro-es-1.0.0
    heritage: Tiller
    release: opendistro-es
  name: opendistro-es-kibana
  namespace: elasticsearch
  resourceVersion: "48313341"
  selfLink: /api/v1/namespaces/elasticsearch/services/opendistro-es-kibana
  uid: e5066171-cff1-11e9-bb87-42010a8401d0
spec:
  clusterIP: 10.15.246.245
  ports:
  - name: opendistro-es-kibana
    port: 443
    protocol: TCP
    targetPort: 5601
  selector:
    app: opendistro-es-kibana
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

豆荚看起来像

apiVersion: v1
kind: Pod
metadata:
  annotations:
    checksum/config: a4af5a55572dd6587cb86b0e6b3758f682c23745ad114448ce93c19e9612b6a
  creationTimestamp: "2019-09-05T15:29:04Z"
  generateName: opendistro-es-kibana-5f78f46bb-
  labels:
    app: opendistro-es-kibana
    chart: opendistro-es-1.0.0
    heritage: Tiller
    pod-template-hash: 5f78f46bb
    release: opendistro-es
  name: opendistro-es-kibana-5f78f46bb-8pqfs
  namespace: elasticsearch
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: ReplicaSet
    name: opendistro-es-kibana-5f78f46bb
    uid: e4a7a0fe-cff1-11e9-bb87-42010a8401d0
  resourceVersion: "48313352"
  selfLink: /api/v1/namespaces/elasticsearch/pods/opendistro-es-kibana-5f78f46bb-8pqfs
  uid: e4acd8b3-cff1-11e9-bb87-42010a8401d0
spec:
  containers:
  - env:
    - name: CLUSTER_NAME
      value: elasticsearch
    image: amazon/opendistro-for-elasticsearch-kibana:1.0.2
    imagePullPolicy: IfNotPresent
    name: opendistro-es-kibana
    ports:
    - containerPort: 5601
      protocol: TCP
    resources:
      limits:
        cpu: 2500m
        memory: 2Gi
      requests:
        cpu: 500m
        memory: 512Mi
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /usr/share/kibana/config/kibana.yml
      name: config
      subPath: kibana.yml
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: opendistro-es-kibana-token-9g8mq
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: gke-ehealth-africa-d-concourse-ci-poo-98690882-h3lj
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: opendistro-es-kibana
  serviceAccountName: opendistro-es-kibana
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - configMap:
      defaultMode: 420
      name: opendistro-es-security-config
    name: security-config
  - name: config
    secret:
      defaultMode: 420
      secretName: opendistro-es-kibana-config
  - name: opendistro-es-kibana-token-9g8mq
    secret:
      defaultMode: 420
      secretName: opendistro-es-kibana-token-9g8mq

不幸的是,当我尝试 curl Kibana 服务名称时,连接被拒绝

curl: (7) Failed connect to opendistro-es-kibana:443; Connection refused

当我使用时

kubectl port-forward svc/opendistro-es-kibana 5601:443

我可以访问 Kibana

任何我所缺少的指针将不胜感激!

【问题讨论】:

  • “不幸的是,当我尝试 curl Kibana 服务名称时,我得到连接被拒绝”我认为这意味着您正在尝试 curl opendistro-es-kibana.elasticsearch.svc.cluster.local ?
  • 你从哪里运行 curl?你能确认完整的 curl 命令吗?如果 curl 由于端口 443 而尝试使用 TLS 并且 kibana 没有配置 SSL 证书,则连接将被拒绝,但是,端口 5601(端口转发 = localhost:5601)上的连接将不需要使用 TLS,除非您强迫它
  • 我正在执行以下操作(我更新了服务以在 5601 上收听)[root@opendistro-es-client-58b688b566-ph74p elasticsearch]# curl opendistro-es-kibana.elasticsearch.svc.cluster.local:5601 curl: (7) Failed connect to opendistro-es-kibana.elasticsearch.svc.cluster.local:5601; Connection refused
  • 你试过 curl opendistro-es-kibana.elasticsearch.svc.cluster.local:443 吗?您指定集群 IP 在端口 5601 上侦听时侦听端口 5601
  • 不开启port-forward,使用服务的clusterIP代替名称是否有效?卷曲 pod IP 是否有效?

标签: kubernetes kibana kubernetes-helm elasticsearch-opendistro


【解决方案1】:

您的服务属于clusterIP 类型,因此无法在集群外访问。将类型更改为NodePort,使其可以通过<your_node_ip>:<your_service_port>访问

更好的解决方案是使用 k8s ingress 接受外部流量

【讨论】:

  • 我没有尝试从外部访问它,我试图从内部的 pod 访问它
  • @WillPink 是该服务的同一命名空间中的 pod 吗?
  • pod作为服务在命名空间中是的
【解决方案2】:

好的,我设法修复它,默认情况下 Kibana 服务只监听环回接口。将其切换为使用server.host: "0.0.0.0" 后,它工作正常。

感谢您的建议

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 2021-09-13
    • 2016-05-02
    • 2021-05-25
    • 1970-01-01
    • 2020-11-08
    • 2021-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多