关于helm:Helm3安装ElasticSearch和Kibana

6次阅读

共计 6014 个字符,预计需要花费 16 分钟才能阅读完成。

前言

因为本人的网站要做全文检索性能,自身我是应用 mongodb 做为数据库的,然而思考到前期数据量十分大而且用户体验也要跟上,所以筹备动手 elasticsearch 做为我的站内搜索,现分享给大家。

装置

看过我文章的小伙伴应该晓得,之前曾经应用过 helm3 装置过 redis、rabbitmq,所以套路都是一样的,咱们先来搜寻 elasticsearch 和 kibana。

命令:

helm search repo elasticsearch
helm search repo kibana

输入:

NAME                             CHART VERSION    APP VERSION    DESCRIPTION
bitnami/elasticsearch            18.2.9           8.2.2          Elasticsearch is a distributed search and analy...
elastic/elasticsearch            7.17.3           7.17.3         Official Elastic helm chart for Elasticsearch
stable/elasticsearch             1.32.5           6.8.6          DEPRECATED Flexible and powerful open source, d...
stable/elasticsearch-curator     2.2.3            5.7.6          DEPRECATED A Helm chart for Elasticsearch Curator
stable/elasticsearch-exporter    3.7.0            1.1.0          Elasticsearch stats exporter for Prometheus
bitnami/dataplatform-bp2         12.0.3           1.0.1          This Helm chart can be used for the automated d...
bitnami/grafana                  7.6.5            8.3.4          Grafana is an open source, feature rich metrics...
bitnami/kibana                   10.1.9           8.2.2          Kibana is an open source, browser based analyti...
elastic/eck-operator             2.2.0            2.2.0          A Helm chart for deploying the Elastic Cloud on...
stable/apm-server                2.1.7            7.0.0          DEPRECATED The server receives data from the El...
stable/dmarc2logstash            1.3.1            1.0.3          DEPRECATED Provides a POP3-polled DMARC XML rep...
stable/elastabot                 1.2.1            1.1.0          DEPRECATED A Helm chart for Elastabot - a Slack...
stable/elastalert                1.5.1            0.2.4          DEPRECATED ElastAlert is a simple framework for...
stable/fluentd                   2.5.3            v2.4.0         DEPRECATED A Fluentd Elasticsearch Helm chart f...
stable/kibana                    3.2.7            6.7.0          Kibana is an open source data visualization plu...
elastic/eck-operator-crds        2.2.0            2.2.0          A Helm chart for installing the ECK operator Cu...
NAME                         CHART VERSION    APP VERSION    DESCRIPTION
bitnami/kibana               10.1.9           8.2.2          Kibana is an open source, browser based analyti...
elastic/kibana               7.17.3           7.17.3         Official Elastic helm chart for Kibana
stable/kibana                3.2.7            6.7.0          Kibana is an open source data visualization plu...
elastic/eck-operator         2.2.0            2.2.0          A Helm chart for deploying the Elastic Cloud on...
bitnami/dataplatform-bp2     12.0.3           1.0.1          This Helm chart can be used for the automated d...
elastic/eck-operator-crds    2.2.0            2.2.0          A Helm chart for installing the ECK operator Cu...

而后找到本人想要的 repo 拉下来,比方我这里选用的是 bitnami/elasticsearch 和 bitnami/kibana,接着输出以下命令:

命令:

helm pull bitnami/elasticsearch
helm pull bitnami/kibana

下载下来之后,咱们先关上 elasticsearch 的 values.yaml 文件,查阅之后,咱们设置咱们想要的配置如下所示:

elasticsearch values.yaml

global:
  storageClass: "alicloud-cnfs-nas"
  elasticsearch:
    service:
      name: elasticsearch
      ports:
        restAPI: 9200
  kibanaEnabled: false
service:
  type: NodePort
master:
  replicaCount: 1
data:
  replicaCount: 1
coordinating:
  replicaCount: 1
ingest:
  replicaCount: 1

留神:因为我应用的是阿里云的 K8S 所以 storageClass 我用的是 alicloud-cnfs,之前文章有说过如何装置,有趣味的能够前去查看,之后正本我都应用的是 1,起因也是想节约资源。

配置好之后,接下来咱们来装置,命令如下:

helm install -f test-values.yaml test-elasticsearch bitnami/elasticsearch --namespace elasticsearch

输入:

NAME: test-elasticsearch
LAST DEPLOYED: Wed Jun 15 10:11:40 2022
NAMESPACE: elasticsearch
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: elasticsearch
CHART VERSION: 18.2.10
APP VERSION: 8.2.2

-------------------------------------------------------------------------------
 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 test-elasticsearch.elasticsearch.svc.cluster.local

  To access from outside the cluster execute the following commands:

    export NODE_PORT=$(kubectl get --namespace elasticsearch -o jsonpath="{.spec.ports[0].nodePort}" services test-elasticsearch)
    export NODE_IP=$(kubectl get nodes --namespace elasticsearch -o jsonpath="{.items[0].status.addresses[0].address}")
    curl http://$NODE_IP:$NODE_PORT/

这样就装置好了,接下来,咱们通过以下命令来获取 IP 和 PORT 目标是拜访咱们曾经装置好的 elasticsearch

# 获取端口
kubectl get --namespace elasticsearch -o jsonpath="{.spec.ports[0].nodePort}" services test-elasticsearch

# 获取 IP
kubectl get nodes --namespace elasticsearch -o jsonpath="{.items[0].status.addresses[0].address}"

实现获取之后,咱们把地址关上会呈现如下显示,则证实装置胜利。

{
  "name" : "test-elasticsearch-coordinating-0",
  "cluster_name" : "elastic",
  "cluster_uuid" : "fd9jc0k3QY2E5wYHgcGNbA",
  "version" : {
    "number" : "8.2.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "9876968ef3c745186b94fdabd4483e01499224ef",
    "build_date" : "2022-05-25T15:47:06.259735307Z",
    "build_snapshot" : false,
    "lucene_version" : "9.1.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

装置好之后,接下来咱们装置 kibana,跟装置 elasticsearch 相似,咱们配置一下 pull 下来的 values.yaml 文件

service:
  type: NodePort
elasticsearch:
  hosts: [your-elasticsearch-ip]
  port: your-elasticsearch-port
persistence:
  storageClass: "alicloud-cnfs-nas"
  size: 10Gi

配置完之后,咱们执行一下命令:

helm install -f test-values.yaml test-kibana bitnami/kibana --namespace elasticsearch

输入:

NAME: test-kibana
LAST DEPLOYED: Wed Jun 15 21:55:26 2022
NAMESPACE: elasticsearch
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: kibana
CHART VERSION: 10.1.9
APP VERSION: 8.2.2

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

1. Get the application URL by running these commands:
  export NODE_PORT=$(kubectl get --namespace elasticsearch -o jsonpath="{.spec.ports[0].nodePort}" services test-kibana)
  export NODE_IP=$(kubectl get nodes --namespace elasticsearch -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT

WARNING: Kibana is externally accessible from the cluster but the dashboard does not contain authentication mechanisms. Make sure you follow the authentication guidelines in your Elastic stack.
+info https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-up-authentication.html

这样就装置好了,接下来,咱们通过以下命令来获取 IP 和 PORT 目标是拜访咱们曾经装置好的 elasticsearch

# 获取端口
kubectl get --namespace elasticsearch -o jsonpath="{.spec.ports[0].nodePort}" services test-kibana

# 获取 IP
kubectl get nodes --namespace elasticsearch -o jsonpath="{.items[0].status.addresses[0].address}"

实现获取之后,咱们把地址关上会呈现如下显示,则证实装置胜利,当初开始你的 elasticsearch 之旅吧。

总结

1、bitnami/elasticsearch 曾经集成了 kibana,就看你想应用集成的还是独立的了

援用

Springboot + ElasticSearch 构建博客检索系统

正文完
 0