crd yaml编写

yaml主要有三种类型的数据原语:Maps,Lists,Scales(按照官方法表达:“mappings (hashes/dictionaries), sequences (arrays/lists) and scalars (strings/numbers)”),基于这三种数据原语可以组合出任何数据结构。

  • 破折号和空格( “-” ):Lists集合
  • 冒号和空格( “:” ) :Maps键值对
  • 井号( “#” ):注释

API返回的所有JSON对象必须具有以下字段:

  • apiVersion:标识对象应具有的架构版本的字符串
  • kind:标识此对象应具有的架构的字符串
  • metadata:元数据
    • name:在当前命名空间中唯一标识此字符,在全部空间中使用该路径寻找该字符   命名规范为:复数名 + 组名
    • resourceVersion:用于标识此对象的内部版本,客户端可使用该字符串确定对象何时发生更改。客户端必须将此值视为不透明的,并将其原封不动地传递回服务器。客户端不应假定资源版本在名称空间、不同类型的资源或不同的服务器之间具有意义。
    • generation:表示所需状态的特定生成的序列号。
    • creationTimestamp:表示对象创建日期和时间的RFC 3339日期的字符串
    • deletionTimestamp:表示RFC 3339日期的字符串,在该日期和时间之后将删除此资源。此字段由服务器在用户请求删除时设置,客户端不能直接设置。
    • labels:字符串键和值的映射,可用于组织和分类对象。
    • annotations:字符串键和值的映射,可由外部工具用于存储和检索有关此对象的任意元数据
  • spec:数据属性定义
    • group:组名
    • names:
      • categories:类别
      • kind:类名
      • listKind:字符串类名
      • plural:复数名
      • singular:单数名
    • scope:指定crd资源作用范围在命名空间或集群
    • versions:
      • -additionalPrintercolumns:附加打印项
        •  -jsonPath: .打印json项目中的哪一项(对应列)
        •   name:列名
        •   类型
    • name: ????
    • schmea:

apiVersion: apiextensions.k8s.io/v1   
   # 定义了对象表示的版本化架构。
kind: CustomResourceDefinition
   # 表示该对象所代表的 REST 资源 ,后续可以直接创建这个类型的资源 相当于类名?
   # 标识此对象应具有的架构的字符串
metadata:
  # 标准对象的元数据
  # name must match the spec fields below, and be in the form:
  # <plural>.<group>  由 复数名.分组名组成
  # 在当前命名空间中唯一标识此对象的字符串。检索单个对象时在路径中使用此值。
  name: crontabs.stable.example.com
  uid:时间和空间上的唯一值(通常是 RFC 4122 生成的标识符,请参阅标识符文档),用于区分已删除和重新创建的同名对象
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值