---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.16.1
  name: clusters.core.pingcap.com
spec:
  group: core.pingcap.com
  names:
    categories:
    - tc
    kind: Cluster
    listKind: ClusterList
    plural: clusters
    singular: cluster
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .status.components[?(@.kind=="PD")].replicas
      name: PD
      type: integer
    - jsonPath: .status.components[?(@.kind=="TiKV")].replicas
      name: TiKV
      type: integer
    - jsonPath: .status.components[?(@.kind=="TiDB")].replicas
      name: TiDB
      type: integer
    - jsonPath: .status.components[?(@.kind=="TiFlash")].replicas
      name: TiFlash
      type: integer
    - jsonPath: .status.conditions[?(@.type=="Available")].status
      name: Available
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: Cluster defines a TiDB cluster
        properties:
          apiVersion:
            description: |-
              APIVersion defines the versioned schema of this representation of an object.
              Servers should convert recognized schemas to the latest internal value, and
              may reject unrecognized values.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
            type: string
          kind:
            description: |-
              Kind is a string value representing the REST resource this object represents.
              Servers may infer this from the endpoint the client submits requests to.
              Cannot be updated.
              In CamelCase.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
            type: string
          metadata:
            type: object
          spec:
            properties:
              paused:
                description: Paused specifies whether to pause the reconciliation
                  loop for all components of the cluster.
                type: boolean
              revisionHistoryLimit:
                description: |-
                  RevisionHistoryLimit is the maximum number of revisions that will
                  be maintained in each Group's revision history.
                  The revision history consists of all revisions not represented by a currently applied version.
                  The default value is 10.
                format: int32
                minimum: 0
                type: integer
              suspendAction:
                description: SuspendAction defines the suspend actions for the cluster.
                properties:
                  suspendCompute:
                    description: SuspendCompute indicates delete the pods but keep
                      the PVCs.
                    type: boolean
                type: object
              tlsCluster:
                description: Whether enable the TLS connection between TiDB cluster
                  components.
                properties:
                  enabled:
                    description: |-
                      Enable mutual TLS connection between TiDB cluster components.
                      Once enabled, the mutual authentication applies to all components,
                      and it does not support applying to only part of the components.
                      The steps to enable this feature:
                        1. Generate TiDB cluster components certificates and a client-side certifiacete for them.
                           There are multiple ways to generate these certificates:
                             - user-provided certificates: https://docs.pingcap.com/tidb/stable/generate-self-signed-certificates
                             - use the K8s built-in certificate signing system signed certificates: https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/
                             - or use cert-manager signed certificates: https://cert-manager.io/
                        2. Create one secret object for one component group which contains the certificates created above.
                           The name of this Secret must be: <clusterName>-<groupName>-cluster-secret.
                             For PD: kubectl create secret generic <clusterName>-<pd-groupName>-cluster-secret --namespace=<namespace> --from-file=tls.crt=<path/to/tls.crt> --from-file=tls.key=<path/to/tls.key> --from-file=ca.crt=<path/to/ca.crt>
                             For TiKV: kubectl create secret generic <clusterName>-<tikv-groupName>-cluster-secret --namespace=<namespace> --from-file=tls.crt=<path/to/tls.crt> --from-file=tls.key=<path/to/tls.key> --from-file=ca.crt=<path/to/ca.crt>
                             For TiDB: kubectl create secret generic <clusterName>-<tidb-groupName>-cluster-secret --namespace=<namespace> --from-file=tls.crt=<path/to/tls.crt> --from-file=tls.key=<path/to/tls.key> --from-file=ca.crt=<path/to/ca.crt>
                             For Client: kubectl create secret generic <clusterName>-cluster-client-secret --namespace=<namespace> --from-file=tls.crt=<path/to/tls.crt> --from-file=tls.key=<path/to/tls.key> --from-file=ca.crt=<path/to/ca.crt>
                             Same for other components.
                    type: boolean
                type: object
              upgradePolicy:
                description: UpgradePolicy defines the upgrade policy for the cluster.
                type: string
            type: object
          status:
            properties:
              components:
                description: Components is the status of each component in the cluster.
                items:
                  description: ComponentStatus is the status of a component in the
                    cluster.
                  properties:
                    kind:
                      description: Kind is the kind of the component, e.g., PD, TiKV,
                        TiDB, TiFlash.
                      enum:
                      - PD
                      - TiKV
                      - TiDB
                      - TiFlash
                      type: string
                    replicas:
                      description: Replicas is the number of desired replicas of the
                        component.
                      format: int32
                      type: integer
                  required:
                  - kind
                  - replicas
                  type: object
                type: array
                x-kubernetes-list-map-keys:
                - kind
                x-kubernetes-list-type: map
              conditions:
                description: Conditions contains the current status of the cluster.
                items:
                  description: Condition contains details for one aspect of the current
                    state of this API Resource.
                  properties:
                    lastTransitionTime:
                      description: |-
                        lastTransitionTime is the last time the condition transitioned from one status to another.
                        This should be when the underlying condition changed.  If that is not known, then using the time when the API field changed is acceptable.
                      format: date-time
                      type: string
                    message:
                      description: |-
                        message is a human readable message indicating details about the transition.
                        This may be an empty string.
                      maxLength: 32768
                      type: string
                    observedGeneration:
                      description: |-
                        observedGeneration represents the .metadata.generation that the condition was set based upon.
                        For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
                        with respect to the current state of the instance.
                      format: int64
                      minimum: 0
                      type: integer
                    reason:
                      description: |-
                        reason contains a programmatic identifier indicating the reason for the condition's last transition.
                        Producers of specific condition types may define expected values and meanings for this field,
                        and whether the values are considered a guaranteed API.
                        The value should be a CamelCase string.
                        This field may not be empty.
                      maxLength: 1024
                      minLength: 1
                      pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
                      type: string
                    status:
                      description: status of the condition, one of True, False, Unknown.
                      enum:
                      - "True"
                      - "False"
                      - Unknown
                      type: string
                    type:
                      description: type of condition in CamelCase or in foo.example.com/CamelCase.
                      maxLength: 316
                      pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
                      type: string
                  required:
                  - lastTransitionTime
                  - message
                  - reason
                  - status
                  - type
                  type: object
                type: array
                x-kubernetes-list-map-keys:
                - type
                x-kubernetes-list-type: map
              observedGeneration:
                description: |-
                  observedGeneration is the most recent generation observed for this Cluster. It corresponds to the
                  Cluster's generation, which is updated on mutation by the API Server.
                format: int64
                type: integer
              pd:
                description: |-
                  PD means url of the pd service, it's prepared for internal use
                  e.g. https://pd:2379
                type: string
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}
