一、DaemonSet
DaemonSet是kubernetes 1.2版本新增的一种资源对象,用于管理集群中每个Node上仅允许一份Pod的副本实例。
这种用法适用场景:
- 在每个Node上都运行一个GlusterFS存储或者Ceph存储的Daemon进程
- 在每个Node上都运行一个日志采集程序,例如Fluentd或者Logstach
- 在每个Node上都运行一个性能监控程序,采集该Node的运行性能数据,例如Prometheus、collected
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-cloud-logging
namespace: kube-system
labels:
k8s-app: fluentd-cloud-logging
spec:
template:
metadata:
namespace: kube-system
labels:
k8s-app: fluentd-cloud-logging
spec:
containers:
- name: fluentd-cloud-logging
image: gcr.io/google_containers/fluentd-elasticsearch:1.17
resources:
limits:
cpu: 100m
memory: 200Mi
env:
- name: FLUENTD_ARGS
value: -q
volumeMounts:
- name: varlog
mountPath: /var/log
readOnly: false
- name: containers
mountPath: /var/lib/docker/containers
readOnly: false
volumes:
- name: containers
hostPath:
path: /var/lib/docker/containers
- name: varlog
hostPath:
path: /var/log