Unable to setup couchbase operator 1.2 with persistent volume on local storage class

做~自己de王妃 提交于 2021-02-10 14:50:38

问题


I am trying to setup couchbase operator 1.2 on my local system. i followed the following steps :

  • Install the Couchbase Admission Controller.
  • Deploy the Couchbase Autonomous Operator.
  • Deploy the Couchbase Cluster.
  • Access CouchBase from UI.

But the problem with this is that as soon as the system or docker resets or the pod resets, the cluster's data is lost.

So for the same I tried to do it by adding persistent volume with local storage class as mentioned in the docs but the result was still the same. The pod still gets resets. and i am unable to find the reason for the same.

So if anyone can advise on how to do the same with persistent volume on local storage class. I have successfully created a storage class. Just having problem while getting the cluster up and keep the consistency for the same.

Here is the yamls that i used to create the storage class and pv and pv claim

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
 name: myssd
provisioner: local
apiVersion: v1
kind: PersistentVolume
metadata:
 name: couchbase-data-2
 labels:
    type: local
spec:
 capacity:
  storage: 10Gi
 accessModes:
  - ReadWriteOnce
 storageClassName: myssd
 hostPath:
    path: "/home/<user>/cb-storage/"
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-test-claim-2
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: myssd
  resources:
    requests:
      storage: 1Gi

Thanks in advance


回答1:


Persistent volume using hostPath is not durable. Use a local volume. Compared to hostPath volumes, local volumes can be used in a durable and portable manner without manually scheduling Pods to nodes, as the system is aware of the volume's node constraints by looking at the node affinity on the PersistentVolume.

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: couchbase-data
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /home/<User>/cb-storage/
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - node1
          - node2
          - node3
          - node4

You don't need to create a PersistentVolume manually because the storage class will do that internally.

Also you need to configure the local volume provisioner as discussed here so that dynamic provisioning using the local storage class happens.



来源:https://stackoverflow.com/questions/62888429/unable-to-setup-couchbase-operator-1-2-with-persistent-volume-on-local-storage-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!