This section describes how the database controller provides the ability to create, manage, and use databases via a database custom resource.
| Redis Enterprise for Kubernetes |
|---|
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.
The database controller in Redis Enterprise for Kubernetes:
The database controller recognizes the new custom resource and validates the specification. If valid, the controller combines the values specified in the custom resource with default values to create a full specification. It then uses this full specification to create the database on the specified Redis Enterprise cluster (REC).
Once the database is created, it is exposed with the same service mechanisms by the service rigger for the Redis Enterprise cluster. If the database custom resource is deleted, the database and its services are deleted from the cluster.
Databases in multiple namespaces can be managed by the same operator. To learn more, see Manage databases in multiple namespaces.
To learn more about designing a multi-namespace Redis Enterprise cluster, see flexible deployment options.
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.
Create a file (in this example mydb.yaml) that contains your database custom resource.
apiVersion:app.redislabs.com/v1alpha1kind:RedisEnterpriseDatabasemetadata:name:mydbspec:memorySize:1GBTo 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.
redisEnterpriseCluster:name:recApply the file in the namespace you want your database to be in.
kubectl apply -f mydb.yaml
Check the status of your database.
kubectl get redb mydb -o jsonpath="{.status.status}"
When the status is active, the database is ready to use.
The custom resource defines the properties of the database.
To change the database, you can edit your original specification and apply the change or use kubectl edit.
To modify the database:
Edit the definition:
kubectl edit redb mydb
Change the specification (only properties in spec section) and save the changes.
For more details, see RedisEnterpriseDatabaseSpec or Options for Redis Enterprise databases.
Monitor the status to see when the changes take effect:
kubectl get redb mydb -o jsonpath="{.status.status}"
When the status is active, the database is ready for use.
The database exists as long as the custom resource exists. If you delete the custom resource, the database controller deletes the database. The database controller removes the database and its services from the cluster.
To delete a database, run:
kubectl delete redb mydb
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 maintained by the database controller.
For comprehensive information about connecting to your database, including: