k8s(helm)安装ES集群

ES官方helm文档地址:https://github.com/elastic/helm-charts/tree/master/elasticsearch
本文档中使用的helm:https://github.com/elastic/helm-charts/tree/7.13/elasticsearch

添加ES的helm仓库并查看helm的仓库列表

$ helm repo add elastic https://helm.elastic.co
"elastic" has been added to your repositories

$ helm repo list
NAME    URL
elastic https://helm.elastic.co

获取指定版本es的chart包

$ helm pull --version 7.13.2 elastic/elasticsearch

$ ls |grep ela
elasticsearch-7.13.2.tgz

解压Chart包并根据需要修改values.yaml文件

$ tar xf elasticsearch-7.13.2.tgz
$ cd elasticsearch
$ cp values.yaml{,.bak}
$ vim values.yaml

下面是已经改好的values文件,仅供参考。

注意集群中一定要有一个默认的存储类,默认模板无法手动指定存储类名称。(有存储类没有设置默认请使用命令设置默认存储类,否则无法动态创建pv )

---
# 集群通过helm删除后新集群使用原来的pvc挂载时,注意clusterName和nodeGroup的名称和被删除的一致,否则找不到磁盘无法恢复数据
clusterName: "elasticsearch"
nodeGroup: "master"

# 如果未修改clusterName和nodeGroup这里默认空即可
# 如果修改了clusterName和nodeGroup这里需要改成 "$clusterName-$masterNodeGroup"
masterService: ""

# 配置Pod镜像信息
image: "docker.elastic.co/elasticsearch/elasticsearch"
imageTag: "7.13.2"
imagePullPolicy: "IfNotPresent"
imagePullSecrets: []

# StatefulSet 的 副本数
replicas: 3

# 添加pod的注解信息
podAnnotations: {}
  # iam.amazonaws.com/role: es-cluster

# 为pod附加自定义标签
labels: {}

# Pod的优先级配置
priorityClassName: ""
# 是否为sts开启数据持久化的功能 
persistence:
  enabled: true
  labels:
    # Add default labels for the volumeClaimTemplate of the StatefulSet
    enabled: false
  annotations: {}

# 持久化存储动态存储配置,存储类名称一定要指定。
# 生产环境使用 “alicloud-disk-efficiency-retains” 存储类 > 当chart删除后数据保留,alicloud-disk-efficiency为chart删除数据一同删除
volumeClaimTemplate:
  accessModes: [ "ReadWriteOnce" ]
  storageClassName: "alicloud-disk-efficiency"
  resources:
    requests:
      storage: 20Gi

# 自定义配置JVM堆栈信息
esJavaOpts: "-Duser.timezone=GMT+08" # example: "-Xmx1g -Xms1g -Duser.timezone=GMT+08"

# Pod资源限制配置
resources:
  requests:
    cpu: "500m"
    memory: "1Gi"
  limits:
    cpu: "1000m"
    memory: "2Gi"

# 集群中角色相关的配置信息
roles:
  # 主节点负责集群范围内的元数据(即Cluster State)相关的操作,例如创建或删除索引,跟踪哪些节点是集群的一部分以及确定将哪些 shard 分配给哪些节点。 拥有稳定的主节点对于群集健康非常重要
  master: "true"
  # 堆栈监控节点
  ingest: "true"
  # 数据节点包含包含已建立索引的文档的分片。 数据节点处理与数据相关的操作,例如 CRUD,搜索和聚合
  data: "true"
  # 跨集群连接时需要用到的client节点
  remote_cluster_client: "true"
  # 机器学习节点提供了机器学习功能,该节点运行作业并处理机器学习 API 请求
  ml: "false"

service:
  # 为非无头服务svc添加自定义标签
  labels: {}
  # 为无头服务svc添加自定义标签
  labelsHeadless: {}
  # 配置service的类型
  type: NodePort
  # 如果type:nodePort那么我们可以手动指定节点端口号,为空则随机一个节点端口号
  nodePort: "32222"
  # 为服务的LoadBalancer添加注释。如果service.type是LoadBalancer,这将配置负载平衡器LoadBalancer
  annotations: {}
  # svc中 http 端口的名称
  httpPortName: http
  # svc中传输端口的名称
  transportPortName: transport
  # 一些云提供商允许您指定loadBalancer IP。如果loadBalancerIP未指定该字段,则动态分配 IP。如果您指定了loadBalancerIP但云提供商不支持该功能,则它会被忽略
  loadBalancerIP: ""
  loadBalancerSourceRanges: []
  # 一些云提供商允许您指定LoadBalancer externalTrafficPolicy。如果service.type是LoadBalancer将使用它来保留客户端源 IP。
  externalTrafficPolicy: ""

# 将用于就绪探测的协议
protocol: http
# 用于运行状况检查和服务的 http 端口。如果此参数修改,你还需要配置服务端口 http.port 在extraEnvs环境变量中。
httpPort: 9200
# 用于服务的传输端口。如果此参数修改,,你还需要配置传输端口 transport.port 在extraEnvs环境变量中
transportPort: 9300

# StatefulSet的pod更新策略。默认情况下会在升级每个 Pod 后等待集群变为绿色后再更新下一个。将此设置为OnDelete将允许您在升级期间手动删除每个pod
updateStrategy: RollingUpdate

# 最少master节点数量应该设置为(master_eligible_nodes / 2) + 1
minimumMasterNodes: 2

# 自定义 elasticsearch.yml 和 log4j2.properties 配置
esConfig: {}
#  elasticsearch.yml: |
#    path.repo: ["/tmp"]
#  log4j2.properties: |
#    key = value

# 注入自定义环境变量信息
extraEnvs: []
#  - name: MY_ENVIRONMENT_VAR
#    value: the_value_goes_here

# 通过secret或configMap映射加载环境变量
envFrom: []
# - secretRef:
#     name: env-secret
# - configMapRef:
#     name: config-map

# 挂载secret到pod中安装证书和其他secret
secretMounts: []
#  - name: elastic-certificates
#    secretName: elastic-certificates
#    path: /usr/share/elasticsearch/config/certs
#    defaultMode: 0755

# 向Pod中的 /etc/hosts 添加自定义条目
hostAliases: []
#- ip: "127.0.0.1"
#  hostnames:
#  - "foo.local"
#  - "bar.local"

# init初始化容器的资源限制
initResources: {}
  # limits:
  #   cpu: "25m"
  #   # memory: "128Mi"
  # requests:
  #   cpu: "25m"
  #   memory: "128Mi"

# 自定义配置es服务监听的地址
networkHost: "0.0.0.0"

# rbac配置如果create:true。则使用外部的sa, ServiceAccountserviceAccountName: "externalServiceAccountName"
rbac:
  create: false
  serviceAccountAnnotations: {}
  serviceAccountName: ""

# 是否创建具有最小权限的 pod 安全策略的配置,如果create: true则自动创建默认. 也可以create: true在name:"externalPodSecurityPolicy"指定自定义的安全策略
podSecurityPolicy:
  create: false
  name: ""
  spec:
    privileged: true
    fsGroup:
      rule: RunAsAny
    runAsUser:
      rule: RunAsAny
    seLinux:
      rule: RunAsAny
    supplementalGroups:
      rule: RunAsAny
    volumes:
      - secret
      - configMap
      - persistentVolumeClaim
      - emptyDir

# 添加额外的Volumes模板配置
extraVolumes: # []
  - name: timezone
    hostPath:
      path: /etc/localtime

# 使用挂载额外的volumes配置
extraVolumeMounts: # []
  - name: timezone
    mountPath: /etc/localtime
    readOnly: true

# 附加额外的容器
extraContainers: []
  # - name: do-something
  #   image: busybox
  #   command: ['do', 'something']

# 附加初始化容器
extraInitContainers: []
  # - name: do-something
  #   image: busybox
  #   command: ['do', 'something']

# 配置pod的反亲和性规则,默认配置将使pod不会部署在同一个节点。
# By default this will make sure two pods don't end up on the same node
# Changing this to a region would allow you to spread pods across regions
antiAffinityTopologyKey: "kubernetes.io/hostname"

# 默认值为:hard 这意味着硬性强制反亲和规则,没有满足pod则不会创建
# 如果设置为:soft 意味着软性反亲和规则,尽可能根据反亲和规则不部署pod在同一个节点上
antiAffinity: "soft"

# 配置节点的亲和性规则
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature
nodeAffinity: {}

# 默认设置是串行部署所有pod(有序启动-有序删除)。通过将此设置为“平行”,所有Pod将在pod启动时一次性全部启动
podManagementPolicy: "Parallel"

# 服务链接注入的环境变量不被使用,但是当
# 当前命名空间中有许多服务。
# 如果你经历了缓慢的pod启动,你可能想把它设置为“false”。
enableServiceLinks: true

# 这是pod中断预算的最大不可用设置
# 默认值为1 将确保pod中断不允许超过1
# pod在维护期间的最大不可用数量
maxUnavailable: 1

# 为 pod设置securityContext
podSecurityContext:
  fsGroup: 1000
  runAsUser: 1000

# 为容器设置securityContext
securityContext:
  capabilities:
    drop:
    - ALL
  # readOnlyRootFilesystem: true
  runAsNonRoot: true
  runAsUser: 1000

# pod优雅关闭的等待时间,超出将强制干掉pod
terminationGracePeriod: 120

# 设置Elasticsearch 所需的sysctl vm.max_map_count
sysctlVmMaxMapCount: 262144

# 就绪检查配置参数
readinessProbe:
  # 检查失败后尝试的次数
  failureThreshold: 3
  # 容器启动后多少秒开始进行检查
  initialDelaySeconds: 10
  # 两次健康检查的间隔时间
  periodSeconds: 10
  # 失败后检查成功的连续次数
  successThreshold: 3
  # 健康检查超时秒数
  timeoutSeconds: 5

# 集群健康检查的接口参数 GET /_cluster/health?wait_for_status=yellow&timeout=50s
# https://www.elastic.co/guide/en/elasticsearch/reference/7.13/cluster-health.html#request-params wait_for_status
clusterHealthCheckParams: "wait_for_status=green&timeout=1s"

# 使用的自定义调度器名称
schedulerName: ""
# 选择指定节点启动pod
nodeSelector: {}
# 节点污点容忍配置
tolerations: []

# 通过ingress暴露集群
ingress:
  enabled: false
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: chart-example.local
      paths:
        - path: /
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

#  指定pod启动前执行的钩子 和pod停止前执行的钩子
lifecycle: {}
  # preStop:
  #   exec:
  #     command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
  # postStart:
  #   exec:
  #     command:
  #       - bash
  #       - -c
  #       - |
  #         #!/bin/bash
  #         # Add a template to adjust number of shards/replicas
  #         TEMPLATE_NAME=my_template
  #         INDEX_PATTERN="logstash-*"
  #         SHARD_COUNT=8
  #         REPLICA_COUNT=1
  #         ES_URL=http://localhost:9200
  #         while [[ "$(curl -s -o /dev/null -w '%{http_code}\n' $ES_URL)" != "200" ]]; do sleep 1; done
  #         curl -XPUT "$ES_URL/_template/$TEMPLATE_NAME" -H 'Content-Type: application/json' -d'{"index_patterns":['\""$INDEX_PATTERN"\"'],"settings":{"number_of_shards":'$SHARD_COUNT',"number_of_replicas":'$REPLICA_COUNT'}}'

# 如果使用另一种方法设置sysctl vm.max_map_count,则允许禁用
sysctlInitContainer:
  enabled: true

# 自定义秘钥库
keystore: []

# 配置网络策略
networkPolicy:
  ## Enable creation of NetworkPolicy resources. Only Ingress traffic is filtered for now.
  ## In order for a Pod to access Elasticsearch, it needs to have the following label:
  ## {{ template "uname" . }}-client: "true"
  ## Example for default configuration to access HTTP port:
  ## elasticsearch-master-http-client: "true"
  ## Example for default configuration to access transport port:
  ## elasticsearch-master-transport-client: "true"

  http:
    enabled: false
    ## if explicitNamespacesSelector is not set or set to {}, only client Pods being in the networkPolicy's namespace
    ## and matching all criteria can reach the DB.
    ## But sometimes, we want the Pods to be accessible to clients from other namespaces, in this case, we can use this
    ## parameter to select these namespaces
    ##
    # explicitNamespacesSelector:
    #   # Accept from namespaces with all those different rules (only from whitelisted Pods)
    #   matchLabels:
    #     role: frontend
    #   matchExpressions:
    #     - {key: role, operator: In, values: [frontend]}

    ## Additional NetworkPolicy Ingress "from" rules to set. Note that all rules are OR-ed.
    ##
    # additionalRules:
    #   - podSelector:
    #       matchLabels:
    #         role: frontend
    #   - podSelector:
    #       matchExpressions:
    #         - key: role
    #           operator: In
    #           values:
    #             - frontend

  transport:
    ## Note that all Elasticsearch Pods can talks to themselves using transport port even if enabled.
    enabled: false
    # explicitNamespacesSelector:
    #   matchLabels:
    #     role: frontend
    #   matchExpressions:
    #     - {key: role, operator: In, values: [frontend]}
    # additionalRules:
    #   - podSelector:
    #       matchLabels:
    #         role: frontend
    #   - podSelector:
    #       matchExpressions:
    #         - key: role
    #           operator: In
    #           values:
    #             - frontend

我自己实际部署的配置如下:

---
clusterName: "elasticsearch"
nodeGroup: "master"

# The service that non master groups will try to connect to when joining the cluster
# This should be set to clusterName + "-" + nodeGroup for your master group
masterService: ""

# Elasticsearch roles that will be applied to this nodeGroup
# These will be set as environment variables. E.g. node.master=true
roles:
  master: "true"
  ingest: "true"
  data: "true"
  remote_cluster_client: "true"
  ml: "false"

replicas: 3
minimumMasterNodes: 2

esMajorVersion: ""

# Allows you to add any config files in /usr/share/elasticsearch/config/
# such as elasticsearch.yml and log4j2.properties
esConfig: {}
#  elasticsearch.yml: |
#    key:
#      nestedkey: value
#  log4j2.properties: |
#    key = value

# Extra environment variables to append to this nodeGroup
# This will be appended to the current 'env:' key. You can use any of the kubernetes env
# syntax here
extraEnvs: []
#  - name: MY_ENVIRONMENT_VAR
#    value: the_value_goes_here

# Allows you to load environment variables from kubernetes secret or config map
envFrom: []
# - secretRef:
#     name: env-secret
# - configMapRef:
#     name: config-map

# A list of secrets and their paths to mount inside the pod
# This is useful for mounting certificates for security and for mounting
# the X-Pack license
secretMounts: []
#  - name: elastic-certificates
#    secretName: elastic-certificates
#    path: /usr/share/elasticsearch/config/certs
#    defaultMode: 0755

hostAliases: []
#- ip: "127.0.0.1"
#  hostnames:
#  - "foo.local"
#  - "bar.local"

image: "docker.elastic.co/elasticsearch/elasticsearch"
imageTag: "7.13.2"
imagePullPolicy: "IfNotPresent"

podAnnotations: {}
  # iam.amazonaws.com/role: es-cluster

# additionals labels
labels: {}

esJavaOpts: "" # example: "-Xmx1g -Xms1g"

resources:
  requests:
    cpu: "500m"
    memory: "1Gi"
  limits:
    cpu: "1000m"
    memory: "2Gi"

initResources: {}
  # limits:
  #   cpu: "25m"
  #   # memory: "128Mi"
  # requests:
  #   cpu: "25m"
  #   memory: "128Mi"

networkHost: "0.0.0.0"

volumeClaimTemplate:
  accessModes: [ "ReadWriteOnce" ]
  storageClassName: alibabacloud-common-nas
  resources:
    requests:
      storage: 20Gi

rbac:
  create: false
  serviceAccountAnnotations: {}
  serviceAccountName: ""

podSecurityPolicy:
  create: false
  name: ""
  spec:
    privileged: true
    fsGroup:
      rule: RunAsAny
    runAsUser:
      rule: RunAsAny
    seLinux:
      rule: RunAsAny
    supplementalGroups:
      rule: RunAsAny
    volumes:
      - secret
      - configMap
      - persistentVolumeClaim
      - emptyDir

persistence:
  enabled: true
  labels:
    # Add default labels for the volumeClaimTemplate of the StatefulSet
    enabled: false
  annotations: {}

extraVolumes: []
  # - name: extras
  #   emptyDir: {}

extraVolumeMounts: []
  # - name: extras
  #   mountPath: /usr/share/extras
  #   readOnly: true

extraContainers: []
  # - name: do-something
  #   image: busybox
  #   command: ['do', 'something']

extraInitContainers: []
  # - name: do-something
  #   image: busybox
  #   command: ['do', 'something']

# This is the PriorityClass settings as defined in
# https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass
priorityClassName: ""

# By default this will make sure two pods don't end up on the same node
# Changing this to a region would allow you to spread pods across regions
antiAffinityTopologyKey: "kubernetes.io/hostname"

# Hard means that by default pods will only be scheduled if there are enough nodes for them
# and that they will never end up on the same node. Setting this to soft will do this "best effort"
antiAffinity: "soft"

# This is the node affinity settings as defined in
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature
nodeAffinity: {}

# The default is to deploy all pods serially. By setting this to parallel all pods are started at
# the same time when bootstrapping the cluster
podManagementPolicy: "Parallel"

# The environment variables injected by service links are not used, but can lead to slow Elasticsearch boot times when
# there are many services in the current namespace.
# If you experience slow pod startups you probably want to set this to `false`.
enableServiceLinks: true

protocol: http
httpPort: 9200
transportPort: 9300

service:
  labels: {}
  labelsHeadless: {}
  type: NodePort
  nodePort: "32222"
  annotations: {}
  httpPortName: http
  transportPortName: transport
  loadBalancerIP: ""
  loadBalancerSourceRanges: []
  externalTrafficPolicy: ""

updateStrategy: RollingUpdate

# This is the max unavailable setting for the pod disruption budget
# The default value of 1 will make sure that kubernetes won't allow more than 1
# of your pods to be unavailable during maintenance
maxUnavailable: 1

podSecurityContext:
  fsGroup: 1000
  runAsUser: 1000

securityContext:
  capabilities:
    drop:
    - ALL
  # readOnlyRootFilesystem: true
  runAsNonRoot: true
  runAsUser: 1000

# How long to wait for elasticsearch to stop gracefully
terminationGracePeriod: 120

sysctlVmMaxMapCount: 262144

readinessProbe:
  failureThreshold: 3
  initialDelaySeconds: 10
  periodSeconds: 10
  successThreshold: 3
  timeoutSeconds: 5

# https://www.elastic.co/guide/en/elasticsearch/reference/7.13/cluster-health.html#request-params wait_for_status
clusterHealthCheckParams: "wait_for_status=green&timeout=1s"

## Use an alternate scheduler.
## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/
##
schedulerName: ""

imagePullSecrets: []
nodeSelector: {}
tolerations: []

# Enabling this will publically expose your Elasticsearch instance.
# Only enable this if you have security enabled on your cluster
ingress:
  enabled: true
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: es.test.com
      paths:
        - path: /
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

nameOverride: ""
fullnameOverride: ""

lifecycle: {}
  # preStop:
  #   exec:
  #     command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
  # postStart:
  #   exec:
  #     command:
  #       - bash
  #       - -c
  #       - |
  #         #!/bin/bash
  #         # Add a template to adjust number of shards/replicas
  #         TEMPLATE_NAME=my_template
  #         INDEX_PATTERN="logstash-*"
  #         SHARD_COUNT=8
  #         REPLICA_COUNT=1
  #         ES_URL=http://localhost:9200
  #         while [[ "$(curl -s -o /dev/null -w '%{http_code}\n' $ES_URL)" != "200" ]]; do sleep 1; done
  #         curl -XPUT "$ES_URL/_template/$TEMPLATE_NAME" -H 'Content-Type: application/json' -d'{"index_patterns":['\""$INDEX_PATTERN"\"'],"settings":{"number_of_shards":'$SHARD_COUNT',"number_of_replicas":'$REPLICA_COUNT'}}'

sysctlInitContainer:
  enabled: true

keystore: []

networkPolicy:
  ## Enable creation of NetworkPolicy resources. Only Ingress traffic is filtered for now.
  ## In order for a Pod to access Elasticsearch, it needs to have the following label:
  ## {{ template "uname" . }}-client: "true"
  ## Example for default configuration to access HTTP port:
  ## elasticsearch-master-http-client: "true"
  ## Example for default configuration to access transport port:
  ## elasticsearch-master-transport-client: "true"

  http:
    enabled: false
    ## if explicitNamespacesSelector is not set or set to {}, only client Pods being in the networkPolicy's namespace
    ## and matching all criteria can reach the DB.
    ## But sometimes, we want the Pods to be accessible to clients from other namespaces, in this case, we can use this
    ## parameter to select these namespaces
    ##
    # explicitNamespacesSelector:
    #   # Accept from namespaces with all those different rules (only from whitelisted Pods)
    #   matchLabels:
    #     role: frontend
    #   matchExpressions:
    #     - {key: role, operator: In, values: [frontend]}

    ## Additional NetworkPolicy Ingress "from" rules to set. Note that all rules are OR-ed.
    ##
    # additionalRules:
    #   - podSelector:
    #       matchLabels:
    #         role: frontend
    #   - podSelector:
    #       matchExpressions:
    #         - key: role
    #           operator: In
    #           values:
    #             - frontend

  transport:
    ## Note that all Elasticsearch Pods can talks to themselves using transport port even if enabled.
    enabled: false
    # explicitNamespacesSelector:
    #   matchLabels:
    #     role: frontend
    #   matchExpressions:
    #     - {key: role, operator: In, values: [frontend]}
    # additionalRules:
    #   - podSelector:
    #       matchLabels:
    #         role: frontend
    #   - podSelector:
    #       matchExpressions:
    #         - key: role
    #           operator: In
    #           values:
    #             - frontend

# Deprecated
# please use the above podSecurityContext.fsGroup instead
fsGroup: ""

如果使用的k8s版本是1.21及以上,还需要修改下面两个地方

$ vim  poddisruptionbudget.yaml
apiVersion: policy/v1

vim  ingress.yaml
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "elasticsearch.uname" . -}}
{{- $httpPort := .Values.httpPort -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: networking.k8s.io/v1     #这里需要修改成v1版本
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    app: {{ .Chart.Name }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
  tls:
  {{- if .ingressPath }}
  {{- range .Values.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . }}
      {{- end }}
      secretName: {{ .secretName }}
    {{- end }}
  {{- else }}
{{ toYaml .Values.ingress.tls | indent 4 }}
  {{- end }}
{{- end }}
  rules:
  {{- range .Values.ingress.hosts }}
    {{- if $ingressPath }}
    - host: {{ . }}
      http:
        paths:
          - path: {{ $ingressPath }}
            pathType: Prefix       # 新增 pathType 字段
            backend:
              service:
                name: {{ $fullName }}     # 使用新的 service 字段
                port:
                  number: {{ $httpPort }}       # 使用新的 port.number 字段
    {{- else }}
    - host: {{ .host }}
      http:
        paths:
        {{- range .paths }}
          - path: {{ .path }}
            pathType: Prefix      # 新增 pathType 字段
            backend:
              service:
                name: {{ $fullName }}      # 使用新的 service 字段
                port:
                  number: {{ .servicePort | default $httpPort }}      # 使用新的 port.number 字段
        {{- end }}
    {{- end }}
  {{- end }}
{{- end }}

开始部署

helm install  elasticsearch  -n kube-ops ./elasticsearch

查看helm安装状态

$ kubectl  get all -n kube-ops
NAME                         READY   STATUS    RESTARTS   AGE
pod/elasticsearch-master-0   1/1     Running   0          93m
pod/elasticsearch-master-1   1/1     Running   0          93m
pod/elasticsearch-master-2   1/1     Running   0          93m

NAME                                    TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)                         AGE
service/elasticsearch-master            NodePort    192.168.246.116   <none>        9200:32222/TCP,9300:32754/TCP   93m
service/elasticsearch-master-headless   ClusterIP   None              <none>        9200/TCP,9300/TCP               93m

NAME                                    READY   AGE
statefulset.apps/elasticsearch-master   3/3     93m

NAME                                                                                             AGE
containernetworkfilesystem.storage.alibabacloud.com/cnfs-nas-ca879b7be0bdc459fae2771f2b763f0ce   15d

使用浏览器访问es.test.com或者NodeIP:32222即可访问到集群

ES集群的数据迁移

项目地址:https://github.com/taskrabbit/elasticsearch-dump
部署方式:npm 安装,docker部署
端口:9200 支持夸集群索引复制、支持生成dump文件

集群A数据迁移至集群B
注意提前在目标集群创建好索引以及分片和字段

# 迁移数据
elasticdump --input=http://ip:9200/patent --output=http://nodeIP:32222/patent --type=data --limit=10000 --noRefresh

参数介绍
–input:源es集群地址 patent为源索引名称
–output:目标es集群地址 patent为源索引名称
–type=data:为只迁移数据
–limit=10000:代表每秒迁移多少行数据(最大貌似是10000)
–noRefresh:为不自动刷新,不然每次迁移10000行会自动刷新一次,贼慢。

转自:https://www.putianhui.cn/posts/639b1cad12a9/#elasticsearch-dump

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342

推荐阅读更多精彩内容