How to fix nodes hostnames too long when deploying helm chart in Gitlab CI

11/28/2019

What I'm trying to achieve

Hi, I am currently trying to deploy a postgresql-ha (more specifically bitnami/postgresql-ha) helm chart through a gitlab CI job.

What I can achieve locally

Locally, when running helm install postgresql ./postgresql-ha, I am able to create the chart on my remote Kubernetes Cluster successfully without any error.

./postgresql-ha is an unmodified pull of bitnami/postgresql-ha.

What happens when I run it through CI

When I try to run the same command in Gitlab's CI, with a properly set helm and kubectl, I get this error:

Release "postgresql" does not exist. Installing it now.
Error: template: postgresql-ha/templates/NOTES.txt:60:4: executing "postgresql-ha/templates/NOTES.txt" at <include "postgresql-ha.validateValues" .>: error calling include: template: postgresql-ha/templates/_helpers.tpl:682:51: executing "postgresql-ha.validateValues" at <fail>: error calling fail: 
VALUES VALIDATION:
postgresql-ha: Nodes hostnames
    PostgreSQL nodes hostnames exceeds the characters limit for Pgpool: 128.
    Consider using a shorter release name or namespace.

The first line validates the kubectl/helm configurations.

.gitlab-ci.yml File

##########
# Stages #
##########

stages:
  - deploy charts

########
# Jobs #
########

deploy_postgresql-ha:
  image: dtzar/helm-kubectl:3.0.0
  stage: deploy charts
  environment:
    name: production
  script:
    - helm upgrade --install postgresql ./postgresql-ha

The Kubernetes Cluster was created via Gitlab's Kubernetes Integration tool and is therefore already set up, as per this Gitlab Documentation page.

Thanks in advance the help!

-- Sébastien De Varennes
bitnami
gitlab-ci
kubernetes
kubernetes-helm
postgresql

1 Answer

11/29/2019

It seems there is a bug on pgpool:

ping probes fail with long hostnames due to small buffer pgpool calls "ping -q -c3 " and parses the result to ascertain if a host is up or down. Unfortunately it uses a rather small buffer to read the output and the last line of the ping command can get truncated. This means that pgpool assumes the host is down.

https://pgpool.net/mantisbt/print_all_bug_page_word.php?search=&sort=&dir=DESC&type_page=html&export=-1&show_flag=0

Bitnami upgraded the code so now long hostnames are not allowed anymore. Nodehostname is composed on the following components, so you can adjust:

$nodeHostname := printf "%s-00.%s.%s.svc.%s:1234" $postgresqlFullname $postgresqlHeadlessServiceName $releaseNamespace $clusterDomain }}

https://github.com/bitnami/charts/blob/master/bitnami/postgresql-ha/templates/_helpers.tpl

-- iliefa
Source: StackOverflow