Kubernetes之挂载nfs到pod中
LiuSw Lv6

Kubernetes之挂载nfs到pod中

用界面或者命令编辑pod的yml文件

1
kubectl edit pod pod名称 -n 名称空间

修改配置文件内容,示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
kind: Deployment
apiVersion: apps/v1
metadata:
name: ***
namespace: ***
labels:
app: ***
annotations:
...
spec:
spec:
volumes:
- name: demcache
nfs:
server: 192.168.11.149
path: /data5/nfs_dir/DemCache
containers:
- name: ***
image: ***
...
volumeMounts:
- name: demcache
readOnly: true
mountPath: /DemCache

完整yaml示例

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
69
70
71
72
73
74
75
76
77
78
79
80
81
kind: Deployment
apiVersion: apps/v1
metadata:
name: ***
namespace: ***
labels:
app: ***
annotations:
deployment.kubernetes.io/revision: '134'
kubesphere.io/alias-name: ***
kubesphere.io/maxSurgePod: '2'
kubesphere.io/minAvailablePod: '1'
spec:
replicas: 1
selector:
matchLabels:
app: ***
template:
metadata:
creationTimestamp: null
labels:
app: ***
annotations:
kubesphere.io/containerSecrets: ''
kubesphere.io/restartedAt: '2022-03-03T01:07:01.567Z'
logging.kubesphere.io/logsidecar-config: '{}'
spec:
volumes:
- name: volume-joohn4
persistentVolumeClaim:
claimName: public-disk
- name: volume-thekd1
configMap:
name: test
defaultMode: 420
- name: demcache
nfs:
server: 192.168.11.149
path: /data/nfs/DemCache
containers:
- name: container-2nvr7g
image: '192.168.11.6:80/test/test:0.0.1'
ports:
- name: http-5000
containerPort: 80
protocol: TCP
resources:
limits:
cpu: 500m
memory: 1000Mi
requests:
cpu: 10m
memory: 10Mi
volumeMounts:
- name: volume-joohn4
mountPath: /data
- name: volume-thekd1
mountPath: /app/appsettings.json
subPath: appsettings.json
- name: demcache
readOnly: true
mountPath: /DemCache
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
serviceAccountName: default
serviceAccount: default
securityContext: {}
affinity: {}
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600

 评论