{
  "id": "db-controller",
  "title": "Manage Redis Enterprise databases for Kubernetes",
  "url": "https://redis.io/docs/latest/operate/kubernetes/8.0/re-databases/db-controller/",
  "summary": "This section describes how the database controller provides the ability to create, manage, and use databases via a database custom resource.",
  "content": "## Redis Enterprise database (REDB) lifecycle\n\nA Redis Enterprise database (REDB) is created with a custom resource file. The custom resource defines the size, name, and other specifications for the REDB. The database is created when you apply the custom resource file.\n\nThe database controller in Redis Enterprise for Kubernetes:\n\n- Discovers the custom resource\n- Makes sure the REDB is created in the same namespace as the Redis Enterprise cluster (REC)\n- Maintains consistency between the custom resource and the REDB\n\nThe database controller recognizes the new custom resource and validates the specification.\nIf valid, the controller combines the values specified in\nthe custom resource with default values to create a full specification. It then uses this full specification to create the\ndatabase on the specified Redis Enterprise cluster (REC).\n\n\nThe admission controller prevents duplicate database names when databases are created via the Kubernetes operator.\n\n\nOnce the database is created, it is exposed with the same service mechanisms by the service rigger for the Redis Enterprise cluster.\nIf the database [custom resource is deleted](https://redis.io/docs/latest/operate/kubernetes/re-clusters/delete-custom-resources), the database and its services are deleted from the cluster.\n\n### Flexible deployment options\n\nDatabases in multiple namespaces can be managed by the same operator. To learn more, see [Manage databases in multiple namespaces](https://redis.io/docs/latest/operate/kubernetes/re-clusters/multi-namespace).\n\nTo learn more about designing a multi-namespace Redis Enterprise cluster, see [flexible deployment options](https://redis.io/docs/latest/operate/kubernetes/architecture/deployment-options).\n\n## Create a database\n\nYour Redis Enterprise database custom resource must be of the `kind: RedisEnterpriseDatabase` and have values for `name` and `memorySize`. All other values are optional and will be defaults if not specified.\n\n1. Create a file (in this example mydb.yaml) that contains your database custom resource.\n\n    ```YAML\n    apiVersion: app.redislabs.com/v1alpha1\n    kind: RedisEnterpriseDatabase\n    metadata:\n      name: mydb\n    spec:\n      memorySize: 1GB\n    ```\n\n    To create a REDB in a different namespace from your REC, you need to specify the cluster with `redisEnterpriseCluster` in the `spec` section of your RedisEnterpriseDatabase custom resource.\n\n     ```YAML\n     redisEnterpriseCluster:\n       name: rec\n     ```\n\n1. Apply the file in the namespace you want your database to be in.\n\n    ```sh\n    kubectl apply -f mydb.yaml\n    ```\n\n1. Check the status of your database.\n\n    ```sh\n    kubectl get redb mydb -o jsonpath=\"{.status.status}\"\n    ```\n\n    When the status is `active`, the database is ready to use.\n\n## Modify a database\n\nThe custom resource defines the properties of the database.\nTo change the database, you can edit your original specification and apply the change or use `kubectl edit`.\n\nTo modify the database:\n\n1. Edit the definition:\n\n    ```sh\n    kubectl edit redb mydb\n    ```\n\n1. Change the specification (only properties in `spec` section) and save the changes.  \n    For more details, see [RedisEnterpriseDatabaseSpec](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/redis_enterprise_database_api.md#redisenterprisedatabasespec) or [Options for Redis Enterprise databases](https://redis.io/docs/latest/operate/kubernetes/reference/api/redis_enterprise_database_api). \n\n1. Monitor the status to see when the changes take effect:\n\n    ```sh\n    kubectl get redb mydb -o jsonpath=\"{.status.status}\"\n    ```\n\n    When the status is `active`, the database is ready for use.\n\n## Delete a database\n\nThe database exists as long as the custom resource exists.\nIf you delete the custom resource, the database controller deletes the database.\nThe database controller removes the database and its services from the cluster.\n\nTo delete a database, run:\n\n```sh\nkubectl delete redb mydb\n```\n\n## Connect to a database\n\nAfter the database controller creates a database, services for accessing the database are automatically created in the same namespace. Connection information is stored in a Kubernetes [secret](https://kubernetes.io/docs/concepts/configuration/secret/) maintained by the database controller.\n\nFor comprehensive information about connecting to your database, including:\n\n- Service types and access patterns\n- Retrieving connection information from secrets\n- In-cluster and external access methods\n- Connection examples and troubleshooting\n\nSee [Database connectivity](https://redis.io/docs/latest/operate/kubernetes/networking/database-connectivity).\n",
  "tags": ["docs","operate","kubernetes"],
  "last_updated": "2026-06-04T14:49:57+01:00"
}
