Extend the Kubernetes API with CustomResourceDefinitions

최종 목표 : HPA에 RL 적용시키기

우선 HpaRl이라는 CRD를 제작하는 것을 목표로 한다.

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name은 spec 필드와 맞춰줘야 함: <plural>.<group>
  name: hparls.kopf.dev
spec:
  scope: Namespaced # Namespaced 또는 Cluster
  # group name은 REST API를 위해 사용됨: /apis/<group>/<version>
  group: kopf.dev
  names:
    kind: HpaRl # CamelCased 형태로
    plural: hparls # URL: /apis/<group>/<version>/<plural>
    singular: hparl # CLI
    shortNames:
      - hrl
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                scaleTargetRef:
                  type: object
                  properties:
                    apiVersion:
                      type: string
                    kind:
                      type: string
                    name:
                      type: string
                minReplicas:
                  type: integer
                  minimum: 1
                maxReplicas:
                  type: integer
            status:
              type: object
              properties:
                lastScaleTime:
                  type: string
                currentReplicas:
                  type: integer
                desiredReplicas:
                  type: integer
      additionalPrinterColumns:
      - name: Reference
        type: string
        description: The reference deployment
        priority: 0
        jsonPath: .spec.scaleTargetRef.name
      - name: Replicas
        type: integer
        description: Number of current replicas
        priority: 0
        jsonPath: .status.currentReplicas
      - name: Desired
        type: integer
        description: Number of desired replicas
        priority: 0
        jsonPath: .status.desiredReplicas
      - name: Minimum
        type: integer
        description: Number of minimum replicas
        priority: 0
        jsonPath: .spec.minReplicas
      - name: Maximum
        type: integer
        description: Number of maximum replicas
        priority: 0
        jsonPath: .spec.maxReplicas
      - name: Age
        type: date
        priority: 0
        jsonPath: .metadata.creationTimestamp

Additional printer columns

0으로 설정하면 get을 입력했을 때, 바로 해당 column이 보임

0보다 큰 값으로 설정하면 "-o wide" 플래그를 입력해야 보임

integer : non-floating-point numbers

number : floating point numbers

string

boolean

date

위의 다섯 가지의 타입이 있음