k8s nginx入口kibana

时间:2019-03-02 03:14:25

标签: docker kubernetes kibana nginx-ingress

我有一个k8s集群,上面已经部署了ELK,我的kibana部署和服务看起来像

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    service: kibana
  name: kibana
spec:
  replicas: 1
  selector:
    matchLabels:
      service: kibana
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        service: kibana
    spec:
      containers:
        - image: docker.elastic.co/kibana/kibana:6.6.0
          name: kibana
          ports:
            - containerPort: 5601
          resources:
            requests:
              memory: 1Gi
            limits:
              memory: 1Gi
      restartPolicy: Always
      imagePullSecrets:
        - name: regcred
---
apiVersion: v1
kind: Service
metadata:
  labels:
    service: kibana
  name: kibana
spec:
  ports:
    - name: "5601"
      port: 5601
      targetPort: 5601
  selector:
    service: kibana
  type: NodePort

nginx入口看起来像

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: loadbalancer-https
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: true
    nginx.ingress.kubernetes.io/force-ssl-redirect: true
    nginx.ingress.kubernetes.io/secure-backends: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/app-root: /
    nginx.org/ssl-services: "kibana"
    kubernetes.io/ingress.class: nginx
spec:
  tls:
    - hosts:
        - kibana.some.com
      secretName: secret
  rules:
    - host: kibana.some.com
      http:
        paths:
          - path: /
            backend:
              serviceName: kibana
              servicePort: 5601

但是我得到502 Bad Gateway,如果我查看nginx入口日志,我会看到

2019/03/02 01:25:09 [error] 875#875: *470787 upstream prematurely closed connection while reading response header from upstream, client: 10.138.82.98, server: kibana.some.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://10.244.2.86:5601/favicon.ico", host: "kibana.some.com", referrer: "https://kibana.some.com/"

这似乎很简单,但我不知道我在这里缺少什么。我将不胜感激。

谢谢

1 个答案:

答案 0 :(得分:2)

它应该与您的入口中的items = [1,2,3,1,2,4,5,6,7,8,2,1,3,4,1,2,1,1] dict_of_keys = {} for i in items: if i not in dict_of_keys: dict_of_keys[i] = [] dict_of_keys[i].append(i) print(dict_of_keys) {1: [1, 1, 1, 1, 1, 1], 2: [2, 2, 2, 2], 3: [3, 3], 4: [4, 4], 5: [5], 6: [6], 7: [7], 8: [8]} 配置有关。您是否在Pod中为您的Kibana配置了HTTPS / TLS支持?否则,我建议删除此注释。

另外,请注意,nginx.ingress.kubernetes.io/secure-backends: "true"注释已弃用。

参考: