使用存储卷
1,在pod上定义volume,volume指明关联到哪个存储设备上去
2,,在容器中要使用volumemounts
k8s-storage:
1.emptyDir 节点本地使用
2.hostPath
3. SAN: iSCSI
NAS: nfs,cifs
分布式存储:glusterfs,rbd,cephfs
云存储: EBS,Azure Disk,
1.emptyDir
vim pod-vol-demo.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-demo
namespace: default
labels:
app: myapp
tier: frontend
annotations:
wicrenet.com/created-by: “cluster admin”
spec:
containers:
-
name: myapp
image: ikubernetes/myapp:v1
ports:- name: http
containerPort: 80
volumeMounts:
- name: html
mountPath: /data/web/html/
- name: http
-
name: busybox
image: busybox:latest
imagePullPolicy: IfNotPresent
volumeMounts:- name: html
mountPath: /data/
command: - “/bin/sh”
- “-c”
- “sleep 7200”
volumes:
- name: html
-
name: html
emptyDir: {}
kubectl apply -f pod-vol-demo.yaml