Pods YAML Walkthrough

apiVersion:

  • This refers to the version of Kubernetes.
  • API version consists of two things group name and Version.
  • There are several versions, and several objects are introduced with each version.
  • Some common ones are v1, apps/v1, and extensions/v1beta1.
  • On the right-hand side, you can see the different types of values
  • You can check out the below command for the list of versions.
$ kubectl api-versions

Kind:

  • This is the type of Kubernetes object. In this case (the example above), we’re creating a pod.
  • You can see the other types of objects that we create commonly on the right side here.
  • You can check out the below command for the list of kinds.
$ kubectl api-resources | awk '{print $5}'

Metadata:

  • The metadata houses information that describes the object briefly.
  • The information in the metadata usually contains the name you want to give the object (pod in our case), the labels, and the annotation.
  • name the object is the only mandatory field and the remaining are optional.
  • You can check out the official Kubernetes documentation for the metadata field.

Spec:

  • The spec section is where we define containers that will run inside the pod.
  • For this example, we are deploying a single Nginx container with its latest image. Here we specify
  • The image of the application you want to run in your pods.
  • The name of the container that you’ll run in your pod.
  • ContainerPort is the port of your application in your container and the environment variable inside the containers.

Kind vs API Version

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store