前提
- 需要一個(gè) kubernetes 集群
- 需要提供 csi(數(shù)據(jù)持久化)
部署步驟
- 部署 crd
kubectl create -f https://download.elastic.co/downloads/eck/2.12.1/crds.yaml
- 部署
elastic-operator
# 默認(rèn)在 elastic-system命名空間下
kubectl apply -f https://download.elastic.co/downloads/eck/2.12.1/operator.yaml
- 查看部署日志
kubectl -n elastic-system logs -f statefulset.apps/elastic-operator
- 部署一個(gè) elasticsearch 集群實(shí)例
cat <<EOF | kubectl apply -f -
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: elastic01
spec:
version: 8.13.1
volumeClaimDeletePolicy: DeleteOnScaledownOnly
http:
tls:
selfSignedCertificate:
disabled: true
nodeSets:
- name: default
count: 1
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: nfs-storage-class
config:
node.store.allow_mmap: false
EOF
- 查看集群狀態(tài)
# 查看 es 資源
k get es
NAME HEALTH NODES VERSION PHASE AGE
elastic01 green 1 8.13.1 Ready 38m
# 查看 pod 資源
k get po |grep elastic01
elastic01-es-default-0 1/1 Running 0 38m
# 查看 svc 資源
k get svc |grep elastic01
elastic01-es-default ClusterIP None <none> 9200/TCP 39m
elastic01-es-http NodePort 10.98.160.4 <none> 9200:31977/TCP 39m
elastic01-es-internal-http ClusterIP 10.100.120.30 <none> 9200/TCP 39m
elastic01-es-transport ClusterIP None <none> 9300/TCP 39m
- 查看認(rèn)證信息
kubectl get secret elastic01-es-elastic-user -o=jsonpath='{.data.elastic}' | base64 --decode; echo
- 本地連接測(cè)試
curl -u "elastic:xxxxxxxxx" -k "http://10.98.160.4:9200"
{
"name" : "elastic01-es-default-0",
"cluster_name" : "elastic01",
"cluster_uuid" : "_T5mzPPwRMqGSjnTYnMVWA",
"version" : {
"number" : "8.13.1",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "9287f29bba5e270bd51d557b8daccb7d118ba247",
"build_date" : "2024-03-29T10:05:29.787251984Z",
"build_snapshot" : false,
"lucene_version" : "9.10.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
- 部署 kibana
cat <<EOF | kubectl apply -f -
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: kibana01
spec:
version: 8.13.1
count: 1
elasticsearchRef:
name: elastic01
http:
tls:
selfSignedCertificate:
disabled: true
service:
spec:
type: NodePort
ports:
- port: 5601
targetPort: 5601
EOF
-
登錄驗(yàn)證
密碼同第 6 步