Skip to content

Commit 0082e95

Browse files
📖 add info to tutorial about apis with examples
1 parent 948887a commit 0082e95

File tree

1 file changed

+21
-0
lines changed
  • docs/book/src/cronjob-tutorial

1 file changed

+21
-0
lines changed

docs/book/src/cronjob-tutorial/gvks.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ a package.
4646
Now that we have our terminology straight, we can *actually* create our
4747
API!
4848

49+
## So, how can we create our API?
50+
51+
In the next section, [Adding a new API](./cronjob-tutorial/new-api.html) we will check how the tool help us to create our own API's with the command `kubebuilder create api`.
52+
53+
The goal of this command is to create Custom Resource (CR) and Custom Resource Definition (CRD) for our Kind(s). To check it further see; [Extend the Kubernetes API with CustomResourceDefinitions][kubernetes-extend-api].
54+
55+
## But, why create APIs at all?
56+
57+
New APIs are how we teach Kubernetes about our custom objects. The Go structs are used to generate a Custom Resource Definition (CRD) which includes the schema for our data as well as tracking data like what our new type is called. We can then create instances of our custom objects which will be managed by our [controllers][controllers].
58+
59+
Our APIs and resouces represent our solutions on the clusters. Basically, the CRDs are a definition of our customized Objects, and the CRs are an instance of it.
60+
61+
## Ah, do you have an example?
62+
63+
Let’s think about the classic scenario where the goal is to have an application and its database running on the platform with Kubernetes. Then, one CRD could represent the App, and another one could represent the DB. By having one CRD to describe the App and another one for the DB, we will not be hurting concepts such as encapsulation, the single responsibility principle, and cohesion. Damaging these concepts could cause unexpected side effects, such as difficulty in extending, reuse, or maintenance, just to mention a few.
64+
65+
In this way, we can create the App CRD which will have its controller and which would be responsible for things like creating Deployments that contain the App and creating Services to access it and etc. Similarly, we could create a CRD to represent the DB, and deploy a controller that would manage DB instances.
66+
4967
## Err, but what's that Scheme thing?
5068

5169
The `Scheme` we saw before is simply a way to keep track of what Go type
@@ -70,3 +88,6 @@ API server that says
7088

7189
or properly look up the group-version when we go to submit a `&CronJob{}`
7290
in an update.
91+
92+
[kubernetes-extend-api]: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/
93+
[controllers]: ../cronjob-tutorial/controller-overview.md

0 commit comments

Comments
 (0)