作者:浅笑你的妩媚 | 来源:互联网 | 2023-09-03 10:08
1.emptyDir pod删除的时候,volume也就不存在了,生命周期和pod同样apiVersion: v1kind: Podmetadata: name: redis-p
1.emptyDir
pod删除的时候,volume也就不存在了,生命周期和pod同样
apiVersion: v1
kind: Pod
metadata:
name: redis-pod
spec:
containers:
- image: redis
name: redis
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
2.hostpath
宿主机上面的目录,一旦宿主机宕机文件就不存在,不是分布式的
apiVersion: v1
kind: Pod
metadata:
name: test-host-pd
spec:
containers:
- image: nginx
name: test-container
volumeMounts:
- mountPath: /tmp-test
name: test-volume
volumes:
- name: test-volume
hostPath:
path: /opt/data/
type: Directory
3.nfs分布式的但是 nfs本身为单电
192.168.56.12 部署了nfsserver端 所有node节点需要安装 nfs-utils
[root@k8s-node2 nginx]# cat /etc/exports
/opt/nginx 192.168.56.0/24(rw,no_root_squash)
[root@k8s-node2 nginx]#
[root@k8s-node2 nginx]# cat /opt/nginx/index.html
nginx-index
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
template:
metadata:
labels:
app: nginx-nfs
spec:
containers:
- name: nginx-nfs
image: nginx
volumeMounts:
- name: nginxdata
mountPath: /usr/share/nginx/html
ports:
- containerPort: 80
volumes:
- name: nginxdata
nfs:
server: 192.168.56.12
path: /opt/nginx
kubectl create -f nginx.yaml
kubectl expose deployment nginx-deployment --port=90 --type=NodePort --target-port=80 --name=nginx-service-nfs
kubectl get svc
4.glusterfs
5.
6.