My first usage of jsonnet
- 2 minutes read - 230 wordsIn the past I knew jsonnet, however I didn’t commit too much time to learn it until recently I encountered a data driven scenario, generating istio yaml configurations based on an array of data. The scenario is business driven, and I can foresee that there will be more data coming. What a waste of time to repeat the copy/paste procedures with little tweaks. I hated to do that again and again. There are other options to generate the yaml configuraton files by templates and data, I settled on jsonnet as it was json compatible etc. I figured out doing that data driven configuraton using jsonnet after spending half night yesterday.
The whole journey was not a smooth one. Here I logged my thoughts and hiccups I encountered here.
At first, I wanted to use tanka. I thought it might be too heavy after I learnt that there are environments and spec.json. I tried to use jsonnet-bundler to install jsonnet-libs following the document and failed. I only got it right when I noticed the jb usage at here.
# branch or tags are after @ symbol
jb install github.com/jsonnet-libs/k8s-libsonnet/1.21@main
After I successfully installed cert-manager-libsonnet using jb, I noticed that tanka supports more features than I thought. Considing the possibility to integrate tanka with argo-cd, I went back to use tanka again.
My final result is here.