Add an environment variable that defines which config to load
See https://stackoverflow.com/a/63873828
This commit is contained in:
parent
95eb8db5a3
commit
f68380a461
3 changed files with 14 additions and 1 deletions
|
@ -15,3 +15,8 @@ KRATOS_PUBLIC_URL = str(os.environ.get("KRATOS_PUBLIC_URL")) + "/"
|
||||||
|
|
||||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
|
|
||||||
|
# Set this to "true" to load the config from a Kubernetes serviceaccount
|
||||||
|
# running in a Kubernetes pod. Set it to "false" to load the config from the
|
||||||
|
# `KUBECONFIG` environment variable.
|
||||||
|
LOAD_INCLUSTER_CONFIG = os.environ.get("LOAD_INCLUSTER_CONFIG").lower() == "true"
|
||||||
|
|
|
@ -32,6 +32,9 @@ services:
|
||||||
- SECRET_KEY=$FLASK_SECRET_KEY
|
- SECRET_KEY=$FLASK_SECRET_KEY
|
||||||
- HYDRA_CLIENT_SECRET=$HYDRA_CLIENT_SECRET
|
- HYDRA_CLIENT_SECRET=$HYDRA_CLIENT_SECRET
|
||||||
- KUBECONFIG=/.kube/config
|
- KUBECONFIG=/.kube/config
|
||||||
|
|
||||||
|
# Disable loading config from the service account
|
||||||
|
- LOAD_INCLUSTER_CONFIG=false
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
user: "${KUBECTL_UID}:${KUBECTL_GID}"
|
user: "${KUBECTL_UID}:${KUBECTL_GID}"
|
||||||
|
|
|
@ -14,11 +14,16 @@ from kubernetes.utils import create_from_yaml
|
||||||
from kubernetes.utils.create_from_yaml import FailToCreateError
|
from kubernetes.utils.create_from_yaml import FailToCreateError
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
from config import LOAD_INCLUSTER_CONFIG
|
||||||
|
|
||||||
# Load the kube config once
|
# Load the kube config once
|
||||||
#
|
#
|
||||||
# By default this loads whatever we define in the `KUBECONFIG` env variable,
|
# By default this loads whatever we define in the `KUBECONFIG` env variable,
|
||||||
# otherwise loads the config from default locations, similar to what kubectl
|
# otherwise loads the config from default locations, similar to what kubectl
|
||||||
# does.
|
# does.
|
||||||
|
if LOAD_INCLUSTER_CONFIG:
|
||||||
|
config.load_incluster_config()
|
||||||
|
else:
|
||||||
config.load_kube_config()
|
config.load_kube_config()
|
||||||
|
|
||||||
def create_variables_secret(app_slug, variables_filepath):
|
def create_variables_secret(app_slug, variables_filepath):
|
||||||
|
|
Loading…
Reference in a new issue