Kubernetes yaml Overview

Enzo Erbert
1 min readDec 29, 2021

In this article I will be covering mainly how to create and manage yml file for k8s.

We use the yaml file to create kubernetes resources like pods, deployments and services.

At First we need to pay attention to the “kind” key, it is responsible to specify which element you’re going to create or edit.

When talking about kinds we can have things like:

Pods, Secrets, Service, Deployment and other resources

important fields are:

Examples

now, let’s take a look at some examples

Example 1

the first one was taken from kubernetes docs :

here you can see a yaml that will specify a creation of a Deployment, using the apiVersion “apps/v1”.

You can also see that a name and app label are specified in it’s metadata, in the spec the yaml asks for 3 of those to be created in “replicas”, matching the app label “nginx” and then specifying the name, image and port of the container that we want to create.

Example 2

the second one was taken from kubernetes docs:

here you can see that we are creating a Service, using the apiVersion “v1”, it will be called “my-service”.

Then the selector identifying “MyApp”, end we are running the service as TCP using the port 80 and targeting the port 9376, we’re’ also specifying the clusterIP and that the service will actually be a load balancer.

--

--