apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: redisenterprisedatabases.app.redislabs.com
spec:
  group: app.redislabs.com
  names:
    kind: RedisEnterpriseDatabase
    listKind: RedisEnterpriseDatabaseList
    plural: redisenterprisedatabases
    singular: redisenterprisedatabase
    shortNames:
      - redb
  scope: Namespaced
  preserveUnknownFields: false
  versions:
  - name: v1alpha1
    served: true
    storage: true
    additionalPrinterColumns:
      - jsonPath: .status.version
        name: Version
        type: string
      - jsonPath: .status.internalEndpoints[*].port
        name: Port
        type: string
      - jsonPath: .status.redisEnterpriseCluster
        name: Cluster
        type: string
      - jsonPath: .status.shardStatuses.active
        name: Shards
        type: string
      - jsonPath: .status.status
        name: Status
        type: string
      - jsonPath: .status.specStatus
        name: Spec Status
        type: string
      - jsonPath: .metadata.creationTimestamp
        name: Age
        type: date
    subresources:
      status: {}
    schema:
      openAPIV3Schema:
        description: RedisEnterpriseDatabase is the Schema for the redisenterprisedatabases
          API
        properties:
          apiVersion:
            type: string
          kind:
            type: string
          metadata:
            type: object
          spec:
            description: RedisEnterpriseDatabaseSpec defines the desired state of RedisEnterpriseDatabase
            properties:
              alertSettings:
                description: Settings for database alerts
                properties:
                  bdb_backup_delayed:
                    description: "Periodic backup has been delayed for longer than specified threshold value [minutes].
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_crdt_src_high_syncer_lag:
                    description: "Active-active source - sync lag is higher than specified threshold value [seconds]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_crdt_src_syncer_connection_error:
                    description: "Active-active source - sync has connection error while trying to connect replica source
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_crdt_src_syncer_general_error:
                    description: "Active-active source - sync encountered in general error
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_high_latency:
                    description: "Latency is higher than specified threshold value [micro-sec]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_high_throughput:
                    description: "Throughput is higher than specified threshold value [requests / sec.]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_long_running_action:
                    description: "An alert for state-machines that are running for too long
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_low_throughput:
                    description: "Throughput is lower than specified threshold value [requests / sec.]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_ram_dataset_overhead:
                    description: "Dataset RAM overhead of a shard has reached the threshold value [% of its RAM limit]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_ram_values:
                    description: "Percent of values kept in a shard's RAM is lower than [% of its key count]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_replica_src_high_syncer_lag:
                    description: "Replica-of source - sync lag is higher than specified threshold value [seconds]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_replica_src_syncer_connection_error:
                    description: "Replica-of source - sync has connection error while trying to connect replica source
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_shard_num_ram_values:
                    description: "Number of values kept in a shard's RAM is lower than [values]
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                  bdb_size:
                    description: "Dataset size has reached the threshold value [% of the memory limit] expected fields:
                      -Note threshold is commented (allow string/int/float and support backwards compatibility) but is required"
                    properties:
                      enabled:
                        description: Alert enabled or disabled
                        type: boolean
  #                   threshold:
  #                     description: Threshold for alert going on/off
  #                     type: string
                    x-kubernetes-preserve-unknown-fields: true
                    type: object
                type: object
              backup:
                description: Target for automatic database backups.
                properties:
                  abs:
                    properties:
                      absSecretName:
                        description: The name of the K8s secret that holds ABS credentials.
                          The secret must contain the keys "AccountName" and "AccountKey",
                          and these must hold the corresponding credentials
                        type: string
                      container:
                        description: Azure Blob Storage container name.
                        type: string
                      subdir:
                        description: Optional. Azure Blob Storage subdir under container.
                        type: string
                    required:
                    - absSecretName
                    - container
                    type: object
                  ftp:
                    properties:
                      url:
                        description: "a URI of the ftps://[USER[:PASSWORD]@]HOST[:PORT]/PATH[/]"
                        type: string
                        pattern: ftps?://(([^@]+)@)?([^@/:]+)(:(\d+))?([/\.]/?[^@/\.]+)*?/?$
                    required:
                    - url
                    type: object
                  gcs:
                    description: GoogleStorage
                    properties:
                      bucketName:
                        description: Google Storage bucket name.
                        type: string
                      gcsSecretName:
                        description: The name of the K8s secret that holds the Google
                          Cloud Storage credentials. The secret must contain the keys
                          "CLIENT_ID", "PRIVATE_KEY", "PRIVATE_KEY_ID", "CLIENT_EMAIL"
                          and these must hold the corresponding credentials. The keys
                          should correspond to the values in the key JSON.
                        type: string
                      subdir:
                        description: Optional. Google Storage subdir under bucket.
                        type: string
                    required:
                    - bucketName
                    - gcsSecretName
                    type: object
                  interval:
                    description: Backup Interval in seconds
                    type: integer
                  mount:
                    description: MountPointStorage
                    properties:
                      path:
                        description: Path to the local mount point. You must create
                          the mount point on all nodes, and the redislabs:redislabs
                          user must have read and write permissions on the local mount
                          point.
                        type: string
                    required:
                    - path
                    type: object
                  s3:
                    properties:
                      awsSecretName:
                        description: The name of the K8s secret that holds the AWS credentials.
                          The secret must contain the keys "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY",
                          and these must hold the corresponding credentials.
                        type: string
                      bucketName:
                        description: Amazon S3 bucket name.
                        type: string
                      subdir:
                        description: Optional. Amazon S3 subdir under bucket.
                        type: string
                    required:
                    - awsSecretName
                    - bucketName
                    type: object
                  sftp:
                    properties:
                      sftp_url:
                        description: SFTP url
                        type: string
                        pattern: ^sftp://(([^@]+)@)?([^@/:]+)(:(\d+))?(/([^@/\.]+[/\.]?)*)?$
                      sftpSecretName:
                        description: The name of the K8s secret that holds SFTP credentials.
                          The secret must contain the "Key" key, which is the SSH private
                          key for connecting to the sftp server.
                        type: string
                    required:
                    - sftpSecretName
                    - sftp_url
                    type: object
                  swift:
                    properties:
                      auth_url:
                        description: Swift service authentication URL.
                        type: string
                        pattern: ^https?://(([^@]+)@)?([^@/:]+)(:(\d+))?([/\.]([^@/\.]+))*?/?$
                      container:
                        description: Swift object store container for storing the backup
                          files.
                        type: string
                      prefix:
                        description: Optional. Prefix (path) of backup files in the
                          swift container.
                        type: string
                      swiftSecretName:
                        description: 'The name of the K8s secret that holds Swift credentials.
                          The secret must contain the keys "Key" and "User", and these
                          must hold the corresponding credentials: service access key
                          and service user name (pattern for the latter does not allow
                          special characters &,<,>,")'
                        type: string
                    required:
                    - auth_url
                    - container
                    - swiftSecretName
                    type: object
                type: object
              clientAuthenticationCertificates:
                description: The Secrets containing TLS Client Certificate to use for
                  Authentication
                items:
                  type: string
                type: array
              dataInternodeEncryption:
                description: Internode encryption (INE) setting. An optional boolean setting, overriding
                  a similar cluster-wide policy.
                  If set to False, INE is guaranteed to be turned off for this DB (regardless of cluster-wide policy).
                  If set to True, INE will be turned on, unless the capability is not supported by the DB (
                  in such a case we will get an error and database creation will fail).
                  If left unspecified, will be disabled if internode encryption is not supported by the DB
                  (regardless of cluster default).
                  Deleting this property after explicitly setting its value shall have no effect.
                type: boolean
              databasePort:
                description: Database port number. TCP port on which the database is
                  available. Will be generated automatically if omitted. can not be
                  changed after creation
                type: integer
              databaseSecretName:
                description: The name of the K8s secret that holds the password to the
                  database.
                type: string
              defaultUser:
                description: Is connecting with a default user allowed?
                type: boolean
              evictionPolicy:
                description: Database eviction policy. see more https://docs.redislabs.com/latest/rs/administering/database-operations/eviction-policy/
                type: string
              memorySize:
                description: memory size of database. use formats like 100MB, 0.1GB.
                  minimum value in 100MB.
                type: string
              modulesList:
                description: List of modules associated with database
                items:
                  description: 'Redis Enterprise Module: https://redislabs.com/redis-enterprise/modules/'
                  properties:
                    config:
                      description: Module command line arguments e.g. VKEY_MAX_ENTITY_COUNT
                        30
                      type: string
                    name:
                      description: The module's name e.g "ft" for redissearch
                      type: string
                    version:
                      description: Module's semantic version e.g "1.6.12"
                      type: string
                  required:
                  - name
                  - version
                  type: object
                type: array
              ossCluster:
                description: OSS Cluster mode option. Note that not all client libraries
                  support OSS cluster mode.
                type: boolean
              persistence:
                description: Database on-disk persistence policy
                enum:
                - disabled
                - aofEverySecond
                - aofAlways
                - snapshotEvery1Hour
                - snapshotEvery6Hour
                - snapshotEvery12Hour
                type: string
              proxyPolicy:
                description: 'The policy used for proxy binding to the endpoint. Supported
                  proxy policies are: single/all-master-shards/all-nodes When left blank,
                  the default value will be chosen according to the value of ossCluster
                  - single if disabled, all-master-shards when enabled'
                type: string
              rackAware:
                description: 'Whether database should be rack aware. This improves availability
                  - more information: https://docs.redislabs.com/latest/rs/concepts/high-availability/rack-zone-awareness/'
                type: boolean
              redisEnterpriseCluster:
                description: Connection to Redis Enterprise Cluster
                properties:
                  name:
                    description: The name of the Redis Enterprise Cluster where the
                      database should be stored.
                    type: string
                required:
                - name
                type: object
              replicaSources:
                description: What databases to replicate from
                items:
                  properties:
                    clientKeySecret:
                      description: Secret that defines what client key to use.  The
                        secret needs 2 keys in it's map, "cert" that is the PEM encoded
                        certificate and "key" that is the PEM encoded private key
                      type: string
                    compression:
                      description: GZIP Compression level (0-9) to use for replication
                      type: integer
                    replicaSourceName:
                      description: Kubernetes resource name of type ReplicaSourceType
                      type: string
                    replicaSourceType:
                      description: Determines what Kuberetes resource ReplicaSourceName
                        refers to SECRET - Get URI from secret named in ReplicaSourceName.  The
                        secret will have a uri key that defines the complete, redis://
                        URI REDB - Determine URI from Kubernetes REDB resource named
                        in ReplicaSourceName
                      type: string
                    serverCertSecret:
                      description: Secret that defines the Server's certificate.  The
                        secret needs 1 key in it's map, "cert" that is the PEM encoded
                        certificate
                      type: string
                    tlsSniName:
                      description: TLS SNI Name to use
                      type: string
                  required:
                  - replicaSourceName
                  - replicaSourceType
                  type: object
                type: array
              replication:
                description: In-memory database replication. When enabled, database
                  will have replica shard for every master - leading to higher availability.
                type: boolean
              rolesPermissions:
                description: List of Redis Enteprise ACL and Role bindings to apply
                items:
                  description: Redis Enterprise Role and ACL Binding
                  properties:
                    acl:
                      description: Acl Name of RolePermissionType
                      type: string
                    role:
                      description: Role Name of RolePermissionType
                      type: string
                    type:
                      description: Type of Redis Enterprise Database Role Permission
                      type: string
                  required:
                  - acl
                  - role
                  - type
                  type: object
                type: array
              shardCount:
                description: Number of database server-side shards
                type: integer
              tlsMode:
                description: Require SSL authenticated and encrypted connections to
                  the database. enabled - all incoming connections to the Database must
                  use SSL. disabled - no incoming connection to the Database should
                  use SSL. replica_ssl - databases that replicate from this one need
                  to use SSL.
                enum:
                - disabled
                - enabled
                - replica_ssl
                type: string
            type: object
          status:
            description: RedisEnterpriseDatabaseStatus defines the observed state of
              RedisEnterpriseDatabase
            properties:
              createdTime:
                description: Time when the database was created
                type: string
              databaseUID:
                description: Database UID provided by redis enterprise
                type: string
              internalEndpoints:
                description: Endpoints listed internally by the Redis Enterprise Cluster.
                  Can be used to correlate a ReplicaSourceStatus entry.
                items:
                  properties:
                    host:
                      description: Hostname assigned to the database
                      type: string
                    port:
                      description: Database port name
                      type: integer
                  type: object
                type: array
              lastActionStatus:
                description: Status of the last action done by operator on this database
                type: string
              lastActionUid:
                description: UID of the last action done by operator on this database
                type: string
              lastUpdated:
                description: Time when the database was last updated
                type: string
              observedGeneration:
                description: 'The generation (built in update counter of K8s) of the
                  REDB resource that was fully acted upon, meaning that all changes
                  were handled and sent as an API call to the Redis Enterprise Cluster
                  (REC). This field value should equal the current generation when the
                  resource changes were handled. Note: the lastActionStatus field tracks
                  actions handled asynchronously by the Redis Enterprise Cluster.'
                format: int64
                type: integer
              redisEnterpriseCluster:
                description: The Redis Enterprise Cluster Object this Resource is associated
                  with
                type: string
              replicaSourceStatuses:
                description: ReplicaSource statuses
                items:
                  properties:
                    endpointHost:
                      description: The internal host name of the replica source database.
                        Can be used as an identifier. See the internalEndpoints list
                        on the REDB status.
                      type: string
                    lag:
                      description: Lag in millisec between source and destination (while
                        synced).
                      type: integer
                    lastError:
                      description: Last error encountered when syncing from the source.
                      type: string
                    lastUpdate:
                      description: Time when we last receive an update from the source.
                      type: string
                    rdbSize:
                      description: The source’s RDB size to be transferred during the
                        syncing phase.
                      type: integer
                    rdbTransferred:
                      description: Number of bytes transferred from the source’s RDB
                        during the syncing phase.
                      type: integer
                    status:
                      description: Sync status of this source
                      type: string
                  required:
                  - endpointHost
                  type: object
                type: array
              shardStatuses:
                additionalProperties:
                  type: integer
                description: Aggregated statuses of shards
                type: object
              specStatus:
                description: Whether the desired specification is valid
                type: string
              status:
                description: The status of the database
                type: string
              version:
                description: Database compatibility version
                type: string
            type: object
        type: object
