Verified Commit 33497f1c authored by Xueshan Feng's avatar Xueshan Feng
Browse files

Update recyle-node to use kubectl get node to get instance_id.

parent 95a7fe96
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -61,14 +61,14 @@ uncordon: ## Enable scheduling on a node
	done

.PHONY: cluster-upgrade-nodes
recycle-node: NODES = $(shell kubectl get node -o json  | jq -r '.items[].metadata.name')
recycle-node: NODES = $$(kubectl get node -o json  | jq -r '.items[].metadata.name')
recycle-node: ## Replace node with a new instance
	kubectl get nodes
	@for i in ${NODES}; do \
		echo "" ; \
		echo "Recycle $$i?" ; \
		confirm 2> /dev/null || continue ; \
		external_id=`kubectl describe node $$i |grep ExternalID | awk '{print $$2}'` ; \
		instance_id=`kubectl get node $$i -o json | jq -r '.spec.externalID'` ; \
		aws autoscaling terminate-instance-in-auto-scaling-group  \
		  --instance-id $$external_id --no-should-decrement-desired-capacity ; \
		  --instance-id $$instance_id --no-should-decrement-desired-capacity ; \
	done