# For Kubernetes 1.16+.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: statefulsets.apps.pingcap.com
spec:
  group: apps.pingcap.com
  versions:
  - name: v1alpha1
    served: true
    storage: false
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            required:
            - replicas
            - selector
            - template
            - serviceName
            properties:
              replicas:
                type: integer
                minimum: 0
                default: 1
              selector:
                type: object
                # TODO validate all fields
                x-kubernetes-preserve-unknown-fields: true
              template:
                type: object
                # TODO validate all fields
                x-kubernetes-preserve-unknown-fields: true
              volumeClaimTemplates:
                type: array
                items:
                  type: object
                  # TODO validate all fields
                  x-kubernetes-preserve-unknown-fields: true
              serviceName:
                type: string
              podManagementPolicy:
                type: string
                # TODO OrderedReady/Parallel
              updateStrategy:
                type: object
                # TODO validate all fields
                x-kubernetes-preserve-unknown-fields: true
              revisionHistoryLimit:
                type: integer
                minimum: 0
                default: 10
          status:
            type: object
            # TODO validate all fields
            x-kubernetes-preserve-unknown-fields: true
    additionalPrinterColumns:
    - name: Desired
      type: integer
      jsonPath: .spec.replicas
    - name: Current
      type: integer
      jsonPath: .status.readyReplicas
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
    # subresources describes the subresources for custom resources.
    subresources:
      # status enables the status subresource.
      status: {}
      # scale enables the scale subresource.
      scale:
        # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas.
        specReplicasPath: .spec.replicas
        # statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas.
        statusReplicasPath: .status.replicas
        # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector.
        labelSelectorPath: .status.labelSelector
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            required:
            - replicas
            - selector
            - template
            - serviceName
            properties:
              replicas:
                type: integer
                minimum: 0
                default: 1
              selector:
                type: object
                # TODO validate all fields
                x-kubernetes-preserve-unknown-fields: true
              template:
                type: object
                # TODO validate all fields
                x-kubernetes-preserve-unknown-fields: true
              volumeClaimTemplates:
                type: array
                items:
                  type: object
                  # TODO validate all fields
                  x-kubernetes-preserve-unknown-fields: true
              serviceName:
                type: string
              podManagementPolicy:
                type: string
                # TODO OrderedReady/Parallel
              updateStrategy:
                type: object
                # TODO validate all fields
                x-kubernetes-preserve-unknown-fields: true
              revisionHistoryLimit:
                type: integer
                minimum: 0
                default: 10
          status:
            type: object
            # TODO validate all fields
            x-kubernetes-preserve-unknown-fields: true
    additionalPrinterColumns:
    - name: Desired
      type: integer
      jsonPath: .spec.replicas
    - name: Current
      type: integer
      jsonPath: .status.readyReplicas
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
    # subresources describes the subresources for custom resources.
    subresources:
      # status enables the status subresource.
      status: {}
      # scale enables the scale subresource.
      scale:
        # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas.
        specReplicasPath: .spec.replicas
        # statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas.
        statusReplicasPath: .status.replicas
        # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector.
        labelSelectorPath: .status.labelSelector
  scope: Namespaced
  names:
    plural: statefulsets
    singular: statefulset
    kind: StatefulSet
    shortNames:
    - asts
    categories:
    - all
