Hello fellow Kubernetes enthusiasts! In my previous blog posts we explored the basics of Jsonnet and how to use it to generate Kubernetes manifests. Now, I'm thrilled to finally get to the deployment of our production-ready, Jsonnet-templated application to ArgoCD.
Prerequisites
I am expecting you to have a basic understanding of ArgoCD and Kubernetes for this one. If you need a refresher, check out some resources online (before I create my own tutorials on these topics):
Before diving in, here's a quick overview of what you need to follow along:
- Read through Jsonnet Introduction
- Read through Jsonnet Adventures: Functions, Conditionals, and Advanced Templates
- Jsonnet Templates Repository: All the Jsonnet templates in those tutorials are stored in kubeden/tutorials and you can use it as reference.
- Application Repository: The source code for the Simple Node App is in kubeden/simple-nod-app. Yes, that is a typo lol
- Docker Repository: The application's Docker image is available at kuberdenis/simple-node-app.
ArgoCD and Jsonnet
ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It allows us to deploy applications to Kubernetes using Git repositories as the source of truth. ArgoCD also supports Jsonnet, allowing us to deploy Jsonnet templates directly to Kubernetes.
I repeat - ArgoCD support Jsonnet out of the box! This is a huge advantage, as we can leverage Jsonnet's power to create dynamic Kubernetes manifests, and deploy them using ArgoCD.
The Deployment Process
- Jsonnet Templates: Using Jsonnet, I generated Kubernetes manifests that are both dynamic and maintainable.
- ArgoCD Application: I created an application in ArgoCD pointing to the simple-node-app repository with a path to my prd directory. With a simple sync of the application, ArgoCD deployed the application to my Kubernetes cluster.
The Result
The application, now live, dynamically greets users with the name provided in the YOUR_NAME environment variable.
Here is how the application looks like in ArgoCD:
And here is the application itself:
Now if we update the YOUR_NAME environment variable in the parameters.libsonnet file, and sync the application in ArgoCD, we can see the application dynamically update:
This small, yet powerful demonstration shows the flexibility and power of combining Jsonnet for templating Kubernetes for ArgoCD.
Conclusion
If you made it this far, thank you for reading! I hope you enjoyed this series and learned something new. I am planning to continue writing about Jsonnet and other Kubernetes-related topics, so stay tuned!
For the next Jsonnet post, I am thinking of diving deep into combining multiple templating languages and use Jsonnet + Helm to deploy Grafana and Prometheus.
Thank you for following along and if you feel like chatting, feel free to hit me up on x/twitter!
Top comments (0)