Git Product home page Git Product logo

elasticsearch-cluster-kubernetes's Introduction

elasticsearch-k8s-glusterfs-heketi

在k8s中部署elasticsearch集群有两个难点,1、服务高可用,2、数据持久化。

elasticsearch集群高可用部署方案

elasticsearch使用单一角色进行部署,使用单一角色的好处是:增强es集群的稳定性、可用性,以及便于维护。

master节点:3个
data节点:3个
client节点:2个

并且设置pod排斥性调度,使同一角色的pod尽量分布在不同node上。

es的docker镜像

es镜像基于5.6.4版本,进行了两个方面的修改:1、打入了结巴分词工具。2、设置服务发现域名(elasticsearch-discovery)。详情查看es-images

kubernetes的数据持久化方案

使用独立的Glusterfs集群存储数据,具体的安装配置参考glusterfs-heketi。 在k8s中,为了增强数据可用性,master节点和data节点的部署使用有状态的StatefulSet,而不是无状态的deployment。stateful状态的pod如果失败,将会自动救活和重启,而不是重新部署pod。这样就可以保证数据在pod重启之后不会丢失。在数据层面,使用网络存储的方式保存数据,把k8s中的数据存储到远程的glusterfs中。创建步骤如下:

部署

首先创建storageclass,启动服务发现和master节点:

kubectl create -f gluster-storage-class.yaml
kubectl create -f es-discovery-svc.yaml
kubectl create -f es-svc.yaml
kubectl craete -f es-master-svc.yaml
kubectl create -f es-master-stateful-gfs.yaml

等到master 节点起来之后,部署client和data节点

kubectl create -f es-client.yaml
kubectl create -f es-data-svc.yaml
kubectl create -f es-data-stateful-gfs.yaml

测试

得到server的cluster-ip:

 kubectl get svc elasticsearch
NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
elasticsearch   ClusterIP   10.100.220.56   <none>        9200/TCP   3m

测试es的健康状态:

$ curl http://10.100.220.56:9200/_cluster/health?pretty

elasticsearch-cluster-kubernetes's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.