Indispensable keywords in any Kubernetes Template!

This blog aims to explain all the important keywords that any Kubernetes Template needs to contain. Also, at the end of the article, one example template is also provided.

Harshit Dawar
3 min readOct 1, 2021

Kubernetes is been used as anything in the market & that’s the reason that Kubernetes is having such high demand in the market.

There is no one out there who is not impressed by the working of Kubernetes, it is simply brilliant to use Kubernetes in the Production Environment.

Since it is that widely used, that is why it's very important to create the templates for the workloads that are decided to be deployed using Kubernetes instead of using commands. A use-case can involve multiple things that are very difficult to deploy using commands as well as templating provides you complete customization freedom of which simple commands are not capable of.

Now, that being said, let’s proceed towards the discussion about the keywords that are required in any template file.

Pre-requisites for this article

In order to completely understand this article, it is expected that the reader has a basic knowledge of Kubernetes & its objects.

Indispensible Keywords of any Kubernetes Template!

There are 4 keywords that should be present in any Kubernetes Template & are as follows(remember, they are case sensitive):

  1. kind
  2. apiVersion
  3. metadata
  4. spec

Detailed Discussion on each keyword is present below!

kind

This keyword specifies which kind of application to create, either it is pod, service, deployment, replica set, replication controller, or anything else.

This is the most straightforward keyword of the template & very easy to mention.

Some of the values that this variable can take are:

  1. Pod
  2. Service
  3. Deployment
  4. RepliactionController
  5. ReplicaSet, etc.

apiVersion

This keyword signifies which API version a Kubernetes Template should use, there are multiple different types of applications/Kubernetes objects for which different API versions are used.

For example, if kind is pod or service, then apiVersion is “v1”, or when kind is assigned to “ReplicaSet” or “Deployment”, then apiVersion is “apps/v1”

metadata

This keyword is used to specify the extra data for the kind. Metadata is used to associate attributes to the kind.

For example, one can set the name of the kind using metadata as well as it can provide labels to the kind that helps a lot in bigger workloads to find the things.

spec

This keyword is actually responsible for the configuration or specification of the kind.

For example, if the kind is a POD, then the image name & name of the POD will be configured using the spec keyword. Similarly, for the other services, spec sets different attributes that are required for that kind.

An example Kubernetes Template to launch the webserver using my own custom image for containers is as follows:

Code by Author!

I hope my article explains each and everything related to the topic with all the detailed concepts and explanations. Thank you so much for investing your time in reading my blog & boosting your knowledge. If you like my work, then I request you to applaud this blog & follow me on Medium, GitHub, & LinkedIn for the more amazing content on multiple technologies and their integration!

Also, subscribe to me on Medium to get the update of all my blogs!

--

--

Harshit Dawar

AIOPS Engineer, have a demonstrated history of delivering large and complex projects. 14x Globally Certified. Rare & authentic content publisher.