Jsonnet is actually a data templating language from google.It is an extension of JSON so every Jsonnet is itself a valid Json.
In terms of where it is used , it can be used in deployment configuration, configuration management, package definition etc.

    // Jsonnet example
    person1: {
        name: "Test",
        welcome: "Hello " + self.name + "!",
    person2: self.person1 { name: "Test2" },

Jsonnet has some advantages over Json like (also seen above):

  • Jsonnet has the feature of adding comments which increases its readability.
  • One part of the structure can call other part using self and super keywords.
  • We can use function ,variables ,imports ,arrays which greatly increases the flexibility.

If we convert it to Json using Json convertor then we get:

   "person1": {
      "name": "Test",
      "welcome": "Hello Test!"
   "person2": {
      "name": "Test2",
      "welcome": "Hello Test2!"

Usage in kubernetes:

Kubernetes uses YAML file configuration to update the objects in kubernetes.One can often change the YAML file configuration and then perform kubectl apply -f name.yml to update the changes to kubernetes.
But when the environment is very big like in big company then it becomes difficult because common sharing of YAML file is not easy.

Default.jsonnet : We will have some default global variables that apply to all the environment and application.

config.libsonnet : This is main kubernetes deployment file which will have all properties of kubernetes.Some of the property are :

  • Config properties such as Port numbers , docker image version ,timeout value etc.
  • Resource properties such as memory requirements , cpu requirements etc..

There will be some other jsonnet files according to the requirements.After all the jsonnet files are created we can compile them and it will generate YAML/JSON file according to the specified formats.

I have used a tool called jman which is in python to convert them into YAML files.
But alternatively we can use jsonnet command too.

More info on Jsonnet: