Last active
December 29, 2018 19:01
-
-
Save NPoi/d3c4297e380898892b5983c890e7b680 to your computer and use it in GitHub Desktop.
AKSのノードにSSHキーを追加するためのスクリプト
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
#!/usr/bin/env bash | |
RESOURCE_GROUP="$1" | |
CLUSTER_NAME="$2" | |
PUB_KEY_PATH="$3" | |
NODE_RESOURCE_GROUP=$(az aks show --resource-group "$RESOURCE_GROUP" --name "$CLUSTER_NAME" --query nodeResourceGroup -o tsv) | |
VM_LIST=$(az vm list --resource-group "$NODE_RESOURCE_GROUP" -o table | grep $RESOURCE_GROUP | tr -s ' ' ' ' | cut -f1 -d" ") | |
for VM in $VM_LIST | |
do | |
az vm user update \ | |
--resource-group "$NODE_RESOURCE_GROUP" \ | |
--name "$VM" \ | |
--username azureuser \ | |
--ssh-key-value "$PUB_KEY_PATH" | |
done | |
IP_ADRESSES=$(az vm list-ip-addresses --resource-group "$NODE_RESOURCE_GROUP" -o table | sed -e '1,2d' | tr -s ' ' ' ' | cut -f2 -d" " | cut -f1 -d",") | |
echo $IP_ADRESSES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment