Utiliser du stockage persistent via des PV¶
La StorageClass ceph-rbd est utilisable (dans la limite du quota de votre namespace) afin de créer des PVC ou des Statefulsets.
Le stockage en block permet de meilleures performances, et peut être utilisé directement en mode block ou monté en tant que filesystem dans le pod.
Exemple avec un Statefulset :
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: gimme-data
labels:
app: stateful
spec:
replicas: 1
persistentVolumeClaimRetentionPolicy:
whenDeleted: Delete
whenScaled: Delete
selector:
matchLabels:
app: stateful
template:
metadata:
labels:
app: stateful
spec:
containers:
- name: test
image: docker.io/busybox:1.36.1
command: ["/bin/sh","-c","echo running; touch /mnt/RBD-SUCCESS; sleep 3600"]
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
livenessProbe:
exec:
command:
- ls
volumeMounts:
- name: mypvc
mountPath: "/mnt"
volumeClaimTemplates:
- metadata:
name: mypvc
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "ceph-rbd"
resources:
requests:
storage: 1Gi
Exemple avec un PVC et un pod :
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ceph-rbd-claim-test
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: ceph-rbd
---
kind: Pod
apiVersion: v1
metadata:
name: rbd-test-pod
spec:
containers:
- name: rbd-test-pod
image: busybox:1.36.1
command:
- "/bin/sh"
args:
- "-c"
- "touch /mnt/RBD-SUCCESS; sleep 3600"
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
volumeMounts:
- name: pvc
mountPath: "/mnt"
restartPolicy: "Never"
volumes:
- name: pvc
persistentVolumeClaim:
claimName: ceph-rbd-claim-test