Kubernetes: Dynamically create configuration json files from j2 templates

7/20/2016

Is there an already built in j2 template processor in kubernetes or docker? I am doing the configuration below and wanted to plugin the values on the template.

Note that using hostPath is not an option since this is using openshift and no pv/pvc can be used.

containers:
    - image: some-docker-image:latest
      name: some-docker-image
      volumeMounts:
        - mountPath: /etc/app/conf
          name: configuration-volume
.
. Do some j2 template processing here if possible.
.

volumes:
    - name: configuration-volume
      gitRepo:
        repository: "https://gitrepo/repo/example.git
-- javapadawan
docker
jinja2
json
kubernetes
openshift-origin

1 Answer

7/21/2016

There isn't any templating support built into Kubernetes. You can easily build a templating system on top of the yaml/json files that you pass into kubectl -f create though. I know some folks that are using jsonnet to accomplish this.

The discussion around adding templates is happening in https://github.com/kubernetes/kubernetes/issues/23896 if you'd like to contribute.

-- Robert Bailey
Source: StackOverflow