通过 CURL 将成员添加到 F5(BigIP) 池

Add members to F5(BigIP) pool via CURL

我正在尝试使用以下 CURL 将成员添加到 F5。它们都失败了,错误复制如下

curl -u<username>:<password> -sk -XPOST -H "Content-type: application/json" -d '{"state": "present", "name": "myapp01", "host": "192.168.98.73", "port": "80", "pool": "deploypool", "partition": "Common", "monitor_state": "yes", "description": "First microservice", "connection_limit": 0, "rate_limit": 0, "ratio": 1}' 'https://192.168.60.50/mgmt/tm/ltm/pool/deploypool/members'
{"code":400,"message":"Found invalid JSON body in the request.","errorStack":[],"apiError":1}


curl -u<username>:<password> -sk -XPOST -H "Content-type: application/json" -d '{"members":[{"state: "present", "name": "myapp01", "host": "192.168.98.73", "port": "80", "pool": "deploypool", "partition": "Common", "monitor_state": "yes", "description": "First microservice", "connection_limit": 0, "rate_limit": 0, "ratio": 1}]}' 'https://192.168.60.50/mgmt/tm/ltm/pool/deploypool'
{"code":400,"message":"Found invalid JSON body in the request.","errorStack":[],"apiError":1}

您缺少状态的结束引号。任何时候你得到这个错误,把你的 json 扔进 linter 来找到你的问题,比如 https://jsonlint.com/.

列出节点和池成员信息

curl -snkw"\n" -H "Content-Type: application/json" -X GET https://<IP_ADDR>/mgmt/tm/ltm/pool/~Common~<pool_name>/members
curl -snkw"\n" -H "Content-Type: application/json" -X GET https://<IP_ADDR>/mgmt/tm/ltm/node

添加池成员

curl -snkw\n -H Content-Type: application/json -X POST https://<IP_ADDR>/mgmt/tm/ltm/pool/~Common~<pool_name>/members -d {"partition":"Common","name":"<pool_member_name>:8080","address":"<IP_ADDR>"}

要删除池成员,请删除池成员和节点

curl -snkw"\n" -H "Content-Type: application/json" -X DELETE https://<IP_ADDR>/mgmt/tm/ltm/pool/~Common~<pool_name>/members/<pool_member_name>:8080
curl -snkw"\n" -H "Content-Type: application/json" -X DELETE https://<IP_ADDR>/mgmt/tm/ltm/node/<pool_member_name>

希望对有需要的人有所帮助