k8s储存卷

卷的类型

In-Tree存储卷插件
◼ 临时存储卷
◆emptyDir
◼ 节点本地存储卷
◆hostPath, local
◼ 网络存储卷
◆文件系统:NFS、GlusterFS、CephFS和Cinder
◆块设备:iSCSI、FC、RBD和vSphereVolume
◆存储平台:Quobyte、PortworxVolume、StorageOS和ScaleIO
◆云存储:awsElasticBlockStore、gcePersistentDisk、azureDisk和azureFile
◼ 特殊存储卷
◆Secret、ConfigMap、DownwardAPI和Projected
◼ 扩展接口
◆CSI和FlexVolume
Out-of-Tree存储卷插件
◼ 经由CSI或FlexVolume接口扩展出的存储系统称为Out-of-Tree类的存储插件

cat pods-with-emptyDir-vol.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: pods-with-emptydir-vol
spec:
  containers:
  - image: ikubernetes/admin-box:v1.2
    name: admin
    command: ["/bin/sh","-c"]
    args: ["sleep 99999d"]
    resources: {}
    volumeMounts: 
    - name: data
      mountPath: /data
  - image: ikubernetes/demoapp:v1.0
    name: demonapp
    resources: {}
    volumeMounts: 
    - name: data
      mountPath: /luo/html
  volumes:
  - name: data
    emptyDir:
      medium: Memory
      sizeLimit: 16Mi
  dnsPolicy: ClusterFirst
  restartPolicy: Always

hostPath

不能跨节点,

kubectl explain pods.spec.volumes.hostPath

cat pod-with-hostpath-vol.yaml 
apiVersion: v1
kind: Pod
metadata: 
  name: redis
spec:
  containers:
  - name: redis
    image: redis:6
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - name: redisdata
      mountPath: /data
  volumes:
  - name: redisdata
    hostPath:
      type: DirectoryOrCreate
      path: /data/redis 

root@server01:~/k8s/yaml# kubectl get pods -owide
redis 1/1 Running 0 2m2s 192.168.24.18 server02

登录容器产生数据

root@server01:~/k8s/yaml# kubectl exec -it redis – sh
#redis-cli
127.0.0.1:6379> set name luohuiwen
OK
127.0.0.1:6379> save
OK

root@server02:/data/redis# ls
dump.rdb

你可能感兴趣的:(kubernetes,容器,云原生)