How to add Prefect Server Helm chart as a dependency to an existing helm chart?

View in #prefect-server on Slack

Christian_Nuss @Christian_Nuss: hey everyone! i’m trying to add the Prefect Server Helm chart as a dependency to an existing helm chart. If I want to prefix/rename EVERYTHING that is in the Prefect Server helm chart, is there an easy way to do that?

Michael_Adkins @Michael_Adkins: Hi, we generate names with the following utilities

Christian_Nuss @Christian_Nuss: i saw that, but it was a tid bit headscratching, with respect to namePrefix nameSuffix too…

in my top-level chart, should i set nameOverride or namePrefix or nameSuffix for each component?

Michael_Adkins @Michael_Adkins: Yeah :smile:
So… the name for each object is created with

{{- $name := print (.namePrefix | default "") ( .component ) (.nameSuffix | default "") -}}
{{ printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}

Where the first chunk is the name of the helm release
And the second chunk is the “name” which has a prefix, component, and suffix
The prefix and suffix there are internal to the chart, although we could expose their default value in the values file if it’d be helpful.
It sounds like you want to change the first chunk though, which is just the release name

A Release is an instance of a chart running in a Kubernetes cluster. One chart can often be installed many times into the same cluster. And each time it is installed, a new release is created. Consider a MySQL chart. If you want two databases running in your cluster, you can install that chart twice. Each one will have its own release, which will in turn have its own release name.

Christian_Nuss @Christian_Nuss: exactly, so my Chart.yml looks something like this:

apiVersion: v2
name: my-app
type: application
version: 0.0.0
appVersion: "1.16.0"
...
dependencies:
  - name: postgresql
    version: "~9.3.2"
    repository: <https://charts.bitnami.com/bitnami>
    condition: postgresql.useSubChart
  - name: prefect-server
    version: "2022.01.25"
    repository: https://prefecthq.github.io/server/

so currently its colliding on the service account name and postgres (and we already have a component called ui as well)

i think prefect’s helm is trying to make my-app-postgresql which is already taken by my-app

Michael_Adkins @Michael_Adkins: Hmmm
I think we might need to add something to the chart to make this possible

Christian_Nuss @Christian_Nuss: i think this is the possible issue:

i believe the helper is taking .Chart.Name or which is in this case, my-app , and only allowing .Values.nameOverride as an alternative?

Michael_Adkins @Michael_Adkins: What happens if you provide a nameOverride to the server chart?
The name of the component uses the release name, not the chart name, so I don’t think nameOverride takes effect

Christian_Nuss @Christian_Nuss: in my top level values.yaml, i’ve been playing with something like this…

prefect-server:
  nameOverride: prefect-server
  useSubChart: false
  postgresql:
    nameOverride: prefect-server-postgresql
  serviceAccount:
    name: prefect-server

but that nested nameOverride seems to have no effect?

(PSA I’m new to the way values.yaml are munged for subcharts)

Michael_Adkins @Michael_Adkins: Yeah only the top-level name override will do anything
And it’ll just override the chart name, not the component names

Christian_Nuss @Christian_Nuss: ahh dang :confused:

Michael_Adkins @Michael_Adkins: I think Include the chart name in component names by zanieb · Pull Request #355 · PrefectHQ/server · GitHub will fix this issue

Christian_Nuss @Christian_Nuss: that looks pretty good, wouldn’t we want an option of somekind to conditionally do the new naming, for backwards compatibility?

Michael_Adkins @Michael_Adkins: Perhaps, I’m not actually sure how helm will behave on upgrade when names change
In theory, it’ll just replace the components with the newly named ones.

Christian_Nuss @Christian_Nuss: i believe the service yamls use nameField as well, so in theory the generated DNS name would likely change, that might break anyone that’s hardcoded the DNS name of apollo, for example
i’m wondering if just allowing .namePrefix or .nameSuffix to be provided in values would do the trick?

Michael_Adkins @Michael_Adkins: Ah yes, hm. I’m not really enthused about including a boolean. I’ll see what the rest of the team thinks.
Well… those are supposed to be internal for different uses of nameField
like if somewhere in the chart we had two names for the same component and wanted to add a suffix to one
It’d have to be change to be global prefix/suffix values and I’d rather just fix the default names.

Christian_Nuss @Christian_Nuss: gotcha, i understand! let me know what the rest of the team thinks!
FYI, i’ve worked around this by simply doing another chart install outside of my standard app install