blob: 01e20fd09b18cb16968ed34540041863bd50f657 [file] [log] [blame]
#!/bin/bash
# Source file to set access credentials to Kubernetes API
# Requires parameters to work with libpepper:
# - SALTAPI_URL
# - SALTAPI_USER
# - SALTAPI_PASS
# Example usage:
# $> export ENV_NAME=some-test-environment
# $> . ./tcp_tests/utils/env_salt
# $> . ./tcp_tests/utils/env_k8s
# # now you can run tcp-qa test cases for k8s
CURRENT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
export PYTHONPATH=${CURRENT_DIR}/../..
if [ -z "$SALTAPI_URL" ]; then
echo "$SALTAPI_URL not found in the environment variables, getting values from salt-master is impossible."
unset kube_host
unset kube_apiserver_port
unset kubernetes_admin_user
unset kubernetes_admin_password
else
KUBE_TARGET='I@haproxy:proxy:enabled:true and I@kubernetes:master and *01*'
export kube_host=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get haproxy:proxy:listen:k8s_secure:binds:address)
export kube_apiserver_port=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get haproxy:proxy:listen:k8s_secure:binds:port)
export kubernetes_admin_user=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get kubernetes:master:admin:username)
export kubernetes_admin_password=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get kubernetes:master:admin:password)
fi
echo "export kube_host='$kube_host' # Kubernetes API host"
echo "export kube_apiserver_port='${kube_apiserver_port}' # Kubernetes API port"
echo "export kubernetes_admin_user='${kubernetes_admin_user}' # Kubernetes admin user"
echo "export kubernetes_admin_password='${kubernetes_admin_password}' # Kubernetes admin password"