部署 ECK [2.12]
安装说明
ElasticCloudonKubernetes(ECK)是一个 Elasticsearch Operator,但远不止于此。ECK 使用 Kubernetes Operator 模式构建而成,需要安装在您的 Kubernetes 集群内;
借助 Elastic Cloud on Kubernetes (ECK),您可以扩展基本的 Kubernetes 编排功能,以轻松部署、保护、升级 Elasticsearch 集群等。
基于Operator 模式的Elastic Cloud on Kubernetes,是 Elastic 推荐的在 Kubernetes 上部署 Elasticsearch、Kibana 和 APM Server 的方法。 ECK 有一个专用的 Helm 图表,可以 在 ECK 存储库(文档)中找到。
ECK中集成了大量es的运维工作:
- 管理和监测多个集群
- 轻松升级至新的版本
- 扩大或缩小集群容量
- 更改集群配置
- 动态调整本地存储的规模(包括 Elastic Local Volume(一款本地存储驱动器))
- 备份
支持版本
- Kubernetes 1.25-1.29
- OpenShift 4.11-4.14
- Google Kubernetes Engine (GKE), Azure Kubernetes Service (AKS), and Amazon Elastic - Kubernetes Service (EKS)
- Helm: 3.2.0+
- Elasticsearch, Kibana, APM Server: 6.8+, 7.1+, 8+
- Enterprise Search: 7.7+, 8+
- Beats: 7.0+, 8+
- Elastic Agent: 7.10+ (standalone), 7.14+ (Fleet), 8+
- Elastic Maps Server: 7.11+, 8+
- Logstash: 8.7+
从 ECK 1.3.0 开始,Helm 图表可用于安装 ECK。它可以从 Elastic Helm 存储库中获取,并且可以通过运行以下命令将其添加到您的 Helm 存储库列表中:
helm repo add elastic https://helm.elastic.co
helm repo update
# 查看图表的所有可用版本
helm search repo elastic/eck-operator --versions
Helm 支持的最低版本是 3.2.0。
限制安装
ECK operator 默认运行在elastic-system命名空间中。建议您为工作负载选择专用命名空间,而不是使用elastic-system或default命名空间。
安装CRD
此模式避免安装任何集群范围的资源,并限制操作员仅管理一组预定义的命名空间。
由于 CRD 是全局资源,因此它们仍然需要由管理员安装。这可以通过以下方式实现:
# 创建命名空间
kubectl create ns apm
# 指定版本安装
helm install --create-namespace -n apm elastic-operator-crds elastic/eck-operator-crds --version 2.12.1
这个操作可以由对他们希望管理的命名空间集具有完全访问权限的任何用户安装。
安装operator
以下示例将运算符安装到 elastic-system 命名空间,并将其配置为仅管理 elastic-system 和 apm:
# 下载指定版本图表
# 下载指定版本图表
helm pull elastic/eck-operator --version 2.12.1
tar zxvf eck-operator-2.12.1.tgz
helm upgrade --install elastic-operator elastic/eck-operator \
-n apm --create-namespace \
--values="eck-operator/values.yaml" \
--set=installCRDs=false \
--set=managedNamespaces='{apm,}' \
--set=createClusterScopedResources=false \
--set=webhook.enabled=false \
--set=config.validateStorageClass=false
eck-operator 图表包含多个预定义的配置文件,可帮助您在不同的配置中安装 operator。这些配置文件可以在图表目录的根目录中找到,以 profile- 为前缀。例如,前面的代码提取中所示的受限配置是在 profile-restricted.yaml 文件中定义的。
查看可用的配置选项
您可以通过运行以下命令来查看所有可配置值:
helm show values elastic/eck-operator -n apm
验证服务
验证一下是否安装成功
[root@node1 ~]# kubectl get pods -n apm
NAME READY STATUS RESTARTS AGE
elastic-operator-0 1/1 Running 0 5m29s
监控 operator 日志:
kubectl -n apm logs -f statefulset.apps/elastic-operator
这个时候会安装上若干个 CRD 对象,当然这些 CRD 资源的控制器就在上面的 elastic-operator-0 这个 Pod 中:
$ kubectl get crd | grep elastic
agents.agent.k8s.elastic.co 2024-05-08T03:26:15Z
apmservers.apm.k8s.elastic.co 2024-05-08T03:26:15Z
beats.beat.k8s.elastic.co 2024-05-08T03:26:15Z
elasticmapsservers.maps.k8s.elastic.co 2024-05-08T03:26:15Z
elasticsearchautoscalers.autoscaling.k8s.elastic.co 2024-05-08T03:26:15Z
elasticsearches.elasticsearch.k8s.elastic.co 2024-05-08T03:26:15Z
enterprisesearches.enterprisesearch.k8s.elastic.co 2024-05-08T03:26:15Z
kibanas.kibana.k8s.elastic.co 2024-05-08T03:26:15Z
logstashes.logstash.k8s.elastic.co 2024-05-08T03:26:15Z
stackconfigpolicies.stackconfigpolicy.k8s.elastic.co 2024-05-08T03:26:15Z
然后我们可以利用 CRD 对象来创建一个非常简单的单个 Elasticsearch 集群
创建ES存储
创建存储类
创建华为云sfs存储类
创建文件 sfsturbo-es-sc.yaml
---
apiVersion: storage.k8s.io/v1
allowVolumeExpansion: true
kind: StorageClass
metadata:
name: sfsturbo-es-sc
mountOptions:
- vers=3
- nolock
- timeo=600
- hard
parameters:
csi.storage.k8s.io/csi-driver-name: sfsturbo.csi.everest.io
csi.storage.k8s.io/fstype: nfs
everest.io/archive-on-delete: "true"
everest.io/share-access-to: 4f9789b0-xxxx-xxxx-xxxx-cxxxx75dxxxx # subpath模式下,填写SFS Turbo资源的所在VPC的ID。
everest.io/share-export-location: 3967e677-xxxx-xxxx-xxxx-xxxxxxx8xxxx.sfsturbo.internal:/APM/Elasticsearch
everest.io/share-source: sfs-turbo
everest.io/volume-as: subpath # 该参数需设置为“subpath”来使用subpath模式。
everest.io/volume-id: 3967e677-xxxx-xxxx-xxxx-xxxx3xxxxxxx # SFS Turbo资源的卷ID
provisioner: everest-csi-provisioner
allowVolumeExpansion: true
volumeBindingMode: Immediate
reclaimPolicy: Retain
创建nfs存储类
1. 安装配置nfs
# 所有节点安装nfs客户端
# 本文k8s节点系统版本为 RockyLinux 9.2
yum