一. ECK部署
kubectl create -f https://download.elastic.co/downloads/eck/2.0.0/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/2.0.0/operator.yaml
kubectl -n elastic-system logs -f statefulset.apps/elastic-operator
二、部署Elasticsearch7.6.2集群
下载压缩包,下面的文件内容就是里面的
curl -LO https://github.com/elastic/cloud-on-k8s/archive/1.1.0.tar.gz
tar zxvf 1.1.0.tar.gz
cd cloud-on-k8s-1.1.0/config/recipes/beats
创建命名空间:
kubectl create namespace beats
创建elasticsearch:
cat > 1_monitor.yaml <<EOF
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: monitor
namespace: beats
spec:
version: 7.6.2
nodeSets:
- name: mdi
count: 3
config:
node.master: true
node.data: true
node.ingest: true
node.store.allow_mmap: false
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storageClassName: nfs-storage
http:
service:
spec:
type: NodePort
---
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: monitor
namespace: beats
spec:
version: 7.6.2
count: 1
elasticsearchRef:
name: "monitor"
http:
service:
spec:
type: NodePort
EOF
查看启动情况:
kubectl get pod -n beats
NAME READY STATUS RESTARTS AGE
monitor-es-mdi-0 1/1 Running 0 3m5s
monitor-es-mdi-1 1/1 Running 0 3m5s
monitor-es-mdi-2 1/1 Running 0 3m5s
monitor-kb-84bfc69db5-dkwm7 1/1 Running 0 3m3s
kubectl get crd -n beats | grep elastic
agents.agent.k8s.elastic.co 2022-11-24T11:37:25Z
apmservers.apm.k8s.elastic.co 2022-11-24T11:37:25Z
beats.beat.k8s.elastic.co 2022-11-24T11:37:25Z
elasticmapsservers.maps.k8s.elastic.co 2022-11-24T11:37:25Z
elasticsearches.elasticsearch.k8s.elastic.co 2022-11-24T11:37:25Z
enterprisesearches.enterprisesearch.k8s.elastic.co 2022-11-24T11:37:25Z
kibanas.kibana.k8s.elastic.co 2022-11-24T11:37:25Z
查看创建的Elasticsearch和kibana资源,包括运行状况,版本和节点数:
kubectl get elasticsearch -n beats
NAME HEALTH NODES VERSION PHASE AGE
monitor green 3 7.6.2 Ready 5m51s
kubectl get kibana -n beats
NAME HEALTH NODES VERSION AGE
monitor green 1 7.6.2 6m8s
查看创建的pv和pvc:
kubectl get pv,pvc -n beats
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/pvc-9a1710d9-b839-4dcd-805e-cea77d97dd33 50Gi RWO Delete Bound default/elasticsearch-data-monitor-es-mdi-1 nfs-storage 7m2s
persistentvolume/pvc-b72c2621-ec3b-4a14-9755-e37dc1e1bb09 50Gi RWO Delete Bound default/elasticsearch-data-monitor-es-mdi-2 nfs-storage 7m2s
persistentvolume/pvc-cd1285c3-6c81-4ec4-9b2e-b938a8eae96e 50Gi RWO Delete Bound default/elasticsearch-data-monitor-es-mdi-0 nfs-storage 7m2s
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/elasticsearch-data-monitor-es-mdi-0 Bound pvc-cd1285c3-6c81-4ec4-9b2e-b938a8eae96e 50Gi RWO nfs-storage 7m2s
persistentvolumeclaim/elasticsearch-data-monitor-es-mdi-1 Bound pvc-9a1710d9-b839-4dcd-805e-cea77d97dd33 50Gi RWO nfs-storage 7m2s
persistentvolumeclaim/elasticsearch-data-monitor-es-mdi-2 Bound pvc-b72c2621-ec3b-4a14-9755-e37dc1e1bb09 50Gi RWO nfs-storage 7m2s
查看创建的service,部署时已经将es和kibana服务类型改为NodePort,方便从集群外访问。
kubectl get svc -n beats
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.254.0.1 <none> 443/TCP 29d
monitor-es-http NodePort 10.254.52.175 <none> 9200:31553/TCP 8m5s #es端口
monitor-es-mdi ClusterIP None <none> 9200/TCP 8m2s
monitor-es-transport ClusterIP None <none> 9300/TCP 8m5s
monitor-kb-http NodePort 10.254.212.41 <none> 5601:32705/TCP 8m4s #kibanna端口
登录es地址:https://192.168.80.45:31553
默认elasticsearch启用了验证,获取elastic user的密码:
PASSWORD=$(kubectl get secret -n beats monitor-es-elastic-user -o=jsonpath='{.data.elastic}' | base64 --decode)
echo $PASSWORD
用户名:elastic 密码:Y41Z5M06I3d7rGVj58SLsD5z
登录kibanna:https://192.168.80.45:32705
注:密码跟上面一样,登录页面选择
标签:kubectl,mdi,monitor,elastic,eck,elasticsearch,版本,2.0,es From: https://www.cnblogs.com/Mercury-linux/p/16923533.html