> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubernetes support

> Deploy FalkorDB to Kubernetes.

FalkorDB can be deployed on Kubernetes using Helm charts and Docker images. This guide will walk you through the process.

## Prerequisites

Before you begin, make sure you have Helm installed on your Kubernetes cluster.

To deploy FalkorDB to Kubernetes we need to use:

* [Helm charts](https://bitnami.com/stack/redis/helm)
* [Docker image](https://hub.docker.com/r/falkordb/falkordb)

And follow these steps:

## Step 1: Create a `values.yaml` File

Create a values.yaml file with the following content:

```yaml theme={null}
global:
  security:
    # Required to run the FalkorDB image which may use non-standard base configurations
    allowInsecureImages: true

image:
  registry: docker.io
  repository: falkordb/falkordb
  tag: "latest"

master:
  extraFlags:
  - "--loadmodule /var/lib/falkordb/bin/falkordb.so"

replica:
  extraFlags:
  - "--loadmodule /var/lib/falkordb/bin/falkordb.so"
```

This file specifies the FalkorDB image (you can choose different tags)
and configures the master and replicas to load the FalkorDB module.
For additional configurations [see the official Helm chart documentation](https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml)

## Step 2: Install FalkorDB Helm Charts

You can deploy FalkorDB using one of two Redis deployment architectures:

### Option A: Sentinel-based Deployment (Recommended for High Availability)

This deployment uses Redis Sentinel for automatic failover and high availability.

Install the helm charts using the following command:

```bash theme={null}
helm install -f values.yaml my-falkordb oci://registry-1.docker.io/bitnamicharts/redis
```

This command deploys FalkorDB with Redis Sentinel and the configuration from values.yaml.
After running this command, instructions on how to connect to the FalkorDB server will be displayed.

### Option B: Redis Cluster Deployment

This deployment uses Redis Cluster for horizontal scalability and sharding.

**Create a cluster-specific `values.yaml` file:**

```yaml theme={null}
global:
  security:
    # Required to run the FalkorDB image which may use non-standard base configurations
    allowInsecureImages: true

image:
  repository: bitnamilegacy/redis-cluster
  tag: 8.2.1-debian-12-r0

redis:
  extraVolumes:
    - name: falkordbmodule
      emptyDir: {}
  extraVolumeMounts:
    - name: falkordbmodule
      mountPath: /falkordbmodule/
  initContainers:
    - name: falkordb-module-preload
      image: falkordb/falkordb-server:latest
      command: ['/bin/sh', '-c', 'cp /var/lib/falkordb/bin/falkordb.so /falkordbmodule/']
      volumeMounts:
        - name: falkordbmodule
          mountPath: /falkordbmodule/
  configmap: |-
    loadmodule /falkordbmodule/falkordb.so
```

**Install the Redis Cluster Helm chart:**

```bash theme={null}
helm upgrade falkordb oci://registry-1.docker.io/bitnamicharts/redis-cluster --values values.yaml --install
```

This command deploys FalkorDB in a Redis Cluster configuration with 6 nodes (3 masters and 3 replicas by default).
For additional cluster configurations, see the [official Redis Cluster Helm chart documentation](https://artifacthub.io/packages/helm/bitnami/redis-cluster).

**Note:** The remaining steps in this guide assume you're using Option A (Sentinel-based deployment). If you chose Option B (Redis Cluster), adjust the service names and connection commands accordingly (e.g., use `my-falkordb-redis-cluster` instead of `my-falkordb-redis-master`).

## Step 3: Retrieve the FalkorDB Password

To connect to FalkorDB, you need the Redis password. Retrieve it using the following command:

```bash theme={null}
export REDIS_PASSWORD=$(kubectl get secret --namespace default my-falkordb-redis -o jsonpath="{.data.redis-password}" | base64 -d)
```

## Step 4: Enable External Connections

In a new terminal, run the following command to port-forward to the FalkorDB server, allowing external connections:

```bash theme={null}
kubectl port-forward --namespace default svc/my-falkordb-redis-master 6379:6379
```

## Step 5: Connect to FalkorDB Using `redis-cli`

You can now connect to FalkorDB using redis-cli with the following command:

```bash theme={null}
REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h 127.0.0.1 -p 6379
```

## Step 6: Run a Simple Cypher Query

To test your FalkorDB installation, run a simple Cypher query:

```cypher theme={null}
GRAPH.QUERY mygraph "UNWIND range(1, 10) AS i RETURN i"
```

The output should resemble the following:

```cypher theme={null}
127.0.0.1:6379> GRAPH.QUERY mygraph "UNWIND range(1, 10) AS i RETURN i"
1) 1) "i"
2)  1) 1) (integer) 1
    2) 1) (integer) 2
    3) 1) (integer) 3
    4) 1) (integer) 4
    5) 1) (integer) 5
    6) 1) (integer) 6
    7) 1) (integer) 7
    8) 1) (integer) 8
    9) 1) (integer) 9
   10) 1) (integer) 10
3) 1) "Cached execution: 0"
   2) "Query internal execution time: 0.290600 milliseconds"
```

In summary, this guide provides steps for deploying FalkorDB on Kubernetes using Helm charts and Docker images. It covers the creation of a values.yaml file for configuration, Helm chart installation, password retrieval, enabling external connections, connecting to FalkorDB with redis-cli, and running a basic Cypher query for verification. We hope this documentation helped you to set up FalkorDB in your Kubernetes environment. If you have any questions or encounter any issues during the process, please don't hesitate to reach out for assistance. Thank you for choosing FalkorDB!

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="Which Helm chart should I use for FalkorDB on Kubernetes?">
    Use the Bitnami Redis Helm chart (`oci://registry-1.docker.io/bitnamicharts/redis`) for Sentinel-based HA deployments, or the Redis Cluster chart (`bitnamicharts/redis-cluster`) for sharded deployments.
  </Accordion>

  <Accordion title="Why is allowInsecureImages required in the values.yaml?">
    The FalkorDB Docker image may use non-standard base configurations. Setting `global.security.allowInsecureImages: true` allows the Bitnami Helm chart to accept the FalkorDB image without strict security validation.
  </Accordion>

  <Accordion title="How do I scale replicas in Kubernetes?">
    Modify the `replica.replicaCount` value in your `values.yaml` and run `helm upgrade`. For cluster deployments, adjust the node count in the Redis Cluster chart values.
  </Accordion>

  <Accordion title="Can I use persistent volumes with FalkorDB on Kubernetes?">
    Yes. The Bitnami Helm charts enable persistent volume claims by default. Configure `master.persistence.size` and `replica.persistence.size` in your `values.yaml` to set storage sizes.
  </Accordion>

  <Accordion title="How do I expose FalkorDB outside the Kubernetes cluster?">
    Use `kubectl port-forward` for development, or configure a LoadBalancer or NodePort service type in your Helm values for production external access.
  </Accordion>
</AccordionGroup>
