最佳实践
本文以
elasticsearch
、kibana
为例
# elasticsearch
- 通过 Artifact Hub (opens new window) 搜索要安装的服务
- 找到 elasticsearch 8.5.1・elastic/elastic (opens new window)
根据文档说明进行如下操作
# 添加 Elastic Helm charts repo
helm repo add elastic https://helm.elastic.co
# 安装
helm install elasticsearch elastic/elasticsearch
# 执行安装命令后,从终端可知,通过此命令获取默认密码
kubectl get secrets --namespace=default elasticsearch-master-credentials -ojsonpath='{.data.password}' | base64 -d
# 或通过保密字典elasticsearch-master-credentials可知
通过 Service 地址访问: https://serice-ip:9200
- 账号:
elastic
- 密码:elasticsearch-master-credentials 可知
9200和9300端口的区别
9200 作为 Http 协议,主要用于外部通讯
9300 作为 Tcp 协议,jar 之间就是通过 tcp 协议通讯
ES 集群之间是通过 9300 进行通讯
# kibana
由于 kibana 修改中文修改在 yaml 配置中设置,因此这里使用另一种方式安装
# 添加repo;(安装elasticsearch时已经添加过了)
#helm repo add elastic https://helm.elastic.co
# 拉取
helm pull elastic/kibana --untar
cd kibana
vim values.yaml
找到
kibanaConfig: {}
# kibana.yml: |
# key:
# nestedkey: value
修改为
kibanaConfig:
kibana.yml: |
i18n.locale: "zh-CN"
笔记
之后就可以通过容器挂载的 kibana-kibana-config
配置修改,值得注意的是,values.yaml 使用默认配置,即 kibanaConfig: {}
时,是不会生成 k8s 配置 kibana-kibana-config
的
# 回到上一级
cd ..
# 本地安装
helm install kibana kibana
# 由于我是安装后才发现需要修改配置才可以改中文,执行下面命令更新配置
#helm upgrade kibana elastic/kibana -f values.yaml
笔记
- 默认链接的 es url 为
https://elasticsearch-master:9200
,配合上面的 elasticsearch 安装是可以直接连接上的。
访问 http://serice-ip:5601
- 账号、密码为 es
记一次kibana卸载重新安装报错
helm install kibana kibana
Error: INSTALLATION FAILED: failed pre-install: warning: Hook pre-install kibana/templates/pre-install-serviceaccount.yaml failed: serviceaccounts "pre-install-kibana-kibana" already exists
# 删除 serviceaccount
kubectl delete serviceaccount pre-install-kibana-kibana
helm install kibana kibana
Error: INSTALLATION FAILED: failed pre-install: warning: Hook pre-install kibana/templates/pre-install-role.yaml failed: roles.rbac.authorization.k8s.io "pre-install-kibana-kibana" already exists
# 删除role
kubectl delete role pre-install-kibana-kibana
helm uninstall kibana
Error: uninstallation completed with 1 error(s): warning: Hook post-delete kibana/templates/configmap-helm-scripts.yaml failed: configmaps "kibana-kibana-helm-scripts" already exists
# 删除configmap
kubectl delete configmap kibana-kibana-helm-scripts
helm install kibana kibana
Error: INSTALLATION FAILED: failed pre-install: warning: Hook pre-install kibana/templates/pre-install-rolebinding.yaml failed: rolebindings.rbac.authorization.k8s.io "pre-install-kibana-kibana" already exists
# 删除rolebinding
kubectl delete rolebinding pre-install-kibana-kibana
上次更新: 2023/12/02, 15:28:12