$ helm repo list |grep bitnami

如果没有,还需额外增加此仓库

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

2、下载ElasticSearch的chart包

helm pull bitnami/elasticsearch --untar --version 19.10.2

3、安装ElasticSearch

注意:要保证K8S所有节点内存大于4G,否则ElasticSearch跑不动

(1)因为资源有限,所以调整内存、副本等信息。并且定义SC

[root@master01 ~]# cd  elasticsearch
[root@master01 elasticsearch]# vi values.yaml
定义  storageClass: "nfs-client"
搜索  memory: 2048Mi  改为  memory: 1024Mi
搜索  heapSize: 1024m 改为  heapSize: 512m
搜索 replicaCount: 2 改为  replicaCount: 1  ##如果是生产环境不要改

第20行处定义SC,修改后内容如下:

storageClass: "nfs-client"

第186-189行替换国外镜像为国内镜像

# 国外镜像
    186 image:
    187   registry: docker.io
    188   repository: bitnami/elasticsearch
    189   tag: 8.8.1-debian-11-r0

# 国内镜像
    186 image:
    187   registry: registry.cn-hangzhou.aliyuncs.com
    188   repository: abroad_images/elasticsearch
    189   tag: 8.8.1-debian-11-r0

第829行处修改memory,修改后内容如下:

memory: 1024Mi

第836行处修改heapSize,修改后内容如下:

heapSize: 512m

第1097行处修改replicaCount,修改后内容如下:

replicaCount: 1

第1836-1839行替换国外镜像为国内镜像

# 国外镜像
   1836   image:
   1837     registry: docker.io
   1838     repository: bitnami/elasticsearch-exporter
   1839     tag: 1.5.0-debian-11-r106

# 国内镜像
   1836   image:
   1837     registry: registry.cn-hangzhou.aliyuncs.com
   1838     repository: abroad_images/elasticsearch-exporter
   1839     tag: 1.5.0-debian-11-r106

第2169-2172行替换国外镜像为国内镜像

# 国外镜像

   2169   image:
   2170     registry: docker.io
   2171     repository: bitnami/bitnami-shell
   2172     tag: 11-debian-11-r123

# 国内镜像

   2169   image:
   2170     registry: registry.cn-hangzhou.aliyuncs.com
   2171     repository: abroad_images/bitnami-shell
   2172     tag: 11-debian-11-r123

(2)安装

[root@master01 elasticsearch]# helm install skywalking-es .
NAME: skywalking-es
LAST DEPLOYED: Fri Nov  3 21:06:13 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: elasticsearch
CHART VERSION: 19.10.2
APP VERSION: 8.8.1

-------------------------------------------------------------------------------
 WARNING

    Elasticsearch requires some changes in the kernel of the host machine to
    work as expected. If those values are not set in the underlying operating
    system, the ES containers fail to boot with ERROR messages.

    More information about these requirements can be found in the links below:

      https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html
      https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html

    This chart uses a privileged initContainer to change those settings in the Kernel
    by running: sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536

** Please be patient while the chart is being deployed **

  Elasticsearch can be accessed within the cluster on port 9200 at skywalking-es-elasticsearch.default.svc.cluster.local

  To access from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/skywalking-es-elasticsearch 9200:9200 &
    curl http://127.0.0.1:9200/

(3)在master01节点上查看pod

[root@master01 elasticsearch]# kubectl get po
NAME                                         READY   STATUS    RESTARTS   AGE
skywalking-es-elasticsearch-coordinating-0   1/1     Running   0          11h
skywalking-es-elasticsearch-data-0           1/1     Running   0          11h
skywalking-es-elasticsearch-data-1           1/1     Running   0          11h
skywalking-es-elasticsearch-ingest-0         1/1     Running   0          11h
skywalking-es-elasticsearch-ingest-1         1/1     Running   0          11h
skywalking-es-elasticsearch-master-0         1/1     Running   0          11h
skywalking-es-elasticsearch-master-1         1/1     Running   0          11h

(4)在master01节点上查看svc

[root@master01 elasticsearch]# kubectl get svc
NAME                                          TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)             AGE
kubernetes                                    ClusterIP   10.0.0.1     <none>        443/TCP             2d14h
skywalking-es-elasticsearch                   ClusterIP   10.0.92.27   <none>        9200/TCP,9300/TCP   11h
skywalking-es-elasticsearch-coordinating-hl   ClusterIP   None         <none>        9200/TCP,9300/TCP   11h
skywalking-es-elasticsearch-data-hl           ClusterIP   None         <none>        9200/TCP,9300/TCP   11h
skywalking-es-elasticsearch-ingest-hl         ClusterIP   None         <none>        9200/TCP,9300/TCP   11h
skywalking-es-elasticsearch-master-hl         ClusterIP   None         <none>        9200/TCP,9300/TCP   11h

(5)访问es

[root@master01 elasticsearch]# curl 10.0.92.27:9200
{
  "name" : "skywalking-es-elasticsearch-coordinating-0",
  "cluster_name" : "elastic",
  "cluster_uuid" : "7l6jGZ7JTBOVi5f4lFa7Jw",
  "version" : {
    "number" : "8.8.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "f8edfccba429b6477927a7c1ce1bc6729521305e",
    "build_date" : "2023-06-05T21:32:25.188464208Z",
    "build_snapshot" : false,
    "lucene_version" : "9.6.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}