Helm으로 Elasticsearch 설치하기

Elasticsearch 레포지토리 추가 및 차트 다운로드

$ helm repo add bitnami https://charts.bitnami.com/bitnami $ helm fetch bitnami/elasticsearch $ tar xzvf elasticsearch-19.10.4.tgz

values.yaml 수정

$ cd elasticsearch
$ sudo vi values.yaml

Elasticsearch 설정

bitnami elasticsearch

...
global:
  kibanaEnabled: false # 키바나는 별도로 설치함
...
plugins: analysis-nori
...
security:
  enabled: false # true로 수정
  elasticPassword: "" # 비밀번호 입력
tls:
  restEncryption: true # false로 수정
  autuGenerated: false # true로 수정
...

service:
  type: ClusterIP # NodePort 로 수정
  nodePorts:
    restAPI: 30002
    transport: 31002
...



master:
  replicaCount: 2 # 1로 수정
...
data:
  replicaCount: 2 # 1로 수정
...
data:
  replicaCount: 2 # 1로 수정
...
coordinating:
  replicaCount: 2 # 1로 수정
...
ingest:
  replicaCount: 2 # 1로 수정
...
metrics:
  enabled: true

  

Elasticsearch 설치

$ kubectl create namespace elasticsearch $ helm install elasticsearch -f values.yaml . -n elasticsearch --render-subchart-notes $ helm upgrade elasticsearch -f values.yaml . -n elasticsearch --render-subchart-notes
NAME: elasticsearch
LAST DEPLOYED: Tue Aug 15 14:50:09 2023
NAMESPACE: elasticsearch
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: elasticsearch
CHART VERSION: 19.8.1
APP VERSION: 8.7.1

-------------------------------------------------------------------------------
 WARNING

    Elasticsearch requires some changes in the kernel of the host machine to
    work as expected. If those values are not set in the underlying operating
    system, the ES containers fail to boot with ERROR messages.

    More information about these requirements can be found in the links below:

      https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html
      https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html

    This chart uses a privileged initContainer to change those settings in the Kernel
    by running: sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536

** Please be patient while the chart is being deployed **

  Elasticsearch can be accessed within the cluster on port 9200 at elasticsearch.elasticsearch.svc.cluster.local

  To access from outside the cluster execute the following commands:

    kubectl port-forward --namespace elasticsearch svc/elasticsearch 9200:9200 &
    curl http://127.0.0.1:9200/


CHART NAME: kibana
CHART VERSION: 10.3.2
APP VERSION: 8.7.1

** Please be patient while the chart is being deployed **

1. Get the application URL by running these commands:
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward svc/elasticsearch-kibana 8080:5601


포트포워딩

포트포워딩을 이용하여 클러스터 내 어플리케이션에 접속하기

# 백그라운드로 실행
$ nohup kubectl port-forward --namespace elasticsearch svc/elasticsearch 9200:9200 --address='0.0.0.0' &

Kibana는 namespace 지정 필요 (누락되어 있음)

$ nohup kubectl port-forward --namespace elasticsearch  svc/elasticsearch-kibana --address='0.0.0.0' 5601:5601 &

포트포워딩 프로세스 죽이기

PID 확인 (두번째 컬림)

$ ps -aux | grep -i kubectl
$ kill -9 [PID]

Elasticsearch 삭제

아래 명령어 외, Harbor 관련 PVC를 모두 삭제해야 재설치시 로그인 이슈가 없음

$ helm delete -n elasticsearch elasticsearch