blob: 01e20fd09b18cb16968ed34540041863bd50f657 [file] [log] [blame]
Dennis Dmitriev3ec2e532018-06-08 04:33:34 +03001#!/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
14CURRENT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
15export PYTHONPATH=${CURRENT_DIR}/../..
16
17if [ -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
23else
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)
29fi
30
31echo "export kube_host='$kube_host' # Kubernetes API host"
32echo "export kube_apiserver_port='${kube_apiserver_port}' # Kubernetes API port"
33echo "export kubernetes_admin_user='${kubernetes_admin_user}' # Kubernetes admin user"
34echo "export kubernetes_admin_password='${kubernetes_admin_password}' # Kubernetes admin password"