@@ -3,11 +3,63 @@ kind: CustomResourceDefinition
33metadata :
44 name : todos.patrickdap.com
55spec :
6+ # Whether the resource is Namespaced or Cluster-wide
7+ scope : Namespaced
8+
9+ # Define all the names used by the resource, in this case
10+ # you can do:
11+ # kubectl get todos
12+ # kubectl get td
13+ names :
14+ plural : todos
15+ singular : todo
16+ kind : Todo
17+ shortNames :
18+ - td
19+
20+ # Once the resource is part of Kubernetes, it also needs a group
21+ # so then you could have foo.example.com register the concept of "Node"
22+ # as well as v1/Node (the default Kubernetes one)
623 group : patrickdap.com
24+
25+ # There's multiple versions for a Kubernetes resource, and it's common
26+ # to find "v1beta1", "v1beta2", "v1" and so on
727 versions :
8- - name : v1
28+ -
29+ # Versions are string-based and they're prioritized based on the
30+ # Kubernetes version sorting algorithm. Those versions that match
31+ # the Kubernetes sorting are "higher versions" than those who don't.
32+ # See: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#version-priority
33+ name : v1
34+
35+ # The next two fields control the behaviour of the resource in Kubernetes.
36+ # If a resource is marked as "served", it means users can perform CRUD
37+ # operations in resources under this version, "v1" in our case, and have
38+ # them work as you would normally do.
39+ # On multiple versions, only one can be marked as "storage". This means
40+ # that the version marked as storage will be used to "store" it in etcd.
41+ # However, there's a few caveats. For example, resources created on an
42+ # older version which, back then, it was marked as "storage" will be kept
43+ # stored as their old version, and they *will not be converted* to newer
44+ # versions.
45+ # You can use a conversion webhook to "migrate" resources to newer versions
46+ # (see below for more details) or, if you manually edit the resource, you
47+ # will be able to upgrade it as well.
948 served : true
1049 storage : true
50+ deprecated : false
51+
52+ # The OpenAPI Schema used to create the resource. There's hundreds of
53+ # options here, like specifying default values, provide definitions,
54+ # define fields that depend on each other, provide descriptions for
55+ # documentation (such as "kubectl explain ..."), configure the value to
56+ # be an enum, provide a basic format validator that supports, among other
57+ # things fields like bson object IDs, uuids, isbn, credit card numbers,
58+ # US SSN, hexadecimal, rgb, byte data, passwords, dates, durations; or
59+ # you can even create sub-objects in an object, allow for patterns,
60+ # validate minimum and maximum length, whether it's nullable or required,
61+ # a title (used when printing), if the fields are unique, and a plethora
62+ # of other options.
1163 schema :
1264 openAPIV3Schema :
1365 type : object
@@ -23,10 +75,37 @@ spec:
2375 properties :
2476 name :
2577 type : string
26- scope : Namespaced
27- names :
28- plural : todos
29- singular : todo
30- kind : Todo
31- shortNames :
32- - td
78+ done :
79+ type : boolean
80+ default : false
81+
82+ # When printing fields using "kubectl get foo", only the name and the age,
83+ # that is, the time since its creation, will be printed to screen. This
84+ # setting allows the creation of multiple new columns for your CRD which
85+ # will then be outputted automatically. This must match the current
86+ # top-of-the-line version for your CRD.
87+ additionalPrinterColumns :
88+ - name : Action
89+ type : string
90+ description : Indicates the action to be done
91+ jsonPath : .spec.name
92+ - name : Done
93+ type : boolean
94+ description : Indicate whether the action described by this TODO was done
95+ jsonPath : .spec.done
96+ - name : Age
97+ type : date
98+ jsonPath : .metadata.creationTimestamp
99+
100+ # Different versions might require "changes" to move values between one
101+ # version declaration to another. For example, in v1beta1, the field "foo"
102+ # could've been in spec.fields.foo, but in v1 it could've been promoted
103+ # to spec.foo (skipping "fields"). This conversion is not automated and,
104+ # by default, Kubernetes will set the conversion strategy to None.
105+ # Like Admission Controllers, it's possible to create a "webhook conversion"
106+ # which registers an endpoint in the cluster -- this can be either an
107+ # actual endpoint or a Kubernetes Service. The webhook must return a
108+ # Kubernetes "ConversionReview" response.
109+ # See: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#webhook-request-and-response
110+ conversion :
111+ strategy : None
0 commit comments