assign_ip_to_node 469 B

123456789101112131415
  1. #!/bin/bash
  2. NODE=$1
  3. IP=$2
  4. # localhost:8080 is the endpoint created by kubectl proxy --port=8080
  5. API_ENDPOINT=${3-localhost:8080}
  6. [[ -z "$IP" ]] && echo "Usage: $0 <NODE> <IP> [API_ENDPOINT]"
  7. curl -k -v -XPATCH \
  8. -H "Accept: application/json" \
  9. -H "Content-Type: application/json-patch+json" \
  10. http://${API_ENDPOINT}/api/v1/nodes/$NODE/status \
  11. --data '[{"op":"add","path":"/status/addresses/-", "value": {"type": "ExternalIP", "address": "'"$IP"'"} }]'