cancel
Showing results for 
Search instead for 
Did you mean: 
  • 12K Views

How to learn configuration YAML files

I have been learning Kubernetes intermittently for over a year now.

The hardest part for me is the YAML configurations. Usually, a configuration file contains an apiVersion, kind, metadata, and spec. And then spec contains template, which contains spec again. And this is not always the same. Formats differ for each different kind. I have to memorize a lot of things, and I have to check every time against a reference.

What is the best way to learn Kubernetes configurations? Do we have to grab configuration files and apply them every time instead of writing them? Is this the recommended way?

This question is part of the 100K Member Contest - don't forget to kudo the original contest post to be entered. 

Labels (2)
Tags (2)
32 Replies
wengkee
Mission Specialist
Mission Specialist
  • 2,840 Views

Based on my experience, you don't have to memorize each and every single YAML lines. There are a few objects that you can actually generate them using imperative way. For example `kubectl run` would create a pod for you, but you would be able to get the YAML of it if you decide to do so, by adding `-o yaml`. 

This is actually similar to what we did when we start to learn a programming language, we don't really memorize the syntax, we start by understanding the concept and design, then practice, then slowly internalize it.

Take your time, no one will penalize you if you have to refer to Kubernetes page every now and then - in fact, even the real expert will still need to do so. Most importantly, have fun!

 

 

0 Kudos
Sandeep555
Mission Specialist
Mission Specialist
  • 2,893 Views

Practise, Practise - participate and contribute to the open-source world

0 Kudos
RathanA
Mission Specialist
Mission Specialist
  • 2,883 Views

May be simple but it was the most robust then...working on puppet helped me work on the yaml.

0 Kudos
saiprasad
Cadet
Cadet
  • 2,876 Views

The way i learned writing yaml files is by understanding the hierarchy of the objects ex: name is a sub-object of metadata. Another handy technique is using oc/kubectl explain command 

AJ01
Mission Specialist
Mission Specialist
  • 2,866 Views

I am a beginner, will have to study it first and will let you know

0 Kudos
Trevor
Starfighter Starfighter
Starfighter
  • 2,848 Views

Your question:  What is the best way to learn Kubernetes configurations?  

My answer:  By doing, doing, and doing some more!!!

Trevor "Red Hat Evangelist" Chandler
0 Kudos
robbz_chazz
Mission Specialist
Mission Specialist
  • 2,834 Views

Understand the basic structure and the components "keywords to use in yaml files", Kube-by-example offers awesome resource on the different flavors of yaml files one might encounter in a Kubernetes env or learn ansible yaml basics. 

0 Kudos
tonejito
Mission Specialist
Mission Specialist
  • 2,822 Views

From my point of view, there is no need to learn to type the configuration files by hand.

You can either create resources via the “imperative” approach, that is use commands to create the resources (eg. kubectl create deployment --image …), or use the “declarative” approach to create a file using a YAML manifest file (kubectl apply -f manifest.yaml).

You can inspect what YAML is generated with the “imperative” commands by doing a dry-run like this:

$ kubectl create deployment --image nginx:alpine --dry-run=client -o yaml > deployment.yaml

Often you want for kubectl to create all the YAML boilerplate and then configure the resource according to your needs (add labels, annotations, etc.).

I recommend you to learn the things you can do with the kubectl tool like patching or custom columns, as well as JSONPath. That will give you a great understanding on the resources and their fields instead of just learning the YAML syntax alone.

References

Managing Kubernetes Objects Using Imperative Commands
- https://kubernetes.io/docs/tasks/manage-kubernetes-objects/imperative-command/

Declarative Management of Kubernetes Objects Using Configuration Files
- https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/

kubectl cheat sheet
- https://kubernetes.io/docs/reference/kubectl/cheatsheet/

JSONPath Support
- https://kubernetes.io/docs/reference/kubectl/jsonpath/

 

0 Kudos
Beauvalon
Mission Specialist
Mission Specialist
  • 2,800 Views

I'm a novice at yaml, so I have to keep at it and keep learning especially from others.  A smart person is one that is surrounded by smarter people! 

0 Kudos
M4rc10
Mission Specialist
Mission Specialist
  • 2,800 Views

The big question is not to decorate, but to interpret what you want. And the community helps a lot. Thank you all for your support and opinions.

0 Kudos
Join the discussion
You must log in to join this conversation.