Create A Custom Kubernetes Manifest Template Using Monokle

Create A Custom Kubernetes Manifest Template Using Monokle

·

4 min read

What is Kubernetes?

Kubernetes, also known as K8s, is an open-source container orchestration system for automating software deployment, scaling, and management.

What is Monokle ?

Monokle is an open-source tool by Kubeshop. It is MIT licensed. It’s a tool to inspect our Kubernetes manifests. Nowadays when we work with K8s, managing very long YAML files becomes a tough job as we get different issues. Monokle helps us to debug, manage and validate the changes before deploying them into the cluster. It also helps us to create our own manifest template. Some of the features of Monokle are:

  • Quickly get a high-level view of your manifests and their contained resources
  • Easily edit resources without having to learn or look up YAML syntax
  • Visualize and navigate resources in your clusters
  • Create a Resource from a Template
  • Manage multiple projects

Installation of Monokle is quite easy. Go through the following document to install.

How does Monokle fit in with existing tooling:

image.png

What is a Plugin?

Simply, any GitHub repository that contains a package.json file (the plugin entry file) can be installed as a plugin if the entry file follows the structure of a Monokle plugin.

What are Kubernetes Resources?

A resource is an endpoint in the Kubernetes API that stores a collection of API objects of a certain kind; for example, the built-in pods resource contains a collection of Pod objects.

What is Pod?

Pods are the smallest, most basic deployable objects in Kubernetes. A Pod represents a single instance of a running process in your cluster. Pods contain one or more containers, such as Docker containers. When a Pod runs multiple containers, the containers are managed as a single entity and share the Pod’s resources.

What is Deployment?

A Kubernetes deployment is a resource object in Kubernetes that provides declarative updates to applications. A deployment allows you to describe an application’s life cycle, such as which images to use for the app, the number of pods there should be, and the way in which they should be updated.

Let's begin with the monokle app:

image.png

First , Let’s choose the default template of Monokole

  1. Click on Start from a template

image.png

  1. Type the Project Name(whatever you want) and Location(where you want to save the file), usually in desktop directory

image.png

  1. Now select a template. Here I am using “Basic Pod” template. Click on use Template.

image.png

image.png

  1. Enter Pod name , image and Namespace(optional). Then click on Submit.

image.png

  1. So, you can see our pod resource is successfully created.

image.png

  1. Click on Done. You can find the YAML manifest file as shown below

image.png

Its so quick we have created the manifest file for pod without writing YAML file by it’s own and without worrying about it’s syntax.

Let's start creating our own YAML Manifest Template

  1. Creating the Plugin Entry File - create package.json file:

image.png

  1. Creating the template - create a folder named deployment-template and add the following file:

a. Create monokle-template.json file:

image.png

b. Create form-schema.json file:

image.png

c. Create form-ui-schema.json file:

image.png

d. Create template.yaml file:

image.png

  1. Push All the code to GitHub

Checkout the code on my GitHub repo:

github.com/jenstancs/monokle-templates-plugin

  1. Now install the Plugin, click on Open Plugins manager from the top right icon.

image.png

  1. Click on the ‘+ install’ button.

image.png

  1. Paste the GitHub repo URL then click on Download and install plugin.

image.png

Remarks:

The URL must be a valid GitHub repository url in the format github.com/[username]/[repo-name].

And the primary branch should be main. The plugin installer will search there for the package.json file.

  1. Finally the template-plugin is created, you are able to find your new plugin in the Plugin Manager, as shown below:

image.png

  1. Let’s see our templates and test it, click on View Templates:

image.png

a. Here is our template, as shown below:

image.png

b. Now click on Use Template, click on start

image.png

c. Let’s create a deployment by using the template

image.png

d. Click on Submit and the deployment resource is created

image.png

e. The manifest is created and deployed

image.png

Conclusion

Similarly, we can create manifests and templates for job, service, deployment, etc, and deploy them to our clusters.

Just go through the Monokle documentation to learn and read more. (kubeshop.github.io/monokle) Monokle is a nice tool with a great flexible UI. It makes our lives easier and saves a lot of time. Thanks, Kubeshop for such a great tool.

Happy Templating:)