aws/k8s, eks study

[EFK-Kibana issue on EKS] when the kibana service on localhost:5601 is alive but probe check is failed from outside of pod

gepp 2023. 4. 6. 15:44

키바나를 배포했는데 별다른 에러 로그 없이 계속 probe check failed 가 나는 상황에, 실제 파드(포드) 안에서는 서비스 포트(port: 5601)로 정상 응답 확인되며 포드 밖에서는 사설아이피로 방화벽이 모두 허용되있으며 배포된 pod 아이피의 해당 포트 및 서비스 uri로 connection refused가 나는 상황이면,

컨피그맵(kibana-config로 생성했다.)으로 마운트된 kibana.yml 에 server.host: "0.0.0.0" 을 추가 및 배포하여 이를 해결할 수 있다.

pod description (에러 상황): dial tcp x.x.x.x:5601 connect: connection refused

키바나 내부 포드(pod)에 들어가 본다.

kubectl exec -it <pod name> -n <your namespace> -- /bin/bash

들어가면 호스트네임이 보이지만 확인차 hostname 명령어를 쳐서 확인할 수도 있다. (여기서는 hostname: kibana-0)

pod 안에서 호스트네임으로 요청 시 connection refused
pod 안에서 localhost로 요청시 정상 응답

[해결 resolution]

kubectl edit cm kibana-config -n <your namespace>
apiVersion: v1
data:
  kibana.yml: |
    server.host: "0.0.0.0"

위 세팅으로 새로 배포시 이제는 포드 안에서 호스트 네임으로 요청해도 localhost 요청시와 같이 동일하게 정상 응답이 반환되며, 지정한 로드밸런서 타겟그룹에도 아이피가 자동 등록되어 healthy 상태로 확인되었다.

pod 안에서 호스트네임으로 요청 시 정상 응답 반환
Ready 1/1 로 정상 running 상태의 pod 확인

 

문제 해설:

localhost:5601로 로컬 호스트에서 Kibana에 액세스할 수 있지만 kibana-0:5601로는 외부에서 액세스할 수 없는 상태입니다. kibana-0는 호스트 네임이고 배포시 정한 이름입니다. 

이는 Kibana가 동일한 시스템의 연결만 허용하는 루프백 인터페이스에서만 수신(listening)하기 때문일 수 있습니다.

sudo netstat -tlnp | 명령을 실행하여 Kibana가 수신 대기 중인 인터페이스를 확인할 수 있습니다. 포드 내부의sudo netstat -tlnp | grep 5601을 하여 Kibana가 127.0.0.1에서만 수신하는 경우 모든 인터페이스(0.0.0.0) 또는 포드에 액세스하는 데 사용하는 특정 인터페이스에서 수신하도록 구성을 수정해야 합니다.

모든 인터페이스에서 수신 대기하려면 kibana.yml 구성 파일을 수정하고 server.host 옵션을 0.0.0.0으로 설정하면 됩니다. 이렇게 변경한 후 구성을 적용하려면 Kibana를 다시 시작해야 합니다.



It seems that you are able to access Kibana on the local host with localhost:5601, but not from the outside with kibana-0:5601. This could be because Kibana is only listening on the loopback interface, which only allows connections from the same machine.

You can check which interfaces Kibana is listening on by running the command sudo netstat -tlnp | grep 5601 inside the pod. If Kibana is only listening on 127.0.0.1, then you will need to modify its configuration to listen on all interfaces (0.0.0.0) or the specific interface that you are using to access the pod.

To listen on all interfaces, you can modify the kibana.yml configuration file and set the server.host option to 0.0.0.0. For example:After making this change, you will need to restart Kibana for the configuration to take effect.