Created
July 12, 2019 04:59
-
-
Save cdoan1/99adc659234eaf7c561bfd787ee9f07d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HCURL=${1:-$HCURL} | |
HCUSER=${2:-$HCUSER} | |
HCPASS=${3:-$HCPASS} | |
MCURL=${4:-$MCURL} | |
MCUSER=${5:-$MCUSER} | |
MCPASS=${6:-$MCPASS} | |
# login to managed cluster | |
cloudctl login -a $MCURL -u $MCUSER -p $MCPASS -n kube-system | |
MCNAME=$(kubectl config current-context | sed 's/-context//') | |
kubectl config delete-context $MCNAME | |
kubectl config get-contexts | grep '*' | awk '{print $2}'| xargs -I % kubectl config rename-context % $MCNAME | |
kubectl config view --minify=true --context $MCNAME > kubeconfig | |
sed -i.bak 's/^ certificate-authority:.*/ insecure-skip-tls-verify: true/' kubeconfig | |
cloudctl logout | |
# login to hub | |
cloudctl login -a $HCURL -u $HCUSER -p $HCPASS -n kube-system | |
cloudctl mc cluster template $MCNAME -n $MCNAME > cluster-import.yaml | |
cloudctl mc cluster import -f cluster-import.yaml --cluster-kubeconfig kubeconfig | |
cloudctl logout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment