One of the ways to extend Kubernetes is to write your own Custom Resource Definition (CRD). This allows you to extend the KRM with your own "types", like this:
-
Let's first look at the built-in KRM API resource "types", and note e.g. the Pod we used in the previous lesson:
k api-resources
-
Glance at, and then apply, the foo.crd.yaml:
k apply -f https://raw.githubusercontent.com/vorburger/LearningKubernetes-CodeLabs/develop/docs/files/foo.crd.yaml
-
This has created a new (custom) KRM API resource kind, named foo. It now appears on the API:
k api-resources | grep foo k explain foo k explain foo.spec
-
We can now create a new resource of this kind, e.g. by applying the hello.foo.yaml:
k apply -f https://raw.githubusercontent.com/vorburger/LearningKubernetes-CodeLabs/develop/docs/files/hello.foo.yaml
-
You now have a
Foo
. Let's list it, look at it's YAML:k get foos k get foo hello -o yaml
-
Try to edit it, and change "xyz" from "7" to "13", and not the validation error you'll get, xyz =< 10:
k edit foo hello
-
Clean up:
k delete foo hello