'define hostnames for services in kubernetes namespaces
We run an application stack in k8s with several environments (prod, test, dev) and deploy via a custom helm chart. The application stack contains a postgres HA cluster (https://github.com/bitnami/charts/tree/master/bitnami/postgresql-ha) and several other custom APIs and services.
Currently we use an environment configuration file for each environment. However, since the standard hostnames (e.g. for postgres pgpool) contains the namespace as well, we need to follow strict namespace patterns which we need to encode in the environment file before deploying. e.g.
namespace: env1
pgpool service: pgpool
db host then is env1.pgpool
This is quite clumsy and it would be more flexible if we could set the hostname for the pgpool service always the same (e.g. db) in each namespaces (as we did in previous times in docer-compose stacks). Then we could always set the postgres hostname to "db" instead of env1.pgpool irrespective of the namespace it is deployed in, yet teh hostname should only be scoped for the respective namespace.
in short: can I set a hostname in a service definition that is scope only for the namespace and which can be used by each deployment in the namespace, without having the namespace in the host.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
