ElasticSearch for Kafka Sink Connector
1. Before you start
1.1 주요 링크
본문은 ElasticSearch on EKS 문서에서 나온 설치 방법 이후를 가정하고 있습니다.
주요 링크는 아래와 같습니다.
1.2 ES 연결 체크
먼저 ElasticSearch에 연결을 체크 합니다.
# ES로 port-forward 연결을 합니다.
$ kubectl port-forward -n elasticsearch service/elk-es-http 9200:9200
# 터미널 새로 열고, ES 접속 확인 합니다.
$ PASSWORD=$(kubectl get secret elk-es-elastic-user -n elasticsearch -o go-template='{{.data.elastic | base64decode}}')
$ curl -u "elastic:${PASSWORD}" -k "http://localhost:9200" | jq
{
"name": "elk-es-data-0",
"cluster_name": "elk",
<생략>
"tagline": "You Know, for Search"
}
1.3 ES 권한 체크
ElasticSearch 에 create_index, read, write, 그리고 view_index_metadata 권한이 있어야 합니다.
아래 코드는 권한 체크를 합니다.
$ curl -XPOST -u "elastic:${PASSWORD}" -k "localhost:9200/_security/role/es_sink_connector_role?pretty" -H 'Content-Type: application/json' -d'
{
"indices": [
{
"names": [ "*" ],
"privileges": ["create_index", "read", "write", "view_index_metadata"]
}
]
}'
1.4 Sink Connector 유저 생성
$ export ES_SINK_PASSWORD=$(pwgen -n -c -y -s 25 1)
$ curl -XPOST -u "elastic:${PASSWORD}" -k "localhost:9200/_security/user/es_sink_connector_user?pretty" -H 'Content-Type: application/json' -d'
{
"password" : "${ES_SINK_PASSWORD}",
"roles" : [ "es_sink_connector_role" ]
}'
{
"created" : true
}
유저 생성이 잘 됐는지 확인 합니다.
$ curl -XGET -u "elastic:${PASSWORD}" -k "localhost:9200/_security/user/" | jq
{
"es_sink_connector_user": {
"username": "es_sink_connector_user",
"roles": [
"es_sink_connector_role"
],
"full_name": null,
"email": null,
"metadata": {},
"enabled": true
}
}