Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[K8S-STAND-PGSQL] Bad DB_CONNECTION_URI generated #1650

Closed
AurelienConte opened this issue Apr 3, 2024 · 2 comments
Closed

[K8S-STAND-PGSQL] Bad DB_CONNECTION_URI generated #1650

AurelienConte opened this issue Apr 3, 2024 · 2 comments

Comments

@AurelienConte
Copy link

Hi,

I was installing the infisical standalone postgresql helm charts but nothing is starting up because of the DB_CONNECTION_URI badly generated.

Here is the line :

{{- define "infisical.postgresService" -}}
{{- if .Values.postgresql.fullnameOverride -}}
{{- .Values.postgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-postgresql" .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- $serviceName := include "infisical.postgresService" . -}}
{{- printf "postgresql://%s:%s@%s:5432/%s" $dbUsername $dbPassword $serviceName $dbName -}}

The default value of DB_CONNECTION_URI is : postgresql://infisical:root@postgresql:5432/infisicalDB

But in a kubernetes environment this can not work, a good string should use the ".svc.cluster.local" internal dns.

Assuming the charts is deployed in a namespace : "infisical" the DB_CONNECTION_URI should be :

postgresql://infisical:root@postgresql.infisical.svc.cluster.local:5432/infisicalDB

If you need more information on how to reproduce my problem feel free to ask me anything. ( But i was just following the guide : https://infisical.com/docs/self-hosting/deployment-options/kubernetes-helm )

Here is my values.yaml

infisical:
  image:
    tag: "v0.51.2-postgres"

ingress:
  enabled: false
@Grraahaam
Copy link
Contributor

Grraahaam commented Apr 7, 2024

Hey @AurelienConte ! It's indeed a good practice to define the entire FQDN if ever you move services between namespaces (doesnt happen that often) or just to be sure to point to the right one.

Although, the kubelet automatically configure a /etc/resolf.conf in each pod for it to be able to resolve any hosts in the same namespace, so the current helm template works as expected.

$ cat /etc/resolv.conf 
search my-service.svc.cluster.local svc.cluster.local cluster.local my-namespace
nameserver 10.32.0.10
options ndots:5

If you want to point to a different postgresql instance (managed externally) you can configure it in the DB_CONNECTION_URI variable in the infisical-secrets k8s secret used by the infisical pod to get default/extra configs.

However, I don't understand why your instance isn't starting, it should.. Do you have any useful logs? Are you sure it's related to the DB_CONNECTION_URI?

Hope it helps

@AurelienConte
Copy link
Author

Hi back!

I think I can say "My bad" because today after re-installing the chart there were no problems at all ...
I don't know why my instances couldn't connect to the Postgresql included in the helm chart.

I was not aware that the /etc/resolv.conf was filled automatically

We can close this issue since it was more a setup problem than a chart problem.

Thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants