幽沉谢世事,俯默窥唐虞。这篇文章主要讲述Kubernetes EFK相关的知识,希望能为你提供帮助。
Kubernetes EFKElasticsearch + Fluentd + kibana 的构建:
Elasticsearch-rc 配置文件:
apiVersion: v1 kind: ReplicationController metadata:
name: elasticsearch-logging-v1
namespace: kube-system
labels:
k8s-app: elasticsearch-logging
version: v1
kubernetes.io /cluster-service :
"true" spec:
replicas: 2
selector:
k8s-app: elasticsearch-logging
version: v1
template:
metadata:
labels:
k8s-app: elasticsearch-logging
version: v1
kubernetes.io /cluster-service :
"true"
spec:
containers:
- image: gcr.io /google-containers/elasticsearch :v2.4.1
name: elasticsearch-logging
resources:
# need more cpu upon initialization, therefore burstable class
limits:
cpu: 1000m
requests:
cpu: 100m
ports:
- containerPort: 9200
name: db
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
volumeMounts:
- name: es-persistent-storage
mountPath:
/data
volumes:
- name: es-persistent-storage
emptyDir: |
Elasticsearch-svc 配置文件:
apiVersion: v1 kind: Service metadata:
name: elasticsearch-logging
namespace: kube-system
labels:
k8s-app: elasticsearch-logging
kubernetes.io /cluster-service :
"true"
kubernetes.io /name :
"Elasticsearch" spec:
ports:
- port: 9200
name: http
protocol: TCP
targetPort: db
selector:
k8s-app: elasticsearch-logging |
kibana-rc 配置文件:
apiVersion: extensions /v1beta1 kind: Deployment metadata:
name: kibana-logging
namespace: kube-system
labels:
k8s-app: kibana-logging
kubernetes.io /cluster-service :
"true" spec:
replicas: 1
selector:
matchLabels:
k8s-app: kibana-logging
template:
metadata:
labels:
k8s-app: kibana-logging
spec:
containers:
- name: kibana-logging
image: gcr.io /google-containers/kibana :v4.6.1
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
requests:
cpu: 100m
env :
- name:
"ELASTICSEARCH_URL"
value:
"??http://elasticsearch-logging:9200??"
ports:
- containerPort: 5601
name: ui
protocol: TCP |
kibana-svc 配置文件:
apiVersion: v1 kind: Service metadata:
name: kibana-logging
namespace: kube-system
labels:
k8s-app: kibana-logging
kubernetes.io /cluster-service :
"true"
kubernetes.io /name :
"Kibana" spec:
ports:
- port: 5601
name: http
protocol: TCP
targetPort: ui
selector:
k8s-app: kibana-logging |
fluentd-configmap 配置文件:
fluentd-configmap.yml 展开源码
fluentd-daemonset 配置文件:
apiVersion: extensions /v1beta1 kind: DaemonSet metadata:
name: fluentd-elasticsearch
namespace: kube-system
labels:
k8s-app: fluentd-logging spec:
template:
metadata:
labels:
name: fluentd-elasticsearch
spec:
containers:
- name: fluentd-elasticsearch
image: gcr.io /google-containers/fluentd-elasticsearch :1.20
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath:
/var/log
- name: varlibdockercontainers
mountPath:
/var/lib/docker/containers
readOnly:
true
- mountPath:
"/etc/td-agent/"
name: config-volume
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path:
/var/log
- name: varlibdockercontainers
hostPath:
path:
/var/lib/docker/containers
- name: config-volume
configMap:
name: fluentd |
【Kubernetes EFK】正常启动后就会看到日志。
推荐阅读
- yapi禁用注册功能
- RT-Thread快速入门-事件集
- #yyds干货盘点#Zabbi学习
- 为什么MySQL的主键查询这么快()
- docker|《Docker+Kubernetes容器实战派》新书上市
- #yyds干货盘点#ffmpeg
- #yyds干货盘点#java高级用法之:在JNA中将本地方法映射到JAVA代码中
- c++核心编程--函数的重载
- k8s集群Job负载支持多个Pod可靠并发,如何权衡利弊选择适合的并行计算模式()