K8S 中使用 YAML 安装 ECK
Kubernetes 是目前最受欢迎的容器编排技术,越来越多的应用开始往 Kubernetes 中迁移。Kubernetes 现有的 ReplicaSet、Deployment、Service 等资源对象已经可以满足无状态应用对于自动扩缩容、负载均衡等基本需求。但是对于有状态的、分布式的应用,通常拥有各自的一套模型定义规范,例如 Prometheus,Etcd,Zookeeper,Elasticsearch 等等。部署这些分布式应用往往需要熟悉特定领域的知识,并且在扩缩容和升级时需要考虑如何保证应用服务的可用性等问题。为了简化有状态、分布式应用的部署,Kubernetes Operator 应运而生。
Kubernetes Operator 是一种特定的应用控制器,通过 CRD(Custom Resource Definitions,自定义资源定义)扩展 Kubernetes API 的功能,可以用它来创建、配置和管理特定的有状态应用,而不需要直接去使用 Kubernetes 中最原始的一些资源对象,比如 Pod,Deployment,Service 等等。
Elastic Cloud on Kubernetes(ECK) 是其中的一种 Kubernetes Operator,方便我们管理 Elastic Stack 家族中的各种组件,例如 Elasticsearch,Kibana,APM,Beats 等等。比如只需要定义一个 Elasticsearch 类型的 CRD 对象,ECK 就可以帮助我们快速搭建出一套 Elasticsearch 集群。
使用create安装Elastic的自定义资源定义
- [root@k8s-192-168-1-140 ~]# kubectl create -f https://download.elastic.co/downloads/eck/3.2.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/elasticsearchautoscalers.autoscaling.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
- customresourcedefinition.apiextensions.k8s.io/logstashes.logstash.k8s.elastic.co created
- customresourcedefinition.apiextensions.k8s.io/stackconfigpolicies.stackconfigpolicy.k8s.elastic.co created
- [root@k8s-192-168-1-140 ~]#
复制代码 使用kubectl apply 安装operator及其RBAC规则
- [root@k8s-192-168-1-140 ~]# kubectl apply -f https://download.elastic.co/downloads/eck/3.2.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-192-168-1-140 ~]#
复制代码 查看是否启动完成
- [root@k8s-192-168-1-140 ~]kubectl get -n elastic-system pods
- NAME READY STATUS RESTARTS AGE
- elastic-operator-0 1/1 Running 0 8m38s
- [root@k8s-192-168-1-140 ~]#
复制代码 启动部署
Operator自动创建和管理Kubernetes资源,以实现Elasticsearch集群的期望状态。可能需要几分钟的时间才能创建所有资源并准备好使用群集。
[code]cat |
|
|
|
|
|
相关推荐
|
|
|