自动采集网站php源码,开发网站的好处,互联网营销培训的课程学费,哪家公司建站比较好首先我们使用EFK收集Kubernetes集群中的日志#xff0c;本次实验讲解的是在Kubernetes集群中启动一个Elasticsearch集群#xff0c;如果企业内已经有了Elasticsearch集群#xff0c;可以直接将日志输出至已有的Elasticsearch集群。 文章目录 部署elasticsearch创建Kibana创建…首先我们使用EFK收集Kubernetes集群中的日志本次实验讲解的是在Kubernetes集群中启动一个Elasticsearch集群如果企业内已经有了Elasticsearch集群可以直接将日志输出至已有的Elasticsearch集群。 文章目录 部署elasticsearch创建Kibana创建Fluentd查看kibana 部署elasticsearch
下载需要的部署文件
git clone https://gitee.com/qfxcoffee/shield.gitcd shield/sh/k8s/efk创建EFK所用的命名空间
kubectl create -f create-logging-namespace.yaml创建Elasticsearch集群:
[rootcontrol-plane efk-7.10.2]# kubectl create -f es-service.yaml -f es-statefulset.yaml
service/elasticsearch-logging created
serviceaccount/elasticsearch-logging created
clusterrole.rbac.authorization.k8s.io/elasticsearch-logging created
clusterrolebinding.rbac.authorization.k8s.io/elasticsearch-logging created
statefulset.apps/elasticsearch-logging created创建Kibana
[rootcontrol-plane efk-7.10.2]# kubectl create -f kibana-deployment.yaml -f kibana-service.yaml
deployment.apps/kibana-logging created
service/kibana-logging created创建Fluentd
由于在Kubernetes集群中可能并不需要对所有的机器都采集日志因此可以更改Fluentd的部署文件如下添加一个NodeSelector只部署至需要采集的主机即可
[rootcontrol-plane efk-7.10.2]# kubectl get node
NAME STATUS ROLES AGE VERSION
control-plane.minikube.internal Ready control-plane,master 18d v1.23.7[rootcontrol-plane efk-7.10.2]# kubectl label node control-plane.minikube.internal fluentdtrue[rootcontrol-plane efk-7.10.2]# kubectl get node -l fluentdtrue --show-labels
NAME STATUS ROLES AGE VERSION LABELS
control-plane.minikube.internal Ready control-plane,master 18d v1.23.7 beta.kubernetes.io/archamd64,beta.kubernetes.io/oslinux,fluentdtrue,kubernetes.io/archamd64,kubernetes.io/hostnamecontrol-plane.minikube.internal,kubernetes.io/oslinux,minikube.k8s.io/commit210b148df93a80eb872ecbeb7e35281b3c582c61,minikube.k8s.io/nameminikube,minikube.k8s.io/primarytrue,minikube.k8s.io/updated_at2024_11_05T14_44_37_0700,minikube.k8s.io/versionv1.34.0,node-role.kubernetes.io/control-plane,node-role.kubernetes.io/master,node.kubernetes.io/exclude-from-external-load-balancers创建Fluentd
[rootcontrol-plane efk-7.10.2]# kubectl create -f fluentd-es-ds.yaml -f fluentd-es-configmap.yaml
serviceaccount/fluentd-es created
clusterrole.rbac.authorization.k8s.io/fluentd-es created
clusterrolebinding.rbac.authorization.k8s.io/fluentd-es created
daemonset.apps/fluentd-es-v3.1.1 created
configmap/fluentd-es-config-v0.2.1 createdFluentd的ConfigMap有一个字段需要注意在fluentd-es-configmap.yaml最后有一个output.conf 查看kibana
http://192.168.56.115:32678/kibana/app/home#/ 可以看到整个流程已经打通了。