简体   繁体   中英

Why does Kubernetes use a yaml file per "resource"

I am looking for a (more or less scientific) document/presentation that explains why the developers of the "Kubernbetes language" made the choice to fragment an application definition (for instance) in multiple yaml files instead of writing a single yaml file with all the details of the application deployment (all deployments, volumes, ...)?

I imagine that this has something to do with reusability, maintainability and readability but it would be nice to have a more structured argumentation (I think of a conference paper or presentation in a conference such as kubcon or dockercon)

Thanks,

Abdelghani

First things first, Kube.netes does not have its own language, most used language is YAML, but you could work with JSON, or even XML if this were supported. YAML is more human readable and portable across several programming languages. Kube.netes is complex because we want to do complex things. It simply makes things more manageable if we split the deployment in several YAML files, as programmers use different files for different purposes. And, when a modification occurs you only kubectl apply a 'tiny' file. Why they actually chose YAML and separated files was influenced by Google's Borg system, which Kube.netes grabbed a lot of concepts from.

why the developers of the "Kubernbetes language" made the choice to fragment an application definition (for instance) in multiple yaml files instead of writing a single yaml file with all the details of the application deployment (all deployments, volumes, ...)?

This allows us to modify the configuration of Kube.netes objects easier. Thus, you do not have to go through the entire cluster configuration yaml file to make a small change in the service backend, for example. And yes, it is easier to develop and maintain a bunch of files, each containing some object or a group of related objects.

Keep in mind that you can call kubectl apply command on a directory of config files:

kubectl apply -f <directory>

Group related k8s objects into a single file whenever it makes sense . So, it is easier to manage.

But you definitely can put the entire cluster configuration in one yaml file using this syntax (note ---).

apiVersion: v1
kind: Service
metadata:
# skip

---
apiVersion: apps/v1
kind: Deployment
metadata:
# skip

Kube.netes developers suggest write your configuration files using YAML rather than JSON. Though these formats can be used interchangeably in almost all scenarios, YAML tends to be more user-friendly.

There is a good Kube.netes page on Configuration Best Practices .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM