发布时间: 2024-11-7 文章作者: myluzh 分类名称: Kubernetes 朗读文章
root@k8s-master:~# kubectl create -f https://download.elastic.co/downloads/eck/2.4.0/crds.yaml customresourcedefinition.apiextensions.k8s.io/agents.agent.k8s.elastic.co created customresourcedefinition.apiextensions.k8s.io/apmservers.apm.k8s.elastic.co created customresourcedefinition.apiextensions.k8s.io/beats.beat.k8s.elastic.co created customresourcedefinition.apiextensions.k8s.io/elasticmapsservers.maps.k8s.elastic.co created customresourcedefinition.apiextensions.k8s.io/elasticsearches.elasticsearch.k8s.elastic.co created customresourcedefinition.apiextensions.k8s.io/enterprisesearches.enterprisesearch.k8s.elastic.co created customresourcedefinition.apiextensions.k8s.io/kibanas.kibana.k8s.elastic.co created root@k8s-master:~# kubectl apply -f https://download.elastic.co/downloads/eck/2.4.0/operator.yaml namespace/elastic-system created serviceaccount/elastic-operator created secret/elastic-webhook-server-cert created configmap/elastic-operator created clusterrole.rbac.authorization.k8s.io/elastic-operator created clusterrole.rbac.authorization.k8s.io/elastic-operator-view created clusterrole.rbac.authorization.k8s.io/elastic-operator-edit created clusterrolebinding.rbac.authorization.k8s.io/elastic-operator created service/elastic-webhook-server created statefulset.apps/elastic-operator created validatingwebhookconfiguration.admissionregistration.k8s.io/elastic-webhook.k8s.elastic.co created root@k8s-master:~# kubectl get pod -n elastic-system NAME READY STATUS RESTARTS AGE elastic-operator-0 1/1 Running 0 12s
root@k8s-master:~/k8s-yaml/es-cluser# vi es-cluser.yaml apiVersion: elasticsearch.k8s.elastic.co/v1 kind: Elasticsearch metadata: name: quickstart namespace: elastic-system # 可选:指定命名空间 spec: version: 7.17.0 image: 172.30.82.223:5443/base/sxhl-elastic:1.0 # 自定义镜像地址 nodeSets: - name: default count: 2 config: node.store.allow_mmap: false volumeClaimTemplates: - metadata: name: elasticsearch-data # 必须命名为 'elasticsearch-data' spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi root@k8s-master:~/k8s-yaml/es-cluser# kubectl apply -f es-cluser.yaml elasticsearch.elasticsearch.k8s.elastic.co/quickstart created2、获取es密码
root@k8s-master:~/k8s-yaml/es-cluser# PASSWORD=$(kubectl get secret quickstart-es-elastic-user -n elastic-system -o go-template='{{.data.elastic | base64decode}}') root@k8s-master:~/k8s-yaml/es-cluser# echo $PASSWORD sY006F7K7099zHzWyYT08Qbv3、测试es集群连通性
root@k8s-master:~/k8s-yaml/es-cluser# kubectl get svc -n elastic-system | grep http quickstart-es-http ClusterIP 10.43.219.195 <none> 9200/TCP 5m34s quickstart-es-internal-http ClusterIP 10.43.95.187 <none> 9200/TCP 5m34s root@k8s-master:~/k8s-yaml/es-cluser# curl -u "elastic:$PASSWORD" -k "https://10.43.219.195:9200" { "name" : "quickstart-es-default-0", "cluster_name" : "quickstart", "cluster_uuid" : "p7fn2gCzSaO8uXoaPBRGkw", "version" : { "number" : "7.17.0", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "bee86328705acaa9a6daede7140defd4d9ec56bd", "build_date" : "2022-01-28T08:36:04.875279988Z", "build_snapshot" : false, "lucene_version" : "8.11.1", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# vi kibana.yaml apiVersion: kibana.k8s.elastic.co/v1 kind: Kibana metadata: name: quickstart namespace: elastic-system # 可选:指定命名空间 spec: version: 7.17.0 count: 1 image: 172.30.82.223:5443/base/kibana:7.17.0 elasticsearchRef: name: quickstart # Kibana 将连接到名为 quickstart 的 Elasticsearch 集群 root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# kubectl apply -f kibana.yaml kibana.kibana.k8s.elastic.co/quickstart created2、获取密码
root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# KBPASSWD=$(kubectl get secret quickstart-es-elastic-user -n elastic-system -o=jsonpath='{.data.elastic}' | base64 --decode) root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# echo $KBPASSWD sY006F7K7099zHzWyYT08Qbv3、访问Kibana验证
root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# kubectl get svc -n elastic-system | grep kb quickstart-kb-http ClusterIP 10.43.206.185 <none> 5601/TCP 38s # 修改成nodeport端口 root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# kubectl patch svc quickstart-kb-http -n elastic-system -p '{"spec":{"type":"NodePort"}}' service/quickstart-kb-http patched root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# kubectl get svc -n elastic-system | grep kb quickstart-kb-http NodePort 10.43.206.185 <none> 5601:31476/TCP 2m3s # 验证 root@iZbp12bkuvg20e1j3y9gtxZ:~/k8s-yaml/es-cluser# curl -k -u elastic:$KBPASSWD https://172.30.82.214:31476/api/status ... "status": { "overall": { "since": "2024-11-07T09:14:23.109Z", "state": "green", "title": "Green", "nickname": "Looking good", "icon": "success", "uiColor": "secondary" }, ...
标签: k8s 集群 部署 k8s部署 apply elasticsearch elasticsearch7 es ECK Elasticsearch Operator es cluster
评论:
2024-12-10 14:10