{"id":17754727,"url":"https://github.com/gianlucam76/jsonnet-controller","last_synced_at":"2026-05-10T16:10:02.209Z","repository":{"id":169466824,"uuid":"644912588","full_name":"gianlucam76/jsonnet-controller","owner":"gianlucam76","description":"A Jsonnet controller. Get jsonnet files from either Flux source or ConfigMap/Secret. Process them using jsonnet module. Make output available for Sveltos","archived":false,"fork":false,"pushed_at":"2024-05-30T07:51:48.000Z","size":174,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T04:54:09.867Z","etag":null,"topics":["clusterapi","controller","gitops","jsonnet","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gianlucam76.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-24T14:08:19.000Z","updated_at":"2024-06-06T21:05:26.000Z","dependencies_parsed_at":"2023-06-09T10:00:17.882Z","dependency_job_id":"ff3084b1-7233-47b2-a845-a419d7e2de3e","html_url":"https://github.com/gianlucam76/jsonnet-controller","commit_stats":null,"previous_names":["gianlucam76/jsonnet-controller"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianlucam76%2Fjsonnet-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianlucam76%2Fjsonnet-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianlucam76%2Fjsonnet-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianlucam76%2Fjsonnet-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gianlucam76","download_url":"https://codeload.github.com/gianlucam76/jsonnet-controller/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246628421,"owners_count":20808106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clusterapi","controller","gitops","jsonnet","kubernetes"],"created_at":"2024-10-26T14:08:18.291Z","updated_at":"2026-05-10T16:09:57.150Z","avatar_url":"https://github.com/gianlucam76.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonnet-controller\nA Jsonnetcontroller. It can fetch Jsonnet files from:\n\n1. Flux Sources (GitRepository/OCIRepository/Bucket)\n2. ConfigMap/Secret\n\nprocess those files programmatically invoking jsonnet go module and store the output in its Status section. Sveltos addon-manager can then be used to deploy the output of the jsonnet-controller in all selected managed clusters.\n\n\u003cimg src=\"https://github.com/projectsveltos/sveltos/blob/e045d8cb059ac7796a00470a61c5759f1389746f/docs/assets/flux-jsonnet-sveltos.png\"\u003e\n\n\n## Install\n\n```bash\nkubectl apply -f https://raw.githubusercontent.com/gianlucam76/jsonnet-controller/main/manifest/manifest.yaml\n```\n\nor if you want a specific version\n\n```bash\nkubectl apply -f https://raw.githubusercontent.com/gianlucam76/jsonnet-controller/\u003ctag\u003e/manifest/manifest.yaml\n```\n\n\n## Using Flux GitRepository\n\nFor instance, this Github repository https://github.com/gianlucam76/jsonnet-examples contains jsonnet files. \nYou can use Flux to sync from it and then simply post this [JsonnetSource](https://github.com/gianlucam76/jsonnet-controller/blob/main/api/v1beta1/jsonnetsource_types.go) CRD instance.\nThe jsonnet-controller will detect when Flux has synced the repo (and anytime there is a change), will programatically invoke jsonnet go module and store the outcome in its Status.Resources field.\n\n```yaml\napiVersion: extension.projectsveltos.io/v1beta1\nkind: JsonnetSource\nmetadata:\n  name: jsonnetsource-flux\nspec:\n  namespace: flux-system\n  name: flux-system\n  kind: GitRepository\n  path: ./variables/deployment.jsonnet\n  variables:\n    deploymentName: eng\n    namespace: staging\n    replicas: \"3\"\n```\n\n```yaml\napiVersion: extension.projectsveltos.io/v1beta1\nkind: JsonnetSource\nmetadata:\n  annotations:\n    kubectl.kubernetes.io/last-applied-configuration: |\n      {\"apiVersion\":\"extension.projectsveltos.io/v1beta1\",\"kind\":\"JsonnetSource\",\"metadata\":{\"annotations\":{},\"name\":\"jsonnetsource-flux\",\"namespace\":\"default\"},\"spec\":{\"kind\":\"GitRepository\",\"name\":\"flux-system\",\"namespace\":\"flux-system\",\"path\":\"./variables/deployment.jsonnet\",\"variables\":{\"deploymentName\":\"eng\",\"namespace\":\"staging\",\"replicas\":\"3\"}}}\n  creationTimestamp: \"2023-05-26T06:55:13Z\"\n  generation: 3\n  name: jsonnetsource-flux\n  namespace: default\n  resourceVersion: \"39826\"\n  uid: b4cc7584-528d-4938-b6ed-74ec5ba1d760\nspec:\n  kind: GitRepository\n  name: flux-system\n  namespace: flux-system\n  path: ./variables/deployment.jsonnet\n  variables:\n    deploymentName: eng\n    namespace: staging\n    replicas: \"3\"\nstatus:\n  resources: |\n    {\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"labels\":{\"app\":\"eng\"},\"name\":\"eng\",\"namespace\":\"staging\"},\"spec\":{\"replicas\":3,\"selector\":{\"matchLabels\":{\"app\":\"eng\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"eng\"}},\"spec\":{\"containers\":[{\"image\":\"nginx:latest\",\"name\":\"my-container\",\"ports\":[{\"containerPort\":80}]}]}}}}\n```\n\nSveltos can used at this point to deploy resources in managed clusters:\n\n```yaml\napiVersion: config.projectsveltos.io/v1beta1\nkind: ClusterProfile\nmetadata:\n  name: deploy-resources\nspec:\n  clusterSelector: env=fv\n  templateResourceRefs:\n  - resource:\n      apiVersion: extension.projectsveltos.io/v1beta1\n      kind: JsonnetSource\n      name: jsonnetsource-flux\n      namespace: default\n    identifier: JsonnetSource\n  policyRefs:\n  - kind: ConfigMap\n    name: info\n    namespace: default\n---\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: info\n  namespace: default\n  annotations:\n    projectsveltos.io/template: \"true\"  # add annotation to indicate Sveltos content is a template\ndata:\n  resource.yaml: |\n    {{ (index .MgtmResources \"JsonnetSource\").status.resources }}\n```\n\n```bash\nkubectl exec -it -n projectsveltos  sveltosctl-0   -- ./sveltosctl show addons \n+-------------------------------------+-----------------+-----------+------+---------+-------------------------------+------------------+\n|               CLUSTER               |  RESOURCE TYPE  | NAMESPACE | NAME | VERSION |             TIME              | CLUSTER PROFILES |\n+-------------------------------------+-----------------+-----------+------+---------+-------------------------------+------------------+\n| default/sveltos-management-workload | apps:Deployment | staging   | eng  | N/A     | 2023-05-26 00:24:57 -0700 PDT | deploy-resources |\n+-------------------------------------+-----------------+-----------+------+---------+-------------------------------+------------------+\n```\n\n## Using ConfigMap/Secret\n\nJsonnetSource can also reference ConfigMap/Secret. For instance, we can create a ConfigMap whose BinaryData section contains jsonnet files.\n\n```bash\ntar -czf jsonnet.tar.gz -C ~mgianluc/go/src/github.com/gianlucam76/jsonnet-examples/multiple-files .\nkubectl create configmap jsonnet --from-file=jsonnet.tar.gz=jsonnet.tar.gz \n```\n\nThen we can have JsonnetSource reference this ConfigMap instance\n\n```yaml\napiVersion: extension.projectsveltos.io/v1beta1\nkind: JsonnetSource\nmetadata:\n  name: jsonnetsource-configmap\nspec:\n  namespace: default\n  name: jsonnet\n  kind: ConfigMap\n  path: ./main.jsonnet\n  variables:\n    namespace: production\n```\n\nand the controller will programmatically execute jsonnet go module and store the outcome in Status.Results.\n\n```yaml\napiVersion: extension.projectsveltos.io/v1beta1\nkind: JsonnetSource\nmetadata:\n  annotations:\n    kubectl.kubernetes.io/last-applied-configuration: |\n      {\"apiVersion\":\"extension.projectsveltos.io/v1beta1\",\"kind\":\"JsonnetSource\",\"metadata\":{\"annotations\":{},\"name\":\"jsonnetsource-configmap\",\"namespace\":\"default\"},\"spec\":{\"kind\":\"ConfigMap\",\"name\":\"jsonnet\",\"namespace\":\"default\",\"path\":\"./main.jsonnet\",\"variables\":{\"namespace\":\"production\"}}}\n  creationTimestamp: \"2023-05-26T08:28:48Z\"\n  generation: 1\n  name: jsonnetsource-configmap\n  namespace: default\n  resourceVersion: \"121599\"\n  uid: eea93390-771d-4176-92fe-2b761b803764\nspec:\n  kind: ConfigMap\n  name: jsonnet\n  namespace: default\n  path: ./main.jsonnet\n  variables:\n    namespace: production\nstatus:\n  resources: |\n    ---\n    {\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"name\":\"my-deployment\",\"namespace\":\"production\"},\"spec\":{\"replicas\":3,\"selector\":{\"matchLabels\":{\"app\":\"my-app\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"my-app\"}},\"spec\":{\"containers\":[{\"image\":\"my-image:latest\",\"name\":\"my-container\",\"ports\":[{\"containerPort\":8080}]}]}}}}\n    ---\n    {\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"name\":\"my-service\",\"namespace\":\"production\"},\"spec\":{\"ports\":[{\"port\":80,\"protocol\":\"TCP\",\"targetPort\":8080}],\"selector\":{\"app\":\"my-app\"},\"type\":\"LoadBalancer\"}}\n```\n\nAt this point [Sveltos Kubernetes addon controller](https://github.com/projectsveltos/addon-controller) to use the output of the jsonnet-controller and deploy those resources in all selected managed clusters. To know more refer to [Sveltos documentation](https://projectsveltos.github.io/sveltos/ytt_extension/)\n\n## Contributing \n\n❤️ Your contributions are always welcome! If you want to contribute, have questions, noticed any bug or want to get the latest project news, you can connect with us in the following ways:\n\n1. Read contributing [guidelines](CONTRIBUTING.md)\n2. Open a bug/feature enhancement on github [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/projectsveltos/addon-manager/issues)\n3. Chat with us on the Slack in the #projectsveltos channel [![Slack](https://img.shields.io/badge/join%20slack-%23projectsveltos-brighteen)](https://join.slack.com/t/projectsveltos/shared_invite/zt-1hraownbr-W8NTs6LTimxLPB8Erj8Q6Q)\n4. [Contact Us](mailto:support@projectsveltos.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianlucam76%2Fjsonnet-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgianlucam76%2Fjsonnet-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianlucam76%2Fjsonnet-controller/lists"}