Strimzi - Local Storage: Defined static PVs
authorKai Moritz <kai@juplo.de>
Tue, 3 Oct 2023 13:39:20 +0000 (15:39 +0200)
committerKai Moritz <kai@juplo.de>
Wed, 4 Oct 2023 17:43:16 +0000 (19:43 +0200)
See:

* https://kubernetes.io/blog/2019/04/04/kubernetes-1.14-local-persistent-volumes-ga/
* https://docs.confluent.io/operator/current/co-storage.html#use-statically-provisioned-persistent-volumes

sudo mkdir /var/lib/local-storage
sudo mkdir /var/lib/local-storage/zookeeper-0
sudo mkdir /var/lib/local-storage/kafka-0

kubectl -n juplo apply -f local-storage.yaml

kubectl apply -f pv-zookeeper-0.yaml
kubectl apply -f pv-kafka-0.yaml

kubectl get pv

kubectl -n juplo apply -f cluster.yaml
kubectl -n juplo get pvc
kubectl -n juplo get pvc/data-0-juplo-kafka-0 -o yaml

strimzi-kafka/cluster.yaml
strimzi-kafka/local-storage.yaml [new file with mode: 0644]
strimzi-kafka/pv-kafka-0.yaml [new file with mode: 0644]
strimzi-kafka/pv-zookeeper-0.yaml [new file with mode: 0644]

index 3d9f95b..2ed0da3 100644 (file)
@@ -27,6 +27,7 @@ spec:
       volumes:
       - id: 0
         type: persistent-claim
+        class: local-storage
         size: 1Gi
         deleteClaim: false
   zookeeper:
@@ -34,6 +35,7 @@ spec:
     storage:
     storage:
       type: persistent-claim
+      class: local-storage
       size: 500Mi
       deleteClaim: false
   entityOperator:
diff --git a/strimzi-kafka/local-storage.yaml b/strimzi-kafka/local-storage.yaml
new file mode 100644 (file)
index 0000000..e6ce6fb
--- /dev/null
@@ -0,0 +1,6 @@
+apiVersion: storage.k8s.io/v1
+kind: StorageClass
+metadata:
+  name: local-storage
+provisioner: kubernetes.io/no-provisioner
+volumeBindingMode: WaitForFirstConsumer
diff --git a/strimzi-kafka/pv-kafka-0.yaml b/strimzi-kafka/pv-kafka-0.yaml
new file mode 100644 (file)
index 0000000..da92b7c
--- /dev/null
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: pv-kafka-0
+spec:
+  capacity:
+    storage: 1Gi
+  volumeMode: Filesystem
+  accessModes:
+  - ReadWriteOnce
+  persistentVolumeReclaimPolicy: Retain
+  storageClassName: local-storage
+  local:
+     path: /var/lib/local-storage/kafka-0
+  nodeAffinity:
+    required:
+      nodeSelectorTerms:
+      - matchExpressions:
+        - key: kubernetes.io/hostname
+          operator: In
+          values:
+          - ryzen
diff --git a/strimzi-kafka/pv-zookeeper-0.yaml b/strimzi-kafka/pv-zookeeper-0.yaml
new file mode 100644 (file)
index 0000000..dd571a7
--- /dev/null
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: pv-zookeeper-0
+spec:
+  capacity:
+    storage: 500Mi
+  volumeMode: Filesystem
+  accessModes:
+  - ReadWriteOnce
+  persistentVolumeReclaimPolicy: Retain
+  storageClassName: local-storage
+  local:
+     path: /var/lib/local-storage/zookeeper-0
+  nodeAffinity:
+    required:
+      nodeSelectorTerms:
+      - matchExpressions:
+        - key: kubernetes.io/hostname
+          operator: In
+          values:
+          - ryzen