使用 CRD 扩展 Kubernetes API
创建 CRD(CustomResourceDefinition)
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# 名称必须符合下面的格式:<plural>.<group>
name: crontabs.stable.example.com
spec:
# REST API使用的组名称:/apis/<group>/<version>
group: stable.example.com
# REST API使用的版本号:/apis/<group>/<version>
versions:
- name: v1
# 可以通过 served 来开关每个 version
served: true
# 有且仅有一个 version 开启存储
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
cronSpec:
type: string
image:
type: string
replicas:
type: integer
# Namespaced或Cluster
scope: Namespaced
names:
# URL中使用的复数名称: /apis/<group>/<version>/<plural>
plural: crontabs
# CLI中使用的单数名称
singular: crontab
# CamelCased格式的单数类型。在清单文件中使用
kind: CronTab
# CLI中使用的资源简称
shortNames:
- ct创建自定义对象
删除 CustomResourceDefinition
高级主题
Finalizer(终结器)
Validation(验证)
其他打印列
Priority(优先级)
Type(类型)
Format(格式)
子资源
状态子资源
扩展子资源
Category(分类)
参考
最后更新于