# Store the Redpanda Data Directory in hostPath Volumes

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [streaming-full.txt](https://docs.redpanda.com/streaming-full.txt)

---
title: Store the Redpanda Data Directory in hostPath Volumes
latest-operator-version: v26.1.4
# EOL = End-of-Life (support lifecycle status)
page-is-nearing-eol: "false"
page-is-past-eol: "true"
page-eol-date: December 22, 2024
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
docname: kubernetes/storage/k-hostpath
page-component-name: streaming
page-version: "23.3"
page-component-version: "23.3"
page-component-title: Streaming
page-relative-src-path: kubernetes/storage/k-hostpath.adoc
page-edit-url: https://github.com/redpanda-data/docs/edit/v/23.3/modules/manage/pages/kubernetes/storage/k-hostpath.adoc
description: Learn how to configure Redpanda to store the data directory in Kubernetes <code>hostPath</code> volumes. This setup is only for development environments.
page-git-created-date: "2024-01-04"
page-git-modified-date: "2024-02-26"
support-status: past end-of-life
---

<!-- Source: https://docs.redpanda.com/streaming/23.3/manage/kubernetes/storage/k-hostpath.md -->

You can configure Redpanda to use Kubernetes [`hostPath`](https://docs.redpanda.com/streaming/23.3/manage/kubernetes/storage/k-volume-types/) volumes to store the Redpanda data directory. A `hostPath` volume mounts a file or directory from the host node’s file system into your Pod.

> ⚠️ **WARNING**
>
> Use `hostPath` volumes only for development environments. If the Pod is deleted and recreated, it might be scheduled on another worker node and lose access to the data.

## [](#prerequisites)Prerequisites

You must have the following:

-   Kubernetes cluster: Ensure you have a running Kubernetes cluster, either locally, such as with minikube or kind, or remotely.

-   [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl): Ensure you have the `kubectl` command-line tool installed and configured to communicate with your cluster.

-   Dedicated directory: Ensure you have a dedicated directory on the host worker node to prevent potential conflicts with other applications or system processes.

-   File system: Ensure that the chosen directory is on an ext4 or XFS file system.


## [](#configure-redpanda-to-use-hostpath-volumes)Configure Redpanda to use hostPath volumes

Both the Redpanda Helm chart and the Redpanda custom resource provide an interface for configuring `hostPath` volumes.

To store Redpanda data in `hostPath` volumes:

### Helm + Operator

`redpanda-cluster.yaml`

```yaml
apiVersion: cluster.redpanda.com/v1alpha1
kind: Redpanda
metadata:
name: redpanda
spec:
chartRef: {}
clusterSpec:
  storage:
    hostPath: "<absolute-path>"
    persistentVolume:
      enabled: false
  initContainers:
    setDataDirOwnership:
      enabled: true
```

```bash
kubectl apply -f redpanda-cluster.yaml --namespace <namespace>
```

### Helm

#### --values

`hostpath.yaml`

```yaml
storage:
hostPath: "<absolute-path>"
persistentVolume:
  enabled: false
initContainers:
  setDataDirOwnership:
    enabled: true
```

```bash
helm upgrade --install redpanda redpanda/redpanda --namespace <namespace> --create-namespace \
--values hostpath.yaml --reuse-values
```

#### --set

```bash
helm upgrade --install redpanda redpanda/redpanda --namespace <namespace> --create-namespace \
  --set storage.hostPath=<absolute-path> \
  --set storage.persistentVolume.enabled=false \
  --set statefulset.initContainers.setDataDirOwnership.enabled=true
```

-   `storage.hostPath`: Absolute path on the host to store the Redpanda data directory.

-   `storage.persistentVolume.enabled`: Determine if a PersistentVolumeClaim (PVC) should be created for the Redpanda data directory. When set to `false`, a PVC is not created.

-   `statefulset.initContainers.setDataDirOwnership.enabled`: Enable the init container to set write permissions on the data directories.

    Pods that run Redpanda brokers must have read/write access to their data directories. The initContainer is responsible for setting write permissions on the data directories. By default, `statefulset.initContainers.setDataDirOwnership` is disabled because most storage drivers call `SetVolumeOwnership` to give Redpanda permissions to the root of the storage mount. However, some storage drivers, such as `hostPath`, do not call `SetVolumeOwnership`. In this case, you must enable the initContainer to set the permissions.

    > ❗ **IMPORTANT**
    >
    > To set permissions on the data directories, the initContainer must run as root. However, be aware that an initContainer running as root can introduce the following security risks:
    >
    > -   **Privilege escalation:** If attackers gains access to the initContainer, they can escalate privileges to gain full control over the system. For example, attackers could use the initContainer to gain unauthorized access to sensitive data, tamper with the system, or start denial-of-service attacks.
    >
    > -   **Container breakouts:** If the container is misconfigured or the container runtime has a vulnerability, attackers could escape from the initContainer and access the host operating system.
    >
    > -   **Image tampering:** If attackers gain access to the container image of the initContainer, they could add malicious code or backdoors to it. Image tampering could compromise the security of the entire cluster.


## [](#suggested-reading)Suggested reading

-   [Supported Volume Types for Data in Redpanda](https://docs.redpanda.com/streaming/23.3/manage/kubernetes/storage/k-volume-types/)

-   For details about `hostPath` volumes, see the [Kubernetes documentation](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath).

-   [Redpanda Helm Specification](https://docs.redpanda.com/streaming/23.3/reference/k-redpanda-helm-spec/)

-   [Redpanda CRD Reference](https://docs.redpanda.com/streaming/23.3/reference/k-crd/)


## [](#next-steps)Next steps

[Monitor disk usage](https://docs.redpanda.com/streaming/23.3/manage/kubernetes/monitoring/#infrastructure-resources) to detect issues early, optimize performance, and plan capacity.

## Suggested labs

-   [Redpanda Iceberg Docker Compose Example](https://docs.redpanda.com/labs/docker-compose/iceberg/)
-   [Enable Unified Identity with Azure Entra ID for Redpanda and Redpanda Console](https://docs.redpanda.com/labs/docker-compose/oidc/)
-   [Owl Shop Example Application in Docker](https://docs.redpanda.com/labs/docker-compose/owl-shop/)
-   [Migrate Data with Redpanda Migrator](https://docs.redpanda.com/labs/docker-compose/redpanda-migrator/)
-   [Start a Single Redpanda Broker with Redpanda Console in Docker](https://docs.redpanda.com/labs/docker-compose/single-broker/)
-   [Start a Cluster of Redpanda Brokers with Redpanda Console in Docker](https://docs.redpanda.com/labs/docker-compose/three-brokers/)
-   [Iceberg Streaming on Kubernetes with Redpanda, MinIO, and Spark](https://docs.redpanda.com/labs/kubernetes/iceberg/)

See more

[Search all labs](https://docs.redpanda.com/labs)