Now that we have covered  the architecture and general concepts of Kubernetes, along with getting you set up with a Kind cluster, it is time to create a pod the hard way (with YAML files). As mentioned before, pods are groups of containers that run the container images. In these pods, a container image is required. These are obtained from the Docker Hub page.

Let’s get started with creating a pod in Kubernetes.


YAML Files

Before creating a pod, you need to understand the general idea behind YAML files. Usually, JSON files are used, but YAML is new, much more efficient, and easier to use.

One of the main concepts of YAML files is key-value pairs. In essence, a key (e.g. food) is assigned to a value (e.g. pasta). The two values are a key-value pair. They represent one another! Here are some examples of key-value pairs in YAML format:

Fruit: Apple
Vegetable: Carrot
Liquid: Water
City: Austin

As you can see, the format is key: value. One important thing to note is the space between the key and value. If there is no space after the :, the key-value pair will not be recognized. This is one of the main components of a YAML file.

The other component is an array/list. Based on the name, you can tell that the main purpose of this function is to list many different attributes of the YAML file, whether it be a key-value pair or a dictionary/map. Here is an example of an array/list in YAML format:

Cities:
-  Austin
-  Dallas
-  San Francisco
-  New York

Based on this example, you can see that there is a category followed by a :. After that, a list is created with dashes and the list values are written. You may notice that the spacing is the same with all of the values in the list. This is something that must be kept in mind when creating arrays/lists in YAML files.

#containers #kubernetes #programming #docker #k8s

YAML Files and Pods
1.40 GEEK