Dennis Dmitriev | 3ec2e53 | 2018-06-08 04:33:34 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Source file to set access credentials to Kubernetes API |
| 4 | # Requires parameters to work with libpepper: |
| 5 | # - SALTAPI_URL |
| 6 | # - SALTAPI_USER |
| 7 | # - SALTAPI_PASS |
| 8 | # Example usage: |
| 9 | # $> export ENV_NAME=some-test-environment |
| 10 | # $> . ./tcp_tests/utils/env_salt |
| 11 | # $> . ./tcp_tests/utils/env_k8s |
| 12 | # # now you can run tcp-qa test cases for k8s |
| 13 | |
| 14 | CURRENT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) |
| 15 | export PYTHONPATH=${CURRENT_DIR}/../.. |
| 16 | |
| 17 | if [ -z "$SALTAPI_URL" ]; then |
| 18 | echo "$SALTAPI_URL not found in the environment variables, getting values from salt-master is impossible." |
| 19 | unset kube_host |
| 20 | unset kube_apiserver_port |
| 21 | unset kubernetes_admin_user |
| 22 | unset kubernetes_admin_password |
| 23 | else |
| 24 | KUBE_TARGET='I@haproxy:proxy:enabled:true and I@kubernetes:master and *01*' |
| 25 | export kube_host=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get haproxy:proxy:listen:k8s_secure:binds:address) |
| 26 | export kube_apiserver_port=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get haproxy:proxy:listen:k8s_secure:binds:port) |
| 27 | export kubernetes_admin_user=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get kubernetes:master:admin:username) |
| 28 | export kubernetes_admin_password=$(${PYTHONPATH}/tcp_tests/utils/get_param.py -C "${KUBE_TARGET}" pillar.get kubernetes:master:admin:password) |
| 29 | fi |
| 30 | |
| 31 | echo "export kube_host='$kube_host' # Kubernetes API host" |
| 32 | echo "export kube_apiserver_port='${kube_apiserver_port}' # Kubernetes API port" |
| 33 | echo "export kubernetes_admin_user='${kubernetes_admin_user}' # Kubernetes admin user" |
| 34 | echo "export kubernetes_admin_password='${kubernetes_admin_password}' # Kubernetes admin password" |