1. 에러 발생
헬름 차트를 이용하여 bitnami의 kafka 프로젝트 설치 후 kafka-client 내부에서 Producer의 동작을 확인하는 과정에서 다음의 에러가 발생했다.
# kafka-client 내부 Producer 토픽 확인 시 에러
[2023-08-19 14:38:24,607] WARN [Producer clientId=console-producer] Bootstrap broker kafka-controller-2.kafka-controller-headless.kafka.svc.cluster.local:9092 (id: -3 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2023-08-19 14:38:24,609] WARN [Producer clientId=console-producer] Bootstrap broker kafka-controller-1.kafka-controller-headless.kafka.svc.cluster.local:9092 (id: -2 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2023-08-19 14:38:25,019] WARN [Producer clientId=console-producer] Bootstrap broker kafka-controller-0.kafka-controller-headless.kafka.svc.cluster.local:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2023-08-19 14:38:25,427] WARN [Producer clientId=console-producer] Bootstrap broker kafka-controller-2.kafka-controller-headless.kafka.svc.cluster.local:9092 (id: -3 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2023-08-19 14:38:25,832] WARN [Producer clientId=console-producer] Bootstrap broker kafka-controller-1.kafka-controller-headless.kafka.svc.cluster.local:9092 (id: -2 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
처음에는 브로커 간의 네트워크가 연결이 종료되었기 때문에, 일반적인 네트워크 상의 문제인 줄 알았고 Config의 실수인 줄 알고 여러 방면으로 Config를 수정을 하며 시도를 해보았으나 같은 현상이 반복되었다.
지속적으로 구글링을 하여 도출한 결론은 bitnami/kafka 프로젝트 내에서 현재 많이 발생하는 이슈로 파악이 되었다. - 2023.08.24 기준
아래는 동일한 에러가 발생하는 Github - Issue이다.
https://github.com/bitnami/charts/issues/18659
[bitnami/kafka] Cannot connect · Issue #18659 · bitnami/charts
Name and Version bitnami/kafka 24.0.13 What architecture are you using? amd64 What steps will reproduce the bug? I simply installed the chart with the oneliner. After that I cannot connect with any...
github.com
추가로 pod 내부에서 kafka-controller의 로그를 확인했을 때, Client에서 통신할 때, Authentication의 문제라는 것을 파악하였고, 이 또한 Github의 Issue에서 찾아볼 수 있었다.
https://github.com/bitnami/charts/issues/18793
[kafka] SASL_PLAINTEXT and SCRAM-SHA-256 is not working · Issue #18793 · bitnami/charts
Name and Version kafka/24.0.14 What architecture are you using? None What steps will reproduce the bug? Create helm chart with the following value: kraft: enabled: true listeners: client: protocol:...
github.com
위의 Issue도 SASL과 SCRAM-SHA256을 정상적인 이용이 되지 않아서 아래 에러가 발생한 것이다.
# 에러 출력
[2023-08-22 20:55:30,262] ERROR [RaftManager id=2] Connection to node 1 (kafka-controller-1.kafka-controller-headless.kafka.svc.cluster.local/10.42.0.43:9093) failed authentication due to: Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256 (org.apache.kafka.clients.NetworkClient)
[2023-08-22 20:55:30,262] ERROR [kafka-2-raft-outbound-request-thread]: Failed to send the following request due to authentication error: ClientRequest(expectResponse=true, callback=kafka.raft.KafkaNetworkChannel$$Lambda$587/0x00007f21143d6000@12a2ee4e, destination=1, correlationId=294, clientId=raft-client-2, createdTimeMs=1692737729958, requestBuilder=VoteRequestData(clusterId='GTxB5josEfsini5mBw33Ww', topics=[TopicData(topicName='__cluster_metadata', partitions=[PartitionData(partitionIndex=0, candidateEpoch=314, candidateId=2, lastOffsetEpoch=192, lastOffset=1170)])])) (kafka.raft.RaftSendThread)
[2023-08-22 20:55:30,262] ERROR Request OutboundRequest(correlationId=294, data=VoteRequestData(clusterId='GTxB5josEfsini5mBw33Ww', topics=[TopicData(topicName='__cluster_metadata', partitions=[PartitionData(partitionIndex=0, candidateEpoch=314, candidateId=2, lastOffsetEpoch=192, lastOffset=1170)])]), createdTimeMs=1692737729958, destinationId=1) failed due to authentication error (kafka.raft.KafkaNetworkChannel)
org.apache.kafka.common.errors.SaslAuthenticationException: Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256
2. 해결
이를 해결하기 위하여 헬름 차트에서 kafka를 설치할 때, 기본 SASL 프로토콜을 SASL_PLAINTEXT에서 PLAINTEXT로 바꾸어서 적용하여 설치를 하여 문제를 해결하였다.
아래는 변경한 프로토콜을 적용한 헬름 차트의 설치 코드이다.
# 헬름 차트로 카프카 설치
helm install kafka --set volumePermissions.enabled=true,replicaCount=3,listeners.client.protocol=PLAINTEXT oci://registry-1.docker.io/bitnamicharts/kafka
위 코드를 이용하면 client.properties를 이용하지 않는다.
SASL에서 주는 보안의 이점이 있으나, 현재 해결되지 않은 이슈가 존재하기 때문에, 추후 문제가 해결되었을 때 다시 적용을 해야 될 것 같다.
'Devops > Kubernetes' 카테고리의 다른 글
[Kubernetes] Ubuntu 환경에서 K9S 설치 (0) | 2023.09.07 |
---|---|
[Kubernetes] 쿠버네티스 노드(Node) 및 파드(Pod) 사용 중 컴퓨터 자원(Resource) 확인 (0) | 2023.08.30 |
[Kubernetes] 쿠버네티스 내 헬름 차트(Helm Chart)로 Apache Kafka 설치(bitnami) (2) | 2023.08.22 |
[Kubernetes] 파드 간 통신 방법과 FQDN/DNS 요청 시 발생한 에러 처리 (0) | 2023.08.21 |
[Kubernetes] 쿠버네티스 Ec2(Kubeadm) 환경에서 Master-Worker Node 구축 (1) | 2023.08.11 |