Ever wanted to know a field in your Kubernetes yaml definition, but found it ridiculously difficult to find out what it means or even how to use it 😥?
kubectl
is to the rescue!
To get started we can familiarise ourselves with what API resources we have available to use. To do this we can run kubectl api-resources
, looking at the output of this command we can start to paint a picture of what resources our cluster is composed of.
Let’s take the deployment resource as our first example. Interestingly we can see that multiple definitions exist for this resource, once for the API Group extensions
and one for apps
. We will find out why this is the case later on 🤯!
So how do we write a yaml definition for this deployment? It’s possible to get examples for the Kubernetes documentation — personally I always find this too difficult to navigate, instead, it is possible to interrogate the API server’s OpenAPI specification using kubectl.
The command in question is kubectl explain
, so let’s give this a whirl 😜!
This will show us all of the keys that are available to use at the top level.
If you really want to dive deep you can add a “recursive” parameter!
But I will omit the output so you can check it out yourself! (Hint: the output is longer than this post 😈)