File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44NONOK=1
55UNKNOWN=2
66
7- export $( cat /run/metadata/coreos | xargs)
7+ # Get instance ID from Kubernetes node providerID
8+ if [ -z " ${NODE_NAME} " ]; then
9+ exit $UNKNOWN
10+ fi
11+
12+ provider_id=" $( curl -s -H " Authorization: Bearer $( cat /var/run/secrets/kubernetes.io/serviceaccount/token) " \
13+ --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
14+ " https://${KUBERNETES_SERVICE_HOST} :${KUBERNETES_SERVICE_PORT} /api/v1/nodes/${NODE_NAME} " \
15+ 2> /dev/null | jq -r ' .spec.providerID' ) "
816
9- instance_id=" ${COREOS_EC2_INSTANCE_ID} "
17+ if [ -z " ${provider_id} " ]; then
18+ exit $UNKNOWN
19+ fi
20+
21+ # Extract instance ID from providerID (format: aws:///region/instance-id)
22+ instance_id=" $( echo " ${provider_id} " | awk -F' /' ' {print $NF}' ) "
23+
24+ if [ -z " ${instance_id} " ]; then
25+ exit $UNKNOWN
26+ fi
1027
1128instances=" $( aws autoscaling describe-auto-scaling-instances --instance-ids " ${instance_id} " ) "
1229
You can’t perform that action at this time.
0 commit comments