# Copyright Contributors to the Open Cluster Management project

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: managedclusteraddons.addon.open-cluster-management.io
spec:
  group: addon.open-cluster-management.io
  names:
    kind: ManagedClusterAddOn
    listKind: ManagedClusterAddOnList
    plural: managedclusteraddons
    singular: managedclusteraddon
  scope: Namespaced
  preserveUnknownFields: false
  versions:
  - additionalPrinterColumns:
    - jsonPath: .status.conditions[?(@.type=="Available")].status
      name: Available
      type: string
    - jsonPath: .status.conditions[?(@.type=="Degraded")].status
      name: Degraded
      type: string
    - jsonPath: .status.conditions[?(@.type=="Progressing")].status
      name: Progressing
      type: string
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: ManagedClusterAddOn is the Custom Resource object which holds
          the current state of an add-on. This object is used by add-on operators
          to convey their state. This resource should be created in the ManagedCluster
          namespace.
        type: object
        required:
        - spec
        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: spec holds configuration that could apply to any operator.
            type: object
            properties:
              installNamespace:
                description: installNamespace is the namespace on the managed cluster
                  to install the addon agent. If it is not set, open-cluster-management-agent-addon
                  namespace is used to install the addon agent.
                type: string
                maxLength: 63
                pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
          status:
            description: status holds the information about the state of an operator.  It
              is consistent with status information across the Kubernetes ecosystem.
            type: object
            properties:
              addOnConfiguration:
                description: addOnConfiguration is a reference to configuration information
                  for the add-on. This resource is use to locate the configuration
                  resource for the add-on.
                type: object
                properties:
                  crName:
                    description: crName is the name of the CR used to configure instances
                      of the managed add-on. This field should be configured if add-on
                      CR have a consistent name across the all of the ManagedCluster
                      instaces.
                    type: string
                  crdName:
                    description: crdName is the name of the CRD used to configure
                      instances of the managed add-on. This field should be configured
                      if the add-on have a CRD that controls the configuration of
                      the add-on.
                    type: string
              addOnMeta:
                description: addOnMeta is a reference to the metadata information
                  for the add-on. This should be same as the addOnMeta for the corresponding
                  ClusterManagementAddOn resource.
                type: object
                properties:
                  description:
                    description: description represents the detailed description of
                      the add-on.
                    type: string
                  displayName:
                    description: displayName represents the name of add-on that will
                      be displayed.
                    type: string
              conditions:
                description: conditions describe the state of the managed and monitored
                  components for the operator.
                type: array
                items:
                  description: "Condition contains details for one aspect of the current
                    state of this API Resource. --- This struct is intended for direct
                    use as an array at the field path .status.conditions.  For example,
                    type FooStatus struct{     // Represents the observations of a
                    foo's current state.     // Known .status.conditions.type are:
                    \"Available\", \"Progressing\", and \"Degraded\"     // +patchMergeKey=type
                    \    // +patchStrategy=merge     // +listType=map     // +listMapKey=type
                    \    Conditions []metav1.Condition `json:\"conditions,omitempty\"
                    patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
                    \n     // other fields }"
                  type: object
                  required:
                  - lastTransitionTime
                  - message
                  - reason
                  - status
                  - type
                  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.
                      type: string
                      format: date-time
                    message:
                      description: message is a human readable message indicating
                        details about the transition. This may be an empty string.
                      type: string
                      maxLength: 32768
                    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.
                      type: integer
                      format: int64
                      minimum: 0
                    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.
                      type: string
                      maxLength: 1024
                      minLength: 1
                      pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
                    status:
                      description: status of the condition, one of True, False, Unknown.
                      type: string
                      enum:
                      - "True"
                      - "False"
                      - Unknown
                    type:
                      description: type of condition in CamelCase or in foo.example.com/CamelCase.
                        --- Many .condition.type values are consistent across resources
                        like Available, but because arbitrary conditions can be useful
                        (see .node.status.conditions), the ability to deconflict is
                        important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
                      type: string
                      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])$
              registrations:
                description: registrations is the conifigurations for the addon agent
                  to register to hub. It should be set by each addon controller on
                  hub to define how the addon agent on managedcluster is registered.
                  With the registration defined, The addon agent can access to kube
                  apiserver with kube style API or other endpoints on hub cluster
                  with client certificate authentication. A csr will be created per
                  registration configuration. If more than one registrationConfig
                  is defined, a csr will be created for each registration configuration.
                  It is not allowed that multiple registrationConfigs have the same
                  signer name. After the csr is approved on the hub cluster, the klusterlet
                  agent will create a secret in the installNamespace for the registrationConfig.
                  If the signerName is "kubernetes.io/kube-apiserver-client", the
                  secret name will be "{addon name}-hub-kubeconfig" whose contents
                  includes key/cert and kubeconfig. Otherwise, the secret name will
                  be "{addon name}-{signer name}-client-cert" whose contents includes
                  key/cert.
                type: array
                items:
                  description: RegistrationConfig defines the configuration of the
                    addon agent to register to hub. The Klusterlet agent will create
                    a csr for the addon agent with the registrationConfig.
                  type: object
                  properties:
                    signerName:
                      description: signerName is the name of signer that addon agent
                        will use to create csr.
                      type: string
                      maxLength: 571
                      minLength: 5
                    subject:
                      description: "subject is the user subject of the addon agent
                        to be registered to the hub. If it is not set, the addon agent
                        will have the default subject \"subject\": { \t\"user\": \"system:open-cluster-management:addon:{addonName}:{clusterName}:{agentName}\",
                        \t\"groups: [\"system:open-cluster-management:addon\", \"system:open-cluster-management:addon:{addonName}\",
                        \"system:authenticated\"] }"
                      type: object
                      properties:
                        groups:
                          description: groups is the user group of the addon agent.
                          type: array
                          items:
                            type: string
                        organizationUnit:
                          description: organizationUnit is the ou of the addon agent
                          type: array
                          items:
                            type: string
                        user:
                          description: user is the user name of the addon agent.
                          type: string
              relatedObjects:
                description: 'relatedObjects is a list of objects that are "interesting"
                  or related to this operator. Common uses are: 1. the detailed resource
                  driving the operator 2. operator namespaces 3. operand namespaces
                  4. related ClusterManagementAddon resource'
                type: array
                items:
                  description: ObjectReference contains enough information to let
                    you inspect or modify the referred object.
                  type: object
                  required:
                  - group
                  - name
                  - resource
                  properties:
                    group:
                      description: group of the referent.
                      type: string
                    name:
                      description: name of the referent.
                      type: string
                    resource:
                      description: resource of the referent.
                      type: string
    served: true
    storage: true
    subresources:
      status: {}
status:
  acceptedNames:
    kind: ""
    plural: ""
  conditions: []
  storedVersions: []
