it-wiki:kubernetes:local_persistant_storage
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
it-wiki:kubernetes:local_persistant_storage [2024/03/12 06:59] – marko | it-wiki:kubernetes:local_persistant_storage [2024/03/13 12:18] (aktuell) – marko | ||
---|---|---|---|
Zeile 15: | Zeile 15: | ||
===== Step 1: Create StorageClass with WaitForFirstConsumer Binding Mode ===== | ===== Step 1: Create StorageClass with WaitForFirstConsumer Binding Mode ===== | ||
According to the docs, persistent local volumes require to have a binding mode of WaitForFirstConsumer. the only way to assign the volumeBindingMode to a persistent volume seems to be to create a storageClass with the respective volumeBindingMode and to assign the storageClass to the persistent volume. Let us start with | According to the docs, persistent local volumes require to have a binding mode of WaitForFirstConsumer. the only way to assign the volumeBindingMode to a persistent volume seems to be to create a storageClass with the respective volumeBindingMode and to assign the storageClass to the persistent volume. Let us start with | ||
- | <code bash> | + | |
- | cat > storageClass.yaml << EOF | + | //storageClass.yaml// |
+ | <code yaml> | ||
kind: StorageClass | kind: StorageClass | ||
apiVersion: storage.k8s.io/ | apiVersion: storage.k8s.io/ | ||
Zeile 23: | Zeile 24: | ||
provisioner: | provisioner: | ||
volumeBindingMode: | volumeBindingMode: | ||
- | EOF | + | </ |
+ | <code bash> | ||
kubectl create -f storageClass.yaml | kubectl create -f storageClass.yaml | ||
</ | </ | ||
Zeile 33: | Zeile 34: | ||
===== Step 2: Create Local Persistent Volume ===== | ===== Step 2: Create Local Persistent Volume ===== | ||
Since the storage class is available now, we can create local persistent volume with a reference to the storage class we have just created: | Since the storage class is available now, we can create local persistent volume with a reference to the storage class we have just created: | ||
- | <code bash> | + | |
- | cat > persistentVolume.yaml << EOF | + | //persistentVolume.yaml// |
+ | <code yaml> | ||
apiVersion: v1 | apiVersion: v1 | ||
kind: PersistentVolume | kind: PersistentVolume | ||
Zeile 56: | Zeile 58: | ||
values: | values: | ||
- node1 | - node1 | ||
- | EOF | ||
</ | </ | ||
Zeile 81: | Zeile 82: | ||
===== Step 3: Create a Persistent Volume Claim ===== | ===== Step 3: Create a Persistent Volume Claim ===== | ||
Similar to hostPath volumes, we now create a persistent volume claim that describes the volume requirements. One of the requirement is that the persistent volume has the <color # | Similar to hostPath volumes, we now create a persistent volume claim that describes the volume requirements. One of the requirement is that the persistent volume has the <color # | ||
- | <code bash> | + | |
- | cat > persistentVolumeClaim.yaml << EOF | + | //persistentVolumeClaim.yaml// |
+ | <code yaml> | ||
kind: PersistentVolumeClaim | kind: PersistentVolumeClaim | ||
apiVersion: v1 | apiVersion: v1 | ||
Zeile 94: | Zeile 96: | ||
requests: | requests: | ||
storage: 500Gi | storage: 500Gi | ||
- | EOF | + | </ |
+ | <code bash> | ||
kubectl create -f persistentVolumeClaim.yaml | kubectl create -f persistentVolumeClaim.yaml | ||
</ | </ | ||
Zeile 120: | Zeile 122: | ||
Okay, let us perform the last required step to complete the described picture. The only missing piece is the POD, which we will create now: | Okay, let us perform the last required step to complete the described picture. The only missing piece is the POD, which we will create now: | ||
- | <code bash> | + | |
- | cat > http-pod.yaml << EOF | + | //http-pod.yaml// |
+ | <code yaml> | ||
apiVersion: v1 | apiVersion: v1 | ||
kind: Pod | kind: Pod | ||
Zeile 142: | Zeile 145: | ||
persistentVolumeClaim: | persistentVolumeClaim: | ||
claimName: my-claim | claimName: my-claim | ||
- | EOF | + | </ |
+ | <code bash> | ||
kubectl create -f http-pod.yaml | kubectl create -f http-pod.yaml | ||
</ | </ |
it-wiki/kubernetes/local_persistant_storage.1710226752.txt.gz · Zuletzt geändert: 2024/03/12 06:59 von marko