You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# crd.yaml# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1apiVersion: apiextensions.k8s.io/v1beta1kind: CustomResourceDefinitionmetadata:
# 用于定义 CRD 的名字, 名称必须与下面的 spec 字段匹配:<spec.names.plural>.<spec.group>name: dagnoderunners.enigma.basebit.mespec:
group: enigma.basebit.menames:
# CamelCased 格式的单数类型kind: DagNodeRunnerlistKind: DagNodeRunnerListplural: dagnoderunnerssingular: dagnoderunnershortNames:
- dnrversion: v1versions:
- name: v1served: truestorage: true# CRD 可以是命名空间的,也可以是集群范围的,通过 scope 来指定scope: Namespaced# openAPIV3Schema is the schema for validating custom objectsvalidation:
openAPIV3Schema:
description: DagNodeRunner is the Schema for the dagnoderunners APItype: objectproperties:
required: ["spec"]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/api-conventions.md#resources'type: stringkind:
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/api-conventions.md#types-kinds'type: stringmetadata:
type: objectspec:
description: DagNodeRunnerSpec defines the desired state of DagNodeRunnertype: objectrequired: [foo]properties:
foo: {type: string, minimum: 1}barz: {type: boolean}status:
description: DagNodeRunnerStatus defines the observed state of DagNodeRunnertype: object
创建成功后,可访问 API endpoint: /apis/enigma.basebit.me/v1
➜ curl -k https://xx.xx.xx.xx:6443/apis/enigma.basebit.me/v1 |jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 473 100 473 0 0 2620 0 --:--:-- --:--:-- --:--:-- 2627
{
"kind": "APIResourceList",
"apiVersion": "v1",
"groupVersion": "enigma.basebit.me/v1",
"resources": [
{
"name": "dagnoderunners",
"singularName": "dagnoderunner",
"namespaced": true,
"kind": "DagNodeRunner",
"verbs": [
"delete",
"deletecollection",
"get",
"list",
"patch",
"create",
"update",
"watch"
],
"shortNames": [
"dnr"
]
}
]
}
Create a CR
使用 CRD 中定义的类型,创建一个自定义 DagNodeRunner 实例(CR)
# DagNodeRunner-kind.yamlapiVersion: enigma.basebit.me/v1kind: DagNodeRunnermetadata:
name: dagnoderunner-samplespec:
foo: bar
View CRD
# 查看集群内的 CRD 资源
➜ kubectl get crd
NAME CREATED AT
dagnoderunners.enigma.basebit.me 2019-10-03T08:22:05Z
meshpolicies.authentication.istio.io 2019-02-19T16:37:28Z
policies.authentication.istio.io 2019-02-19T16:37:28Z
# 查看创建的 DagNodeRunner 资源
➜ kubectl get dnr
NAME AGE
dagnoderunner-sample 2m
Notes
一个 API 对象在 Etcd 里的完整资源路径,是由:Group(API 组)、Version(API 版本)和 Resource(API 资源类型)三个部分组成。
Overview
Create a CRD
以下是一个 CRD 样例
关于自定义验证对象
创建成功后,可访问 API endpoint: /apis/enigma.basebit.me/v1
Create a CR
使用 CRD 中定义的类型,创建一个自定义 DagNodeRunner 实例(CR)
View CRD
# 查看集群内的 CRD 资源 ➜ kubectl get crd NAME CREATED AT dagnoderunners.enigma.basebit.me 2019-10-03T08:22:05Z meshpolicies.authentication.istio.io 2019-02-19T16:37:28Z policies.authentication.istio.io 2019-02-19T16:37:28Z
# 查看创建的 DagNodeRunner 资源 ➜ kubectl get dnr NAME AGE dagnoderunner-sample 2m
Notes
References
The text was updated successfully, but these errors were encountered: