mirror of
https://github.com/1Panel-dev/KubePi.git
synced 2025-09-26 19:31:15 +08:00
23 lines
485 B
Bash
Executable File
23 lines
485 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
arg1=$1
|
|
mkdir -p ~/.kube
|
|
code=`curl -w %{http_code} -s -o ~/.kube/config http://localhost/kubepi/api/v1/webkubectl/session?token=${arg1}`
|
|
|
|
if [[ $code -ne '200' ]];then
|
|
echo "download kubeconfig failed"
|
|
cat .kube/config
|
|
exit
|
|
fi
|
|
|
|
current_context=`kubectl config current-context`
|
|
username=${current_context%@*}
|
|
cluster=${current_context#*@}
|
|
|
|
echo "Welcome to kubepi"
|
|
echo "Current cluster is ${username}"
|
|
echo "Current user is ${cluster}"
|
|
|
|
exec /bin/bash
|