-
-
Save rvennam/8ea62f0929c5ddb99ce3ff010e39b7d9 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 | |
# IBM Cloud Kubernetes Service cluster config dir | |
clustersdir=~/.bluemix/plugins/container-service/clusters | |
#Produce a Kubernetes merged config string to be used with the KUBECONF environment variable. | |
# CHANGE VALUE | |
# Note the value is the IBM ID used to log into ibmcloud. This is the same | |
# value that appears in the downloaded IKS cluster config files for the | |
# context user field. | |
username="rvennam@us.ibm.com" #set to IBM ID used with ibmcloud login | |
mergedconfig="$HOME/.kube/config" | |
while IFS= read -r -d '' file | |
do | |
clustername=$(awk '/current-context/{print $2}' < $file) | |
sed -i.bak "/$clustername-$username/!s/$username/$clustername-$username/g" $file && rm $file.bak | |
mergedconfig="$mergedconfig:$file" | |
done < <(find $clustersdir -type f -name "*.yml" -print0) | |
echo $mergedconfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment