k8s1.12以上版本设置LXCFS

安装依赖包

1
yum -y install fuse-devel fuse fuse-libs

使用k8s Daemonsets部署lxcfs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
apiVersion: apps/v1beta2
kind: DaemonSet
metadata:
name: lxcfs
namespace: default
labels:
app: lxcfs
spec:
selector:
matchLabels:
app: lxcfs
template:
metadata:
labels:
app: lxcfs
spec:
hostPID: true
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: lxcfs
image: registry.cn-hangzhou.aliyuncs.com/denverdino/lxcfs:3.0.4
imagePullPolicy: Always
securityContext:
privileged: true
volumeMounts:
- name: cgroup
mountPath: /sys/fs/cgroup
- name: lxcfs
mountPath: /var/lib/lxcfs
mountPropagation: Bidirectional
- name: usr-local
mountPath: /usr/local
volumes:
- name: cgroup
hostPath:
path: /sys/fs/cgroup
- name: usr-local
hostPath:
path: /usr/local
- name: lxcfs
hostPath:
path: /var/lib/lxcfs
type: DirectoryOrCreate

例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
"initializer.kubernetes.io/lxcfs": "true"
labels:
app: web
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: httpd:2.4.32
volumeMounts:
- name: cpuinfo
mountPath: /proc/cpuinfo
- name: meminfo
mountPath: /proc/meminfo
- name: diskstats
mountPath: /proc/diskstats
- name: stat
mountPath: /proc/stat
- name: swaps
mountPath: /proc/swaps
- name: uptime
mountPath: /proc/uptime
imagePullPolicy: Always
resources:
requests:
memory: "1024Mi"
cpu: "100m"
limits:
memory: "1024Mi"
cpu: "100m"

volumes:
- name: cpuinfo
hostPath:
path: /var/lib/lxcfs/proc/cpuinfo
type: File
- name: meminfo
hostPath:
path: /var/lib/lxcfs/proc/meminfo
type: File
- name: diskstats
hostPath:
path: /var/lib/lxcfs/proc/diskstats
type: File
- name: stat
hostPath:
path: /var/lib/lxcfs/proc/stat
type: File
- name: swaps
hostPath:
path: /var/lib/lxcfs/proc/swaps
type: File
- name: uptime
hostPath:
path: /var/lib/lxcfs/proc/uptime
type: File
Donate