其他分享
首页 > 其他分享> > K8S之EFK日志收集

K8S之EFK日志收集

作者:互联网

一、EFK部署

1.1、部署ES

# 1、下载yaml文件
https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/fluentd-elasticsearch

# 2、共6个文件
[root@k8s-master01 efk]# ls
es-service.yaml  es-statefulset.yaml  fluentd-es-configmap.yaml  fluentd-es-ds.yaml  kibana-deployment.yaml  kibana-service.yaml

# 3、取消ES健康检查(es-statefulset.yaml),其他的按需改吧
         # livenessProbe:
         #   tcpSocket:
         #     port: transport
         #   initialDelaySeconds: 5
         #   timeoutSeconds: 10
         # readinessProbe:
         #   tcpSocket:
         #     port: transport
         #   initialDelaySeconds: 5
         #   timeoutSeconds: 10
         
# 4、部署ES
[root@k8s-master01 efk]# kubectl apply -f es-service.yaml 
[root@k8s-master01 efk]# kubectl apply -f es-statefulset.yaml 

# 5、查看集群状态(因为健康检查关了,所有等会会直接Running,所有得进去看看)
[root@k8s-master01 EFK]# kubectl get pod -n kube-system elasticsearch-logging-0
NAME                      READY   STATUS            RESTARTS   AGE
elasticsearch-logging-0   0/1     PodInitializing   0          18s

# 6、看看日志
[root@k8s-master01 EFK]# kubectl logs -f  -n kube-system elasticsearch-logging-0

1.2、部署fluentd

[root@k8s-master01 EFK]# kubectl apply -f fluentd-es-configmap.yaml 
configmap/fluentd-es-config-v0.2.0 created

### 设置nodeSelector,之需要部署在需要收集日志的节点上
nodeSelector:
  fluentd: "true"
###

[root@k8s-master01 EFK]# kubectl apply -f fluentd-es-ds.yaml 

# 打上标签
[root@k8s-master01 EFK]# kubectl label node k8s-master02 fluentd=true

1.3、部署kibana

[root@k8s-master01 EFK]# kubectl apply -f kibana-service.yaml -f kibana-deployment.yaml 

# service 端口暴露类型改一下(kibana-service.yaml)
type: NodePort

# 注释以下2行(kibana-deployment.yaml )
- name: SERVER_BASEPATH
  value: /api/v1/namespaces/kube-system/services/kibana-logging/proxy

# 页面登录kibana(http://192.168.1.100:30912/app/kibana)
[root@k8s-master01 EFK]# kubectl get svc  -n kube-system kibana-logging  
NAME             TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
kibana-logging   NodePort   10.110.227.174   <none>        5601:30912/TCP   58s

1.4、所需镜像

[root@k8s-node01 ~]# docker pull quay.io/fluentd_elasticsearch/elasticsearch:v7.4.3
[root@k8s-master02 ~]# docker pull quay.io/fluentd_elasticsearch/fluentd:v3.1.0
[root@k8s-master01 EFK]# docker pull docker.elastic.co/kibana/kibana-oss:7.4.2

标签:fluentd,K8S,master01,kibana,yaml,EFK,日志,k8s,root
来源: https://www.cnblogs.com/hsyw/p/14397700.html