{
  "schema_version": 2,
  "id": "operate/kubernetes/re-databases/db-controller",
  "title": "Manage Redis Enterprise databases for Kubernetes",
  "url": "https://redis.io/docs/latest/operate/kubernetes/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.",
  "tags": [
    "docs",
    "operate",
    "kubernetes"
  ],
  "last_updated": "2026-09-28T16:14:52+01:00",
  "page_type": "content",
  "content_hash": "ccb9f2fb3d24f0b99e2c54194c184fadf246f408bb7e52b73094ecf83380fcce",
  "sections": [
    {
      "id": "redis-enterprise-database-redb-lifecycle",
      "title": "Redis Enterprise database (REDB) lifecycle",
      "role": "overview",
      "text": "A 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> [!NOTE]\n> The admission controller prevents duplicate database names when databases are created via the Kubernetes operator.\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."
    },
    {
      "id": "flexible-deployment-options",
      "title": "Flexible deployment options",
      "role": "content",
      "text": "Databases 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)."
    },
    {
      "id": "create-a-database",
      "title": "Create a database",
      "role": "content",
      "text": "Your 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    [code example]\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     [code example]\n\n1. Apply the file in the namespace you want your database to be in.\n\n    [code example]\n\n1. Check the status of your database.\n\n    [code example]\n\n    When the status is `active`, the database is ready to use."
    },
    {
      "id": "modify-a-database",
      "title": "Modify a database",
      "role": "content",
      "text": "The 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    [code example]\n\n1. Change the specification (only properties in `spec` section) and save the changes.  \n    For more details, see [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    [code example]\n\n    When the status is `active`, the database is ready for use.\n\nTo add tags to a database and expose them as metric labels, see [Enrich database metrics with tags](https://redis.io/docs/latest/operate/kubernetes/re-databases/enrich-metrics-with-tags)."
    },
    {
      "id": "delete-a-database",
      "title": "Delete a database",
      "role": "content",
      "text": "The 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[code example]"
    },
    {
      "id": "connect-to-a-database",
      "title": "Connect to a database",
      "role": "content",
      "text": "After 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)."
    }
  ],
  "examples": [
    {
      "id": "create-a-database-ex0",
      "language": "YAML",
      "code": "apiVersion: app.redislabs.com/v1alpha1\n    kind: RedisEnterpriseDatabase\n    metadata:\n      name: mydb\n    spec:\n      memorySize: 1GB",
      "section_id": "create-a-database"
    },
    {
      "id": "create-a-database-ex1",
      "language": "YAML",
      "code": "redisEnterpriseCluster:\n       name: rec",
      "section_id": "create-a-database"
    },
    {
      "id": "create-a-database-ex2",
      "language": "sh",
      "code": "kubectl apply -f mydb.yaml",
      "section_id": "create-a-database"
    },
    {
      "id": "create-a-database-ex3",
      "language": "sh",
      "code": "kubectl get redb mydb -o jsonpath=\"{.status.status}\"",
      "section_id": "create-a-database"
    },
    {
      "id": "modify-a-database-ex0",
      "language": "sh",
      "code": "kubectl edit redb mydb",
      "section_id": "modify-a-database"
    },
    {
      "id": "modify-a-database-ex1",
      "language": "sh",
      "code": "kubectl get redb mydb -o jsonpath=\"{.status.status}\"",
      "section_id": "modify-a-database"
    },
    {
      "id": "delete-a-database-ex0",
      "language": "sh",
      "code": "kubectl delete redb mydb",
      "section_id": "delete-a-database"
    }
  ]
}
