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

Add value for Kubernetes cluster name #628

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bernljung
Copy link

Description

Adding a configurable value for the name of the Kubernetes cluster. I need this because my hosting provider assigns custom cluster names and this breaks the internal communication in the initContainers snippet making in stay in a pending state forever.
I have made the change wherever I could find the pattern svc.cluster.local. (test code excluded)

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this been tested?

Configured the correct cluster name in my custom values.yaml and was succesfully able to deploy. I have also tested the fallback to the default cluster name in the same way.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@@ -8,6 +8,14 @@
{{- end -}}
{{- end }}

{{- define "posthog.clusterName" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see much value of having this if we anyway specify a default in the values

@@ -8,6 +8,9 @@ notificationEmail:
# This is used to e.g. generate shareable links to Dashboards.
siteUrl:

# -- Cluster name used for internal DNS resolution (svc.{{clusterName}}.local)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# -- Cluster name used for internal DNS resolution (svc.{{clusterName}}.local)
# -- Kubernetes cluster domain name

@@ -8,6 +8,9 @@ notificationEmail:
# This is used to e.g. generate shareable links to Dashboards.
siteUrl:

# -- Cluster name used for internal DNS resolution (svc.{{clusterName}}.local)
clusterName: cluster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clusterName: cluster
clusterDomain: cluster.local

@@ -34,7 +34,7 @@ spec:
- |
until (
wget -qO- \
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@clickhouse-posthog.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local:8123" \
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@clickhouse-posthog.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local:8123" \
Copy link
Contributor

@guidoiaquinti guidoiaquinti Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@clickhouse-posthog.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local:8123" \
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@clickhouse-posthog.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterDomain }}:8123" \

@@ -48,7 +48,7 @@
KAFKA_HOST=$(echo $KAFKA_BROKERS | cut -f1 -d:)
KAFKA_PORT=$(echo $KAFKA_BROKERS | cut -f2 -d:)

until (nc -vz "$KAFKA_HOST.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" $KAFKA_PORT);
until (nc -vz "$KAFKA_HOST.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" $KAFKA_PORT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
until (nc -vz "$KAFKA_HOST.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" $KAFKA_PORT);
until (nc -vz "$KAFKA_HOST.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterDomain }}" $KAFKA_PORT);

do
echo "waiting for PostgreSQL"; sleep 1;
done
{{ end }}

{{ if .Values.redis.enabled }}
until (nc -vz "{{ include "posthog.redis.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "posthog.redis.port" . }});
until (nc -vz "{{ include "posthog.redis.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" {{ include "posthog.redis.port" . }});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
until (nc -vz "{{ include "posthog.redis.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" {{ include "posthog.redis.port" . }});
until (nc -vz "{{ include "posthog.redis.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterDomain }}" {{ include "posthog.redis.port" . }});

do
echo "waiting for PgBouncer"; sleep 1;
done

{{ if .Values.postgresql.enabled }}
until (nc -vz "{{ include "posthog.postgresql.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "posthog.postgresql.port" . }});
until (nc -vz "{{ include "posthog.postgresql.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" {{ include "posthog.postgresql.port" . }});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
until (nc -vz "{{ include "posthog.postgresql.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" {{ include "posthog.postgresql.port" . }});
until (nc -vz "{{ include "posthog.postgresql.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterDomain }}" {{ include "posthog.postgresql.port" . }});

@@ -22,20 +22,20 @@
done
{{ end }}

until (nc -vz "{{ include "posthog.pgbouncer.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "posthog.pgbouncer.port" . }});
until (nc -vz "{{ include "posthog.pgbouncer.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" {{ include "posthog.pgbouncer.port" . }});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
until (nc -vz "{{ include "posthog.pgbouncer.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local" {{ include "posthog.pgbouncer.port" . }});
until (nc -vz "{{ include "posthog.pgbouncer.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterDomain}}" {{ include "posthog.pgbouncer.port" . }});

@@ -12,7 +12,7 @@
{{ if .Values.clickhouse.enabled }}
until (
NODES_COUNT=$(wget -qO- \
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@{{ include "posthog.clickhouse.fullname" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local:8123" \
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@{{ include "posthog.clickhouse.fullname" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local:8123" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@{{ include "posthog.clickhouse.fullname" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterName }}.local:8123" \
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@{{ include "posthog.clickhouse.fullname" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.{{ .Values.clusterDomain }}:8123" \

@guidoiaquinti
Copy link
Contributor

guidoiaquinti commented Nov 23, 2022

@bernljung I've made a couple of suggestions, let me know if they work for you. CI is running.

Edit: unit tests are failing because we likely need to update the snapshots. Regarding the Release Chart action, feel free to ignore it.

Edit #2: a bit related to this, I've opened #635 to add a PgBouncer service FQDN. We should likely do the same for all the services so that your change will be not needed. Let me know what do you think about it.

@guidoiaquinti guidoiaquinti mentioned this pull request Nov 23, 2022
6 tasks
@bernljung
Copy link
Author

Edit #2: a bit related to this, I've opened #635 to add a PgBouncer service FQDN. We should likely do the same for all the services so that your change will be not needed. Let me know what do you think about it.

@guidoiaquinti I like this, way cleaner! 👍

@guidoiaquinti
Copy link
Contributor

Edit #2: a bit related to this, I've opened #635 to add a PgBouncer service FQDN. We should likely do the same for all the services so that your change will be not needed. Let me know what do you think about it.

@guidoiaquinti I like this, way cleaner! 👍

Do you want to take a stab at doing this @bernljung ?

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

Successfully merging this pull request may close these issues.

2 participants