projectsveltos / addon-controller

Sveltos Kubernetes add-on controller programmatically deploys add-ons and applications in tens of clusters. Support for ClusterAPI powered clusters, Helm charts, kustomize ,YAMLs. Sveltos has built-in support for multi-tenancy.
https://projectsveltos.github.io/sveltos/
Apache License 2.0
288 stars 24 forks source link

Template-Based Helm Chart Versioning in ClusterProfile Using Labels #794

Open emreberber opened 2 weeks ago

emreberber commented 2 weeks ago

Currently, ClusterProfile in Sveltos allows defining a fixed chartVersion for Helm charts across clusters that match a clusterSelector. However, in complex environments where clusters vary in Kubernetes version, region, or other metadata, a single chartVersion may not meet compatibility or regional deployment requirements. A templating approach, where chart versions (or other configurations) can dynamically adjust based on metadata labels, would offer more flexible and efficient management.

apiVersion: config.projectsveltos.io/v1alpha1
kind: ClusterProfile
metadata:
  name: prometheus-grafana
spec:
  clusterSelector: env=fv
  helmCharts:
  - repositoryURL:    https://prometheus-community.github.io/helm-charts
    repositoryName:   prometheus-community
    chartName:        prometheus-community/prometheus
    chartVersion:     |
      {{- if eq .metadata.labels.k8s-version "1.20" }}23.4.0
      {{- else if eq .metadata.labels.k8s-version "1.22" }}24.1.0
      {{- else if eq .metadata.labels.k8s-version "1.25" }}25.0.2
      {{- else }}23.4.0
      {{- end }}
    releaseName:      prometheus
    releaseNamespace: prometheus
    helmChartAction:  Install

Example Use Case:

For instance, if clusters have metadata labels such as k8s-version, region, or env, ClusterProfile could use these to set the chartVersion or other parameters automatically:

gianlucam76 commented 2 weeks ago

Thank you @emreberber

I will think a little more on this tomorrow before confirming, but I believe this should be easy to implement. But again, I will spend some time on it before confirming it.

Thanks for suggesting this.

emreberber commented 2 weeks ago

Thank you in advance @gianlucam76 πŸ™πŸ» πŸš€

DanaIzadpanah commented 1 week ago

Could you assign this to me, I would be more than happy to help

gianlucam76 commented 1 week ago

Hi @DanaIzadpanah thank you. This is kinda of taken care of by this

If you see any other issue you would like to help with, I would be more than happy to assign it to you. Thank you so much!

DanaIzadpanah commented 1 week ago

Yes I will definitely let you know :)

gianlucam76 commented 1 week ago

Thank you @DanaIzadpanah

Not sure if this is interesting to you, but if so it would be great to:

  1. extend metrics exposed by sveltos controllers
  2. have predefined Grafana dashboard.

Thank you!