aboutsummaryrefslogtreecommitdiffstats
path: root/test/security/k8s
diff options
context:
space:
mode:
authorPawel Wieczorek <p.wieczorek2@samsung.com>2019-07-31 15:38:15 +0200
committerPawel Wieczorek <p.wieczorek2@samsung.com>2019-07-31 16:07:23 +0200
commite466145e1c1e359a388f3bd2e15130941ac76c1e (patch)
tree85306f8f24e136c82852670baca0b5f472f91c76 /test/security/k8s
parent625be0d2f81705b3ab863ee3d13948f4355e2a7b (diff)
k8s: Make ONAP context default for kubectl
This patch uses previously added alias for kubectl context switching in case it is needed as a template for other contexts as well. Issue-ID: SECCOM-235 Change-Id: Ie92641ee3763a027cd74dd21bf4364a2d796eb1d Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
Diffstat (limited to 'test/security/k8s')
-rwxr-xr-xtest/security/k8s/tools/dublin/setup_kubectl.sh13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/security/k8s/tools/dublin/setup_kubectl.sh b/test/security/k8s/tools/dublin/setup_kubectl.sh
index a50c23656..bbd31a930 100755
--- a/test/security/k8s/tools/dublin/setup_kubectl.sh
+++ b/test/security/k8s/tools/dublin/setup_kubectl.sh
@@ -17,7 +17,9 @@
#
# Constants
+BASHRC='.bashrc'
BASH_ALIASES='.bash_aliases'
+USE_ONAP_ALIAS='useonap'
DEFAULT_RKE_CONFIG='kube_config_cluster.yml'
DEFAULT_KUBE_DIR='.kube'
@@ -31,11 +33,20 @@ KUBE_CONFIG="${3:-$DEFAULT_KUBE_CONFIG}"
KUBE_CONTEXT="${4:-$DEFAULT_KUBE_CONTEXT}"
USE_ONAP="f() { export KUBECONFIG=${KUBE_DIR}/${KUBE_CONFIG}; kubectl config use-context ${KUBE_CONTEXT}; }; f"
+USE_ONAP_CONFIG="$(cat<<CONFIG
+
+# Use ONAP context for kubectl utility (defined in ${HOME}/${BASH_ALIASES})
+${USE_ONAP_ALIAS}
+CONFIG
+)"
# Prerequistes
mkdir -p "$KUBE_DIR"
-echo "alias useonap='${USE_ONAP}'" >> "${HOME}/${BASH_ALIASES}"
+echo "alias ${USE_ONAP_ALIAS}='${USE_ONAP}'" >> "${HOME}/${BASH_ALIASES}"
# Setup
cp "$RKE_CONFIG" "${KUBE_DIR}/${KUBE_CONFIG}"
+
+# Post-setup
+echo "$USE_ONAP_CONFIG" >> "${HOME}/${BASHRC}"