AWS示例
Last updated
Was this helpful?
Was this helpful?
#!/bin/bash
EC2_REGION=`curl -s http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}'`
INSTANCE_ID="`curl -s http://169.254.169.254/latest/meta-data/instance-id`"
aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" --region $EC2_REGION --output=text |grep spotmax:group &>/dev/null
if [ $? -ne 0 ] ;then
exit 1
fi
MOUNT_PATH=$1
OLD_DEV=`lsblk|grep $MOUNT_PATH|awk '{print $1}'`
DEV_TYPE=`lsblk|grep $MOUNT_PATH|awk '{print $6}'`
while true
do
NEW_DEV=`lsblk|grep $DEV_TYPE |grep -Ev "xvda|${OLD_DEV}|nvme0n1"|awk '{print $1}'`
if [ ! -z $NEW_DEV ] ;then
umount $MOUNT_PATH &>/dev/null
sleep 1
mount /dev/$NEW_DEV $MOUNT_PATH && break
else
sleep 3
fi
done#######以下命令在eks master上执行###########
kubectl describe configmap -n kube-system aws-auth ###查看当前eks授权情况
kubectl edit -n kube-system configmap/aws-auth ###编辑授权表,添加权限
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
mapRoles: |
- groups:
- system:masters
rolearn: arn:aws:iam::<your aws account>:role/max_group_role
username: system:node:{{EC2PrivateDNSName}}
######以下命令在maxgroup上执行##########
aws eks --region <region-code> update-kubeconfig --name <cluster_name> --kubeconfig /data/spotmax/k8sconfig