# Template Parameters:
#
# NONE
#
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: clickhouseoperatorconfigurations.clickhouse.altinity.com
spec:
  group: clickhouse.altinity.com
  scope: Namespaced
  names:
    kind: ClickHouseOperatorConfiguration
    singular: clickhouseoperatorconfiguration
    plural: clickhouseoperatorconfigurations
    shortNames:
      - chopconf
  versions:
    - name: v1
      served: true
      storage: true
      additionalPrinterColumns:
        - name: namespaces
          type: string
          description: Watch namespaces
          priority: 0 # show in standard view
          jsonPath: .status
      schema:
        openAPIV3Schema:
          type: object
          description: "allows customize `clickhouse-operator` settings, need restart clickhouse-operator pod after adding, more details https://github.com/Altinity/clickhouse-operator/blob/master/docs/operator_configuration.md"
          x-kubernetes-preserve-unknown-fields: true
          properties:
            status:
              type: object
              x-kubernetes-preserve-unknown-fields: true
            spec:
              type: object
              description: |
                allows define some of settings for `clickhouse-operator` itself,
                More info: https://github.com/Altinity/clickhouse-operator/blob/master/config/config.yaml
                look to etc-clickhouse-operator* ConfigMaps if you need more control
              x-kubernetes-preserve-unknown-fields: true
              properties:
                watchNamespaces:
                  type: array
                  description: "List of namespaces where clickhouse-operator watches for events."
                  items:
                    type: string
                chCommonConfigsPath:
                  type: string
                  description: "Path to folder where ClickHouse configuration files common for all instances within CHI are located. Default - config.d"
                chHostConfigsPath:
                  type: string
                  description: "Path to folder where ClickHouse configuration files unique for each instance (host) within CHI are located. Default - conf.d"
                chUsersConfigsPath:
                  type: string
                  description: "Path to folder where ClickHouse configuration files with users settings are located. Files are common for all instances within CHI"
                chiTemplatesPath:
                  type: string
                  description: "Path to folder where ClickHouseInstallation .yaml manifests are located."
                statefulSetUpdateTimeout:
                  type: integer
                  description: "How many seconds to wait for created/updated StatefulSet to be Ready"
                statefulSetUpdatePollPeriod:
                  type: integer
                  description: "How many seconds to wait between checks for created/updated StatefulSet status"
                onStatefulSetCreateFailureAction:
                  type: string
                  description: |
                    What to do in case created StatefulSet is not in Ready after `statefulSetUpdateTimeout` seconds
                    Possible options:
                    1. abort - do nothing, just break the process and wait for admin.
                    2. delete - delete newly created problematic StatefulSet.
                    3. ignore (default) - ignore error, pretend nothing happened and move on to the next StatefulSet.
                onStatefulSetUpdateFailureAction:
                  type: string
                  description: |
                    What to do in case updated StatefulSet is not in Ready after `statefulSetUpdateTimeout` seconds
                    Possible options:
                    1. abort - do nothing, just break the process and wait for admin.
                    2. rollback (default) - delete Pod and rollback StatefulSet to previous Generation. Pod would be recreated by StatefulSet based on rollback-ed configuration.
                    3. ignore - ignore error, pretend nothing happened and move on to the next StatefulSet.
                chConfigUserDefaultProfile:
                  type: string
                  description: "ClickHouse server configuration `<profile>...</profile>` for any <user>"
                chConfigUserDefaultQuota:
                  type: string
                  description: "ClickHouse server configuration `<quota>...</quota>` for any <user>"
                chConfigUserDefaultNetworksIP:
                  type: array
                  description: "ClickHouse server configuration `<networks><ip>...</ip></networks>` for any <user>"
                  items:
                    type: string
                chConfigUserDefaultPassword:
                  description: "ClickHouse server configuration `<password>...</password>` for any <user>"
                  type: string
                chConfigNetworksHostRegexpTemplate:
                  description: "ClickHouse server configuration `<host_regexp>...</host_regexp>` for any <user>"
                  type: string
                chUsername:
                  type: string
                  description: "ClickHouse username to be used by operator to connect to ClickHouse instances, deprecated, use chCredentialsSecretName"
                chPassword:
                  type: string
                  description: "ClickHouse password to be used by operator to connect to ClickHouse instances, deprecated, use chCredentialsSecretName"
                chCredentialsSecretNamespace:
                  type: string
                  description: "Location of k8s Secret with username and password to be used by operator to connect to ClickHouse instances"
                chCredentialsSecretName:
                  type: string
                  description: "Name of k8s Secret with username and password to be used by operator to connect to ClickHouse instances"
                chPort:
                  type: integer
                  minimum: 1
                  maximum: 65535
                  description: "Name of k8s Secret with username and password to be used by operator to connect to ClickHouse instances"
                logtostderr:
                  type: string
                  description: "boolean, allows logs to stderr"
                alsologtostderr:
                  type: string
                  description: "boolean allows logs to stderr and files both"
                v:
                  type: string
                  description: "verbosity level of clickhouse-operator log, default - 1 max - 9"
                stderrthreshold:
                  type: string
                vmodule:
                  type: string
                log_backtrace_at:
                  type: string
                reconcileThreadsNumber:
                  type: integer
                  description: "how much goroutines will use to reconcile in parallel, 10 by default"
                  minimum: 1
                  maximum: 65535
                reconcileWaitExclude:
                  type: string
                reconcileWaitInclude:
                  type: string
                excludeFromPropagationLabels:
                  type: array
                  description: |
                    When propagating labels from the chi's `metadata.labels` section to child objects' `metadata.labels`,
                    exclude labels from the following list
                  items:
                    type: string
                appendScopeLabels:
                  type: string
                  description: "Whether to append *Scope* labels to StatefulSet and Pod"
                  enum:
                    # List StringBoolXXX constants from model
                    - ""
                    - "0"
                    - "1"
                    - "False"
                    - "false"
                    - "True"
                    - "true"
                    - "No"
                    - "no"
                    - "Yes"
                    - "yes"
                    - "Off"
                    - "off"
                    - "On"
                    - "on"
                    - "Disable"
                    - "disable"
                    - "Enable"
                    - "enable"
                    - "Disabled"
                    - "disabled"
                    - "Enabled"
                    - "enabled"
                    - "LabelShardScopeIndex"
                    - "LabelReplicaScopeIndex"
                    - "LabelCHIScopeIndex"
                    - "LabelCHIScopeCycleSize"
                    - "LabelCHIScopeCycleIndex"
                    - "LabelCHIScopeCycleOffset"
                    - "LabelClusterScopeIndex"
                    - "LabelClusterScopeCycleSize"
                    - "LabelClusterScopeCycleIndex"
                    - "LabelClusterScopeCycleOffset"
