[Suggestion Needed] Discussion on improving compatibility for helm based deployment #253

Closed
opened 2026-02-21 17:26:32 -05:00 by yindo · 4 comments
Owner

Originally created by @BorisPolonsky on GitHub (Jul 10, 2023).

Is your feature request related to a problem? Please describe.
We are the contributors of community based project dify-helm, a solution for k8s deployment. We've identified a minor incompatibility issue, where api won't function if and only if release name were set as dify. And we'd like to discuss a proper way to fix this.
Steps to replicate

helm install dify -n some-ns . --create-namespace

Result

kubectl logs -f -n some-ns dify-api-5549c8b5d9-ggtkj
Running migrations
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.

Error: 'tcp' is not a valid port number.

Describe the solution you'd like
According to our investigation, DIFY_PORT is a reserved variable in entrypoint.sh. As service related environment variable will be automatically injected in pods, in this case {RELEASE_NAME}_PORT=tcp://10.105.104.43:80, which messed up DIFY_PORT. We would like to discuss on a solution to this corner case, say changing DIFY_PORT to PORT, where variable collision won't occur no matter how users deploy their charts.
Describe alternatives you've considered
We've considered explicitly overriding DIFY_PORT in deployment for api. But it's not practical since custom variables defined configMap/Secret are of lower priority than auto injection.
Additional context
Add any other context or screenshots about the feature request here.

Originally created by @BorisPolonsky on GitHub (Jul 10, 2023). **Is your feature request related to a problem? Please describe.** We are the contributors of community based project [dify-helm](https://github.com/BorisPolonsky/dify-helm), a solution for k8s deployment. We've identified a minor incompatibility [issue](https://github.com/BorisPolonsky/dify-helm/issues/7#issue-1792983141), where `api` won't function if and only if release name were set as `dify`. And we'd like to discuss a proper way to fix this. Steps to replicate ``` helm install dify -n some-ns . --create-namespace ``` Result ``` kubectl logs -f -n some-ns dify-api-5549c8b5d9-ggtkj Running migrations INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. Error: 'tcp' is not a valid port number. ``` **Describe the solution you'd like** According to our investigation, `DIFY_PORT` is a reserved variable in [entrypoint.sh](https://github.com/langgenius/dify/blob/7c00a0b6a3c8dd383ce79ee1b96faff5d1b369a4/api/docker/entrypoint.sh#L17). As service related environment variable will be automatically injected in pods, in this case `{RELEASE_NAME}_PORT=tcp://10.105.104.43:80`, which messed up `DIFY_PORT`. We would like to discuss on a solution to this corner case, say changing `DIFY_PORT` to `PORT`, where variable collision won't occur no matter how users deploy their charts. **Describe alternatives you've considered** We've considered explicitly overriding `DIFY_PORT` in `deployment` for `api`. But it's not practical since custom variables defined `configMap`/`Secret` are of lower priority than auto injection. **Additional context** Add any other context or screenshots about the feature request here.
yindo closed this issue 2026-02-21 17:26:32 -05:00
Author
Owner

@takatost commented on GitHub (Jul 10, 2023):

Have u tried adding enableServiceLinks: false to the config to disable service env injection?

@takatost commented on GitHub (Jul 10, 2023): Have u tried adding `enableServiceLinks: false` to the config to disable service env injection?
Author
Owner

@BorisPolonsky commented on GitHub (Jul 10, 2023):

For deplyment-api.yaml

    spec:
      {{- if eq .Release.Name "dify"}}
      {{/*
      Disable service environment variables,
      otherwise they will clash with `DIFY_PORT` which is needed in entrypoint.sh
      */}}
      enableServiceLinks: false
      {{- end }}

It works. Though we have yet to decide if this solution is elegant enough.

@BorisPolonsky commented on GitHub (Jul 10, 2023): For `deplyment-api.yaml` ``` spec: {{- if eq .Release.Name "dify"}} {{/* Disable service environment variables, otherwise they will clash with `DIFY_PORT` which is needed in entrypoint.sh */}} enableServiceLinks: false {{- end }} ``` It works. Though we have yet to decide if this solution is elegant enough.
Author
Owner

@takatost commented on GitHub (Jul 10, 2023):

I used to have this issue a lot, especially when deploying Redis, the REDIS_HOST / REDIS_POST might be overridden with something like tcp://xxx, which causes the startup to fail.

@takatost commented on GitHub (Jul 10, 2023): I used to have this issue a lot, especially when deploying Redis, the REDIS_HOST / REDIS_POST might be overridden with something like tcp://xxx, which causes the startup to fail.
Author
Owner

@BorisPolonsky commented on GitHub (Jul 11, 2023):

For deplyment-api.yaml

    spec:
      {{- if eq .Release.Name "dify"}}
      {{/*
      Disable service environment variables,
      otherwise they will clash with `DIFY_PORT` which is needed in entrypoint.sh
      */}}
      enableServiceLinks: false
      {{- end }}

It works. Though we have yet to decide if this solution is elegant enough.

Then this solution is sealed.

@BorisPolonsky commented on GitHub (Jul 11, 2023): > For `deplyment-api.yaml` > > ``` > spec: > {{- if eq .Release.Name "dify"}} > {{/* > Disable service environment variables, > otherwise they will clash with `DIFY_PORT` which is needed in entrypoint.sh > */}} > enableServiceLinks: false > {{- end }} > ``` > > It works. Though we have yet to decide if this solution is elegant enough. Then this solution is sealed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#253