<p>I am using clickhouse database and data are stored at <code>/media/user/data/clickhouse</code> and <code>/media/user/data/clickhouse-server</code>. When I run a docker container</p>
<pre><code>$ docker run \
    --name local-clickhouse \
    --ulimit nofile=262144:262144 \
    -u 1000:1000 \
    -p 8123:8123 \
    -p 9000:9000 \
    -p 9009:9009 \
    -v /media/user/data/clickhouse:/var/lib/clickhouse \
    -v /media/user/data/clickhouse-server:/var/log/clickhouse-server \
    -dit clickhouse/clickhouse-server
</code></pre>
<p>I see the data and everything is fine. I am trying to run this in a pod using minikube with following persistent volume configs:</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: host-pv-clickhouse
spec:
  capacity:
    storage: 4000Gi   
  volumeMode: Filesystem
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /media/user/data/clickhouse
    type: DirectoryOrCreate
</code></pre>
<p>and</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: host-pv-clickhouse-server
spec:
  capacity:
    storage: 4000Gi 
  volumeMode: Filesystem  
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /media/user/data/clickhouse-server
    type: DirectoryOrCreate
</code></pre>
<p>Additionally, I also have persistent volume claims:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: host-pvc-clickhouse-server
spec:
  volumeName: host-pv-clickhouse-server
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2000Gi
</code></pre>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: host-pvc-clickhouse
spec:
  volumeName: host-pv-clickhouse
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2000Gi
</code></pre>
<p>and finally service and deployment:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: clickhouse
spec:
  type: NodePort
  ports:
    - protocol: TCP
      name: tcp
      port: 9000
      targetPort: 9000
      nodePort: 30003
    - protocol: TCP
      name: http
      port: 8123
      targetPort: 8123
      nodePort: 30004
    - protocol: TCP
      name: interncomm
      port: 9009
      targetPort: 9009
      nodePort: 30005
  selector:
    app: clickhouse
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: clickhouse
  labels:
    app: clickhouse
spec:
  replicas: 1
  selector:
    matchLabels:
      app: clickhouse
  template:
    metadata:
      labels:
        app: clickhouse
    spec:
      containers:
        - name: clickhouse
          image: clickhouse/clickhouse-server:latest
          ports:
            - containerPort: 8123
              name: http
            - containerPort: 9000
              name: tcp
            - containerPort: 9009
              name: interncomm
          volumeMounts:
            - name: clickhouse-volume
              mountPath: /var/lib/clickhouse
            - name: clickhouse-server-volume
              mountPath: /var/log/clickhouse-server
      volumes:
        - name: clickhouse-volume
          persistentVolumeClaim: 
            claimName: host-pvc-clickhouse
        - name: clickhouse-server-volume
          persistentVolumeClaim: 
            claimName: host-pvc-clickhouse-server
</code></pre>
<p>When I run
<code>kubectl apply -f chdb_node.yaml</code> it works and I can access the database via clickhouse's web gui. However, the data aren't there.</p>
<p>Any suggestions to how to fix this?</p>

MoneyBall
<p>Have you got a chance to go through this official kubernetes <strong><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">tutorial</a></strong>, also you are using <code>type: DirectoryOrCreate</code> which will create a directory if the original directory is not available.</p>
<p>Hence it is suggested to check whether the directories which you are trying to mount on the pod already exist on the node by using the below command</p>
<pre><code>ls -lah /media/user/data/clickhouse

and 

ls -lah /media/user/data/clickhouse-server
</code></pre>
<p>This command also helps in checking whether there is any data available in these directories. In case data is not available in these directories, copy the data from your docker container or from the source directory to these directories and follow the official tutorial for mounting your persistent volumes.</p>
