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

Allow to change cluster domain in KUBE_API_URL #1003

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ENVIRONMENT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Environment Configuration Settings
- **KUBERNETES_ROLE_LABEL**: name of the label containing Postgres role when running on Kubernetens. Default is 'spilo-role'.
- **KUBERNETES_SCOPE_LABEL**: name of the label containing cluster name. Default is 'version'.
- **KUBERNETES_LABELS**: a JSON describing names and values of other labels used by Patroni on Kubernetes to locate its metadata. Default is '{"application": "spilo"}'.
- **KUBERNETES_CLUSTER_DOMAIN**: DNS domain for the kubernetes cluster. Default is 'cluster.local'.
- **INITDB_LOCALE**: database cluster's default UTF-8 locale (en_US by default)
- **ENABLE_WAL_PATH_COMPAT**: old Spilo images were generating wal path in the backup store using the following template ``/spilo/{WAL_BUCKET_SCOPE_PREFIX}{SCOPE}{WAL_BUCKET_SCOPE_SUFFIX}/wal/``, while new images adding one additional directory (``{PGVERSION}``) to the end. In order to avoid (unlikely) issues with restoring WALs (from S3/GC/and so on) when switching to ``spilo-13`` please set the ``ENABLE_WAL_PATH_COMPAT=true`` when deploying old cluster with ``spilo-13`` for the first time. After that the environment variable could be removed. Change of the WAL path also mean that backups stored in the old location will not be cleaned up automatically.
- **WALE_DISABLE_S3_SSE**, **WALG_DISABLE_S3_SSE**: by default wal-e/wal-g are configured to encrypt files uploaded to S3. In order to disable it you can set this environment variable to ``true``.
Expand Down
2 changes: 1 addition & 1 deletion postgres-appliance/runit/patroni/run
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ then
fi

# Only small subset of environment variables is allowed. We don't want accidentally disclose sensitive information
for E in $(printenv -0 | tr '\n' ' ' | sed 's/\x00/\n/g' | grep -vE '^(KUBERNETES_(SERVICE|PORT|ROLE)[_=]|((POD_(IP|NAMESPACE))|HOSTNAME|PATH|PGHOME|LC_ALL|ENABLE_PG_MON)=)' | sed 's/=.*//g'); do
for E in $(printenv -0 | tr '\n' ' ' | sed 's/\x00/\n/g' | grep -vE '^(KUBERNETES_(SERVICE|PORT|ROLE|CLUSTER)[_=]|((POD_(IP|NAMESPACE))|HOSTNAME|PATH|PGHOME|LC_ALL|ENABLE_PG_MON)=)' | sed 's/=.*//g'); do
unset $E
done

Expand Down
3 changes: 2 additions & 1 deletion postgres-appliance/scripts/callback_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
KUBE_NAMESPACE_FILENAME = KUBE_SERVICE_DIR + 'namespace'
KUBE_TOKEN_FILENAME = KUBE_SERVICE_DIR + 'token'
KUBE_CA_CERT = KUBE_SERVICE_DIR + 'ca.crt'
KUBE_CLUSTER_DOMAIN = os.environ.get("KUBERNETES_CLUSTER_DOMAIN", 'cluster.local')

KUBE_API_URL = 'https://kubernetes.default.svc.cluster.local/api/v1/namespaces'
KUBE_API_URL = 'https://kubernetes.default.svc.' + KUBE_CLUSTER_DOMAIN + '/api/v1/namespaces'

logger = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions postgres-appliance/scripts/configure_spilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ def get_placeholders(provider):
placeholders.setdefault('PAM_OAUTH2', '')
placeholders.setdefault('CALLBACK_SCRIPT', '')
placeholders.setdefault('DCS_ENABLE_KUBERNETES_API', '')
placeholders.setdefault('KUBERNETES_CLUSTER_DOMAIN', 'cluster.local')
placeholders.setdefault('KUBERNETES_ROLE_LABEL', 'spilo-role')
placeholders.setdefault('KUBERNETES_SCOPE_LABEL', 'version')
placeholders.setdefault('KUBERNETES_LABELS', KUBERNETES_DEFAULT_LABELS)
Expand Down