minikube에 kibana 설치

2024. 2. 6. 19:43카테고리 없음

기본설정

apiVersion: v1
kind: Namespace
metadata:
  name: {namespace}
---
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: {namespace}
  name: {app명}
data:
  kibana.yml: |
    server.name: {app명}
    server.host: "0.0.0.0"
    # minikube 안에서 통신하기 때문에 service에 직접 연결 가능
    elasticsearch.hosts: [ "http://{elasticsearch 서비스명}:{elasticsearch 서비스 포트}" ]
    # elasticsearch에서 'xpack.security.enabled: true'가 설정된 경우 필요
    #elasticsearch.username: "{계정}"
    #elasticsearch.password: "{비밀번호}"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {app명}
  namespace: {namespace}
  labels:
    app: {app명}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {app명}
  template:
    metadata:
      labels:
        app: {app명}
    spec:
      containers:
      - name: {app명}
        # 7.17.17 --> 8.12.1로 업그레이드해도 문제 없음
        image: docker.elastic.co/kibana/kibana:8.12.1
        ports:
        - containerPort: {pod port}
        volumeMounts:
        - name: config
          mountPath: /usr/share/kibana/config/kibana.yml
          readOnly: true
          subPath: kibana.yml
      volumes:
      - name: config
        configMap:
          name: {app명}
---
apiVersion: v1
kind: Service
metadata:
  name: {app명}
  namespace: {namespace}
spec:
  selector:
    app: {app명}
  ports:
    - protocol: TCP
      port: {service port}
      targetPort: {pod port}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {app명}
  namespace: {namespace}
  annotations:
spec:
  rules:
    - host: {도메인}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: {app명}
                port:
                  number: {service port}

Trouble Shooting

  • Unable to retrieve version information from Elasticsearch nodes.

 

  • 리디렉션한 횟수가 너무 많습니다.

# 302에러가 일시적으로 많이 발생함
{"type":"response","@timestamp":"2024-02-08T12:57:53+00:00","tags":[],"pid":7,"method":"get","statusCode":302,"req":{"url":"/","method":"get","headers":{"host":"kibana.xxxxxx.co.kr","x-request-id":"1ecc98844ec26b0cac1d889d9f502864","x-real-ip":"192.168.49.1","x-forwarded-for":"192.168.49.1","x-forwarded-host":"kibana.xxxxxx.co.kr","x-forwarded-port":"80","x-forwarded-proto":"http","x-forwarded-scheme":"http","x-scheme":"http","x-original-forwarded-for":"192.168.0.xx","x-forwarded-for-proto":"http","cache-control":"max-age=0","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","accept-encoding":"gzip, deflate","accept-language":"ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7"},"remoteAddress":"10.244.0.59","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"},"res":{"statusCode":302,"responseTime":4},"message":"GET / 302 4ms"}

원인: ingress에서 잘못된 redirect 처리를 해서 생긴 문제

# kibana의 ingress의 rewrite-target이 잘못 셋팅되어서 계속 redirect가 됨
# / --> /spaces/enter --> / --> /spaces/enter 무한반복하게 됨
# 하지만, 브라우져에서 redirect 횟수가 제한되어 있어서 멈춤
------------------------
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kibana
  namespace: {namespace}
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: {도메인}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: kibana
                port:
                  number: {서비스 포트}
------------------------

# nginx.ingress.kubernetes.io/rewrite-target: /$1을 제거해줘야 redirect가 일어나지 않음
------------------------
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kibana
  namespace: {namespace}
  annotations:
spec:
  rules:
    - host: {도메인}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: kibana
                port:
                  number: {서비스 포트}
------------------------
  • Configuration missing

kibana를 처음 띄우면 오른쪽 하단에 위와 같은 경고 문구가 나옴
없애기 위해서는 아래와 같이 설정 해야 함

# 아래 내용 추가
# http나 https가 빠지면, 작동안함
server.publicBaseUrl: {http 또는 https}://{도메인}