-
Notifications
You must be signed in to change notification settings - Fork 5
/
appstudio_kubeconfig.sh
executable file
·55 lines (48 loc) · 1.36 KB
/
appstudio_kubeconfig.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
RED='\033[0;31m'
NC='\033[0m' # No Color
NAMESPACE=$1
if [ -z "$1" ]; then
echo "${RED}Please provide your namespace as argument to the command: '$0 <your_namespace>'\n"
exit 1
fi
if ! command kubectl konfig &> /dev/null; then
echo "konfig could not be found. Please install it: https://github.com/corneliusweig/konfig"
exit 1
fi
if ! command -v kubectl &> /dev/null; then
echo "kubectl could not be found. Please install it: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/"
exit 1
fi
cat <<EOF > appstudio.cfg
apiVersion: v1
clusters:
- cluster:
server: https://api-toolchain-host-operator.apps.stone-prd-host1.wdlc.p1.openshiftapps.com/workspaces/$NAMESPACE
name: appstudio-$NAMESPACE
contexts:
- context:
cluster: appstudio-$NAMESPACE
namespace: $NAMESPACE-tenant
user: oidc
name: appstudio-$NAMESPACE
current-context: appstudio-$NAMESPACE
kind: Config
preferences: {}
users:
- name: oidc
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- oidc-login
- get-token
- --oidc-issuer-url=https://sso.redhat.com/auth/realms/redhat-external
- --oidc-client-id=rhoas-cli-prod
command: kubectl
env: null
interactiveMode: IfAvailable
provideClusterInfo: false
EOF
#cat appstudio.cfg
kubectl konfig import --save appstudio.cfg
kubectl ctx appstudio-$NAMESPACE