https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#customresourcedefinitions


ThirdPartyResource 가 1.8부터 custom resource definition으로 대체되었다.


관련 예시이다.


 


$ vi crd.yaml

apiVersion: apiextensions.k8s.io/v1beta1

kind: CustomResourceDefinition

metadata:

  name: crontabs.training.lfs458.com

    # This name must match names below.

    # <plural>.<group> syntax

spec:

  scope: Cluster #Could also be Namespaced

  group: training.lfs458.com

  version: v1

  names:

    kind: CronTab #Typically CamelCased for resource manifest

    plural: crontabs #Shown in URL

    singular: crontab #Short name for CLI alias

    shortNames:

    - ct #CLI short name




$ kubectl create -f crd.yaml



$  kubectl get crd

NAME                           AGE

crontabs.training.lfs458.com   4m



$ kubectl describe crd crontab

Name:         crontabs.training.lfs458.com

Namespace:

Labels:       <none>

Annotations:  <none>

API Version:  apiextensions.k8s.io/v1beta1

Kind:         CustomResourceDefinition

Metadata:

  Creation Timestamp:  2018-12-18T05:49:45Z

  Generation:          1

  Resource Version:    3992526

  Self Link:           /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/crontabs.training.lfs458.com

  UID:                 b92d0073-0288-11e9-9a46-fa163e964181

Spec:

  Group:  training.lfs458.com

  Names:

    Kind:       CronTab

    List Kind:  CronTabList

    Plural:     crontabs

    Short Names:

      ct

    Singular:  crontab

  Scope:       Cluster

  Version:     v1

Status:

  Accepted Names:

    Kind:       CronTab

    List Kind:  CronTabList

    Plural:     crontabs

    Short Names:

      ct

    Singular:  crontab

  Conditions:

    Last Transition Time:  2018-12-18T10:49:45Z

    Message:               no conflicts found

    Reason:                NoConflicts

    Status:                True

    Type:                  NamesAccepted

    Last Transition Time:  2018-12-18T10:49:45Z

    Message:               the initial names have been accepted

    Reason:                InitialNamesAccepted

    Status:                True

    Type:                  Established

Events:                    <none>


$ vi  new-crontab.yaml

apiVersion: "training.lfs458.com/v1"

  # This is from the group and version of new CRD

kind: CronTab

  # The kind from the new CRD

metadata:

  name: new-cron-object

spec:

  cronSpec: "*/5 * * * *"

  image: some-cron-image

    #Does not exist



$ kubectl create -f new-crontab.yaml



$ kubectl get CronTab

NAME              AGE

new-cron-object   4m


$ kubectl get ct

NAME              AGE

new-cron-object   4m


$ kubectl describe ct


Name:         new-cron-object

Namespace:

Labels:       <none>

Annotations:  <none>

API Version:  training.lfs458.com/v1

Kind:         CronTab

Metadata:

  Cluster Name:

  Creation Timestamp:  2018-12-18T10:52:21Z

  Resource Version:    3992891

  Self Link:           /apis/training.lfs458.com/v1/new-cron-object

  UID:                 16295359-0289-11e9-9a46-fa163e964181

Spec:

  Cron Spec:  */5 * * * *

  Image:      some-cron-image

Events:       <none>



$ kubectl delete -f crd.yaml

$ kubectl get CronTab
No resources found.

$ kubectl get ct

No resources found.


Posted by 김용환 '김용환'

댓글을 달아 주세요