예전에 Silicon Mac 환경에 K8s 설치해서 ElasticSearch까지 설치하는 가이드를 작성한 적이 있는데, 최근에 다시 실행을 해보니 bitnami 정책의 변경으로 인해 설치가 되지 않았다.
그래서 elastic 표준 chart를 이용해서 설치하는 방법을 정리해봤다.
helm repo add elastic https://helm.elastic.co
helm repo update
kubectl create -f https://download.elastic.co/downloads/eck/3.1.0/crds.yaml
kubectl get crd | grep k8s.elastic.co
helm install elastic-operator elastic/eck-operator \
-n my_namespace \
--create-namespace \
--version 3.1.0 \
--set installCRDs=false
kubectl -n my_namespace rollout status sts/elastic-operator
kubectl -n my_namespace create secret generic es-app-basic \
--type=kubernetes.io/basic-auth \
--from-literal=username=계정이름 \
--from-literal=password=패스워드 \
--from-literal=roles='superuser'
eck-elasticsearch:
enabled: true
fullnameOverride: elasticsearch
version: 9.1.0
auth:
fileRealm:
- secretName: es-app-basic # kubernetes.io/basic-auth (username/password/roles)
http:
tls:
selfSignedCertificate:
disabled: true
nodeSets:
- name: default
count: 1
config:
node.store.allow_mmap: false
podTemplate:
spec:
initContainers:
- name: install-plugins
command: ["sh","-c","bin/elasticsearch-plugin install --batch analysis-nori"]
containers:
- name: elasticsearch
resources:
requests: { cpu: "200m", memory: "1Gi" }
limits: { cpu: "1", memory: "2Gi" }
helm install es-kb-quickstart elastic/eck-stack \
-n my_namespace \
--create-namespace \
-f es-values.yml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: es-ingress
namespace: my_namespace
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
nginx.ingress.kubernetes.io/proxy-body-size: "100m"
spec:
ingressClassName: nginx
rules:
- host: es.k8s
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: elasticsearch-es-http
port:
number: 9200
kubectl apply -f es-ingress.yml
hostname=$(kubectl get ingress es-ingress -n my_namespace -o json | jq -r ".spec.rules[0].host")
ip=$(kubectl get ingress es-ingress -n my_namespace -o json | jq -r ".status.loadBalancer.ingress[0].ip")
echo "$hostname: $ip"
/etc/hosts에 이 호스트명과 IP를 등록해주면 된다.
echo "waiting for ready state..."
kubectl -n textmanager wait --for=condition=ready pod/elasticsearch-es-default-0 --timeout=5m && \
curl -u 계정이름:패스워드 http://es.k8s/_cluster/health\?pretty