k8s部署elasticsearch
Contents
安装ECK
|
|
安装Elasticsearch
|
|
|
|
安装Kibana
|
|
|
|
安装Filebeat
试试helm安装filebeat,真香!
|
|
修改values.yaml中daemonset的内容
output.elasticsearch:
host: '${NODE_NAME}'
hosts: '${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}'
为:
output.elasticsearch:
host: '${NODE_NAME}'
hosts: '${ELASTICSEARCH_HOSTS:elasticsearch-master:9200}'
username: '${ELASTICSEARCH_USERNAME}'
password: '${ELASTICSEARCH_PASSWORD}'
|
|
踩坑
查看错误
yanyong@newmaster:~/k8s/elastic$ kubectl describe kibana | grep -A 10 Events:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning AssociationError 5m12s (x4 over 5m12s) kibana-controller Association backend for elasticsearch is not configured
Normal AssociationStatusChange 5m12s kb-es-association-controller Association status changed from [] to [Pending]
或者,查看错误
yanyong@newmaster:~/k8s/elastic$ kubectl get events | tail
32m Warning AssociationError kibana/quickstart Association backend for elasticsearch is not configured
32m Normal AssociationStatusChange kibana/quickstart Association status changed from [] to [Pending]
查看日志
yanyong@newmaster:~/k8s/elastic$ kubectl logs elastic-operator-0 -n elastic-system | tail -1
{"log.level":"error","@timestamp":"2022-04-21T06:53:30.967Z","log.logger":"manager.eck-operator.controller.kb-es-association-controller","message":"Reconciler error","service.version":"2.1.0+02a8d7c7","service.type":"eck","ecs.version":"1.4.0","name":"quickstart","namespace":"default","error":"no port named [http] in service [default/es7163-es-http]","errorCauses":[{"error":"no port named [http] in service [default/es7163-es-http]"}],"error.stack_trace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
解决办法
部署elasticsearch时添加name: http
spec:
version: 7.16.3
http:
tls:
selfSignedCertificate:
disabled: true
service:
spec:
type: NodePort
ports:
- name: http
port: 9200
targetPort: 9200
https://www.elastic.co/downloads/elastic-cloud-kubernetes
https://www.elastic.co/guide/en/cloud-on-k8s/2.1/k8s-deploy-elasticsearch.html
https://github.com/elastic/cloud-on-k8s/blob/2.1/config/samples/elasticsearch/elasticsearch.yaml
https://www.elastic.co/guide/en/cloud-on-k8s/2.1/k8s-deploy-kibana.html
https://github.com/elastic/cloud-on-k8s/blob/2.1/config/samples/kibana/kibana_es.yaml
https://www.elastic.co/cn/beats/filebeat
https://www.elastic.co/downloads/beats/filebeat
https://github.com/elastic/helm-charts/tree/main/filebeat
https://github.com/elastic/helm-charts/blob/7.16/filebeat/values.yaml
https://github.com/elastic/helm-charts/blob/main/filebeat/examples/security/values.yaml