apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: cyclenoderequests.atlassian.com
spec:
  group: atlassian.com
  names:
    kind: CycleNodeRequest
    listKind: CycleNodeRequestList
    plural: cyclenoderequests
    shortNames:
    - cnr
    singular: cyclenoderequest
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - description: The node group being cycled
      jsonPath: .spec.nodeGroupName
      name: Node Group Name
      type: string
    - description: The method being used for the cycle operation
      jsonPath: .spec.cycleSettings.method
      name: Method
      type: string
    - description: Max nodes the request is cycling at once
      jsonPath: .spec.cycleSettings.concurrency
      name: Concurrency
      type: integer
    - description: The status of the request
      jsonPath: .status.phase
      name: Status
      type: string
    - description: Age of the request
      jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
    name: v1
    schema:
      openAPIV3Schema:
        description: CycleNodeRequest is the Schema for the cyclenoderequests API
        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:
            description: CycleNodeRequestSpec defines the desired state of CycleNodeRequest
            properties:
              cycleSettings:
                description: CycleSettings stores the settings to use for cycling
                  the nodes.
                properties:
                  concurrency:
                    description: Concurrency is the number of nodes that one CycleNodeRequest
                      will work on in parallel. Defaults to the size of the node group.
                    format: int64
                    type: integer
                  ignoreNamespaces:
                    description: IgnoreNamespaces is a list of namespace names in
                      which running pods should be ignored when deciding whether a
                      node has no more pods running.
                    items:
                      type: string
                    type: array
                  ignorePodsLabels:
                    additionalProperties:
                      items:
                        type: string
                      type: array
                    description: 'IgnorePodLabels is a map of values for labels that
                      describes which pods should be ignored when deciding whether
                      a node has no more pods running. This map defines a union: any
                      pod that matches any of the values for a given label name will
                      be ignored.'
                    type: object
                  labelsToRemove:
                    description: LabelsToRemove is an array of labels to remove off
                      of the pods running on the node This can be used to remove a
                      pod from a service/endpoint before evicting/deleting it to prevent
                      traffic being sent to it.
                    items:
                      type: string
                    type: array
                  method:
                    description: Method describes the type of cycle operation to use.
                    enum:
                    - Drain
                    - Wait
                    type: string
                required:
                - method
                type: object
              nodeGroupName:
                description: NodeGroupName is the name of the node group in the cloud
                  provider that will be increased to bring up replacement nodes.
                type: string
              nodeGroupsList:
                description: NodeGroupsList is a list of node groups in the cloud
                  provider which includes target nodes selected by node selector
                items:
                  type: string
                type: array
              nodeNames:
                description: NodeNames is an optional list of the names of nodes to
                  rotate. This is used to only rotate specific nodes belonging to
                  the NodeGroup, rather than every node in the group. If no node names
                  are provided in NodeNames then the entire node group will be rotated.
                items:
                  type: string
                type: array
              selector:
                description: Selector is the label selector used to select the nodes
                  that are to be terminated
                properties:
                  matchExpressions:
                    description: matchExpressions is a list of label selector requirements.
                      The requirements are ANDed.
                    items:
                      description: A label selector requirement is a selector that
                        contains values, a key, and an operator that relates the key
                        and values.
                      properties:
                        key:
                          description: key is the label key that the selector applies
                            to.
                          type: string
                        operator:
                          description: operator represents a key's relationship to
                            a set of values. Valid operators are In, NotIn, Exists
                            and DoesNotExist.
                          type: string
                        values:
                          description: values is an array of string values. If the
                            operator is In or NotIn, the values array must be non-empty.
                            If the operator is Exists or DoesNotExist, the values
                            array must be empty. This array is replaced during a strategic
                            merge patch.
                          items:
                            type: string
                          type: array
                      required:
                      - key
                      - operator
                      type: object
                    type: array
                  matchLabels:
                    additionalProperties:
                      type: string
                    description: matchLabels is a map of {key,value} pairs. A single
                      {key,value} in the matchLabels map is equivalent to an element
                      of matchExpressions, whose key field is "key", the operator
                      is "In", and the values array contains only "value". The requirements
                      are ANDed.
                    type: object
                type: object
            required:
            - cycleSettings
            - nodeGroupName
            - selector
            type: object
          status:
            description: CycleNodeRequestStatus defines the observed state of CycleNodeRequest
            properties:
              activeChildren:
                description: ActiveChildren is the active number of CycleNodeStatuses
                  that this CycleNodeRequest was aware of when it last checked for
                  progress in the cycle operation.
                format: int64
                type: integer
              currentNodes:
                description: CurrentNodes stores the current nodes that are being
                  "worked on". Used to batch operations against the node group in
                  the cloud provider. Once a node is passed off to a CycleNodeStatus
                  CRD, it is no longer listed here.
                items:
                  description: CycleNodeRequestNode stores a current node that is
                    being worked on
                  properties:
                    name:
                      description: Name of the node
                      type: string
                    nodeGroupName:
                      description: NodeGroupName stores current cloud provider node
                        group name which this node belongs to
                      type: string
                    providerId:
                      description: Cloud Provider ID of the node
                      type: string
                  required:
                  - name
                  - nodeGroupName
                  - providerId
                  type: object
                type: array
              equilibriumWaitStarted:
                description: EquilibriumWaitStarted stores the time when we started
                  waiting for equilibrium of Kube nodes and node group instances.
                  This is used to give some leeway if we start a request at the same
                  time as a cluster scaling event. If we breach the time limit we
                  fail the request.
                format: date-time
                type: string
              message:
                description: A human readable message indicating details about why
                  the CycleNodeRequest is in this condition.
                type: string
              nodesAvailable:
                description: NodesAvailable stores the nodes still available to pick
                  up for cycling from the list of nodes to terminate
                items:
                  description: CycleNodeRequestNode stores a current node that is
                    being worked on
                  properties:
                    name:
                      description: Name of the node
                      type: string
                    nodeGroupName:
                      description: NodeGroupName stores current cloud provider node
                        group name which this node belongs to
                      type: string
                    providerId:
                      description: Cloud Provider ID of the node
                      type: string
                  required:
                  - name
                  - nodeGroupName
                  - providerId
                  type: object
                type: array
              nodesToTerminate:
                description: NodesToTerminate stores the old nodes that will be terminated.
                  The cycling of nodes is considered successful when all of these
                  nodes no longer exist in the cluster.
                items:
                  description: CycleNodeRequestNode stores a current node that is
                    being worked on
                  properties:
                    name:
                      description: Name of the node
                      type: string
                    nodeGroupName:
                      description: NodeGroupName stores current cloud provider node
                        group name which this node belongs to
                      type: string
                    providerId:
                      description: Cloud Provider ID of the node
                      type: string
                  required:
                  - name
                  - nodeGroupName
                  - providerId
                  type: object
                type: array
              numNodesCycled:
                description: NumNodesCycled counts how many nodes have finished being
                  cycled
                type: integer
              phase:
                description: Phase stores the current phase of the CycleNodeRequest
                type: string
              scaleUpStarted:
                description: ScaleUpStarted stores the time when the scale up started
                  This is used to track the time limit of the scale up. If we breach
                  the time limit we fail the request.
                format: date-time
                type: string
              selectedNodes:
                additionalProperties:
                  type: boolean
                description: SelectedNodes stores all selected nodes so that new nodes
                  which are selected are only posted in a notification once
                type: object
              threadTimestamp:
                description: ThreadTimestamp is the timestamp of the thread in the
                  messaging provider
                type: string
            required:
            - message
            - phase
            type: object
        type: object
    served: true
    storage: true
    subresources: {}
