vcluster icon indicating copy to clipboard operation
vcluster copied to clipboard

Consider making charts more dynamic via use of tpl

Open joaocc opened this issue 1 year ago • 3 comments

Is your feature request related to a problem?

Not a problem but a need and having seen more productivity in other contexts. Bitnami charts make heavy use of the "tpl" function to allow many/most/all evaluations to be dynamic. This would also reduce the need to resort to other tools (namely gitops or other ways of evaluating values at deploy time).

Which solution do you suggest?

Convert the new v0.20.x chart (or on a follow up version) to use tpl when evaluating variables in the various templates. the bitnami.common chart already includes a "common.tplvalues.render" template/function.

Which alternative solutions exist?

Using combinations of gitops, external tools (ansible, bash), or variables in tools like vcluster or other TACOS. All of them increase complexity, even for simple/trivial scenarios.

Additional context

Examples on no particular order:

  • https://github.com/bitnami/charts/blob/main/bitnami/zookeeper/templates/statefulset.yaml#L15
  • https://github.com/bitnami/charts/blob/main/bitnami/keycloak/templates/admin-ingress.yaml#L31
  • https://github.com/kubernetes/dashboard/blob/main/charts/kubernetes-dashboard/templates/security/pdb.yaml#L22
  • https://github.com/seaweedfs/seaweedfs/blob/master/k8s/charts/seaweedfs/templates/master-statefulset.yaml#L226

joaocc avatar May 10 '24 10:05 joaocc

Could you provide specific examples of which values could be automatically determined that aren't already? You'll see a few .tpl files already here: https://github.com/loft-sh/vcluster/tree/main/chart/templates

rohantmp avatar May 14 '24 09:05 rohantmp

Hi. Didn't explain myself correctly. These values are indeed determined dynamically in the sense that they are conditionally assessed at template generation time. However, all referenced values are values defined statically in values.yaml.

It is not possible, for instance, to define "global.myname: abc" and then refer to abc in the name of the persistence volume (ex: path in NFS) and in the ingress name, without repeating the "abc" string in the different places. With common.tplvalues.render (or tpl) when evaluating the persistence volume var, and on ingress name, we can reference to global.myname in the values.yaml, making values.yaml more dynamic/DRY.

joaocc avatar May 14 '24 15:05 joaocc

Forgot to add an example to illustrate (different domain, but same concept)

global:
  myname: example.com

service:
  type: ClusterIP
  ports:
    - name: http
      port: 80
      targetPort: http
      URL: {{ printf "http://%s:%d" .Values.global.myname 80 | quote }}
    - name: https
      port: 443
      targetPort: https
      URL: {{ printf "https://%s:%d" .Values.global.myname 443 | quote }}

joaocc avatar May 14 '24 15:05 joaocc