blob: a50c23656b2d8b0e4fc643eee7c1eeafcf35af41 [file] [log] [blame]
Pawel Wieczorek2d13ea82019-07-29 13:17:51 +02001#!/usr/bin/env bash
2
3#
4# @file test/security/k8s/tools/dublin/setup_kubectl.sh
5# @author Pawel Wieczorek <p.wieczorek2@samsung.com>
6# @brief Utility for setting up kubectl tool for Dublin cluster
7#
8
9# Dependencies:
10# coreutils
11#
12# Privileges:
13# Script expects to be run with administrative privileges for accessing /usr/local/bin
14#
15# Usage:
16# # ./setup_kubectl.sh [RKE_CONFIG [KUBE_DIR [KUBE_CONFIG [KUBE_CONTEXT]]]]
17#
18
19# Constants
20BASH_ALIASES='.bash_aliases'
21
22DEFAULT_RKE_CONFIG='kube_config_cluster.yml'
23DEFAULT_KUBE_DIR='.kube'
24DEFAULT_KUBE_CONFIG='config.onap'
25DEFAULT_KUBE_CONTEXT='onap'
26
27# Variables
28RKE_CONFIG="${1:-$DEFAULT_RKE_CONFIG}"
29KUBE_DIR="${2:-${HOME}/${DEFAULT_KUBE_DIR}}"
30KUBE_CONFIG="${3:-$DEFAULT_KUBE_CONFIG}"
31KUBE_CONTEXT="${4:-$DEFAULT_KUBE_CONTEXT}"
32
33USE_ONAP="f() { export KUBECONFIG=${KUBE_DIR}/${KUBE_CONFIG}; kubectl config use-context ${KUBE_CONTEXT}; }; f"
34
35
36# Prerequistes
37mkdir -p "$KUBE_DIR"
38echo "alias useonap='${USE_ONAP}'" >> "${HOME}/${BASH_ALIASES}"
39
40# Setup
41cp "$RKE_CONFIG" "${KUBE_DIR}/${KUBE_CONFIG}"