Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes - What exactly is imperative Vs Declarative

Tags:

kubernetes

I am seeing multiple and different explanations for imperative Vs Declarative for Kubernetes - something like Imperative means when we use yaml files to create the resources to describe the state and declarative vice versa.

what is the real and clear difference between these two. I would really appreciate if you can put the group of commands fall under the same - like Create under imperative way etc ..

like image 370
Nag Avatar asked Feb 15 '20 18:02

Nag


1 Answers

"Imperative" is a command - like "create 42 widgets".

"Declarative" is a statement of the desired end result - like "I want 42 widgets to exist".

Typically, your yaml file will be declarative in nature: it will say that you want 42 widgets to exist. You'll give that to Kubernetes, and it will execute the steps necessary to end up with having 42 widgets.

"Create" is itself an imperative command, but what you're creating is a Kubernetes cluster. What the cluster should look like is determined by the declarations in the yaml file.

like image 115
user12904511 Avatar answered Sep 28 '22 05:09

user12904511