RedisLabs / redis-enterprise-k8s-docs

154 stars 91 forks source link

Where can I find details or examples for creating a real RedisEnterpriseDatabase resource? #189

Open grtrout opened 3 years ago

grtrout commented 3 years ago

I was hoping that I could create a database in the UI and it would create a RedisEnterpriseDatabase resource that I could learn from, but creating the database in the UI does not create a RedisEnterpriseDatabase resource at all. The examples for RedisEnterpriseDatabase have basically nothing outside of the memorySize specified.

So, where can I find examples of a RedisEnterpriseDatabase resource where things like replication, shards, eviction policy, etc. are specified?

Thanks!

laurentdroin commented 3 years ago

Hi,

Indeed, creating a database in the UI will not create a corresponding REDB Kubernetes resource (the Redis Enterprise Cluster by itself not being aware it is running in a Kubernetes environment). Note that when a database is created as a REDB resource, the manifest for that resource is the source of truth, and modifications you may make to the database in the UI will be reverted as the REDB controller will constantly try to reconcile the REDB resource specification with the real world.

You can find all the REDB supported properties here: https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/redis_enterprise_database_api.md#redisenterprisedatabasespec

Here is a small example of a REDB definition that makes use of some of these properties:

apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
  name: my-custom-db
spec:
  memorySize: 100MB
  replication: true
  persistence: snapshotEvery1Hour
  shardCount: 2
  evictionPolicy: allkeys-lru

I hope this will help.

Cheers,

Laurent.

grtrout commented 3 years ago

@laurentdroin Thank you - that is very helpful.

A few comments:

Finally, and this is just in case it helps anyone else, here is the YAML I settled on using:

apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
  name: redb-db1
spec:
  alertSettings: {}
  databaseSecretName: "redb-db1-secret"
  defaultUser: false
  evictionPolicy: allkeys-lru
  memorySize: 2GB
  modulesList: []
  ossCluster: false
  persistence: disabled
  proxyPolicy: single
  rackAware: false
  redisEnterpriseCluster:
    name: rec-test
  replication: true
  shardCount: 4
  tlsMode: disabled
laurentdroin commented 3 years ago

Hi @grtrout

There is an admission controller that you can configure and that should help block the REDB creation if the corresponding database cannot be created. The admission controller is now deployed as part of the Operator deployment (in its own container). See step 5 of https://github.com/RedisLabs/redis-enterprise-k8s-docs#installation and also https://github.com/RedisLabs/redis-enterprise-k8s-docs/tree/master/admission

There is also a way to deploy a REDB resource in a different namespace (which we call "consumer" namespace). See https://github.com/RedisLabs/redis-enterprise-k8s-docs/tree/master/multi-namespace-redb

Hope this is helpful.

Laurent.

grtrout commented 3 years ago

@laurentdroin Excellent! I will check into both the admission controller and the consumer namespace strategy. Thanks for your help.

grtrout commented 3 years ago

@laurentdroin - is it possible to configure a RedisEnterpriseDatabase using the RedisEnterpriseDatabaseSpec and not require auth?

laurentdroin commented 3 years ago

@grtrout - Not directly, but you should be able to achieve this by creating a secret with an empty password first and then specifying that secret in the REDB manifest before the REDB is created.

Something like: kubectl create secret generic my-password --from-literal=password=''

and then:

apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
  name: my-db
spec:
  databaseSecretName: my-password

I hope this helps.

Laurent.

grtrout commented 3 years ago

@laurentdroin Thanks. I was able to get that working, but I ended up just modifying my configmaps to supply the generated password. I was more interested in not having to do this at all for quick testing (and since this is, I believe, how it's set up by default in the web UI).

grtrout commented 3 years ago

@laurentdroin - If I want to specify the port where my database is exposed, can that be done via the RedisEnterpriseDatabase resource definition? This is an important feature that I used with the Web UI since it allowed me to declare the port and specify it in the applications' manifests without having to use any sort of find/replace scripting.

laurentdroin commented 3 years ago

@grtrout - It is currently not possible via REDB but we do have a feature request on this in order for this to be implemented in a future version.