civo / cli

Our Command Line Interface (CLI) for interacting with your Civo resources
Apache License 2.0
173 stars 86 forks source link

No docs exist for LB #208

Open haardikdharma10 opened 2 years ago

haardikdharma10 commented 2 years ago

Currently, in CLI repo's README, no docs are mentioned for load balancers and hence https://github.com/civo/cli/blob/master/README.md#load-balancers doesn't redirect to the desired heading as it doesn't exist.

ghost commented 2 years ago

There's also no API documentation yet either, but there is Go client tooling already.

This is pretty much what the documentation would look like right now if it was added. (click to expand)

## Load Balancers #### Listing Load Balancers To list all the load balancers you can run `civo loadbalancer ls` ```sh [protosam@nullhost]$ civo loadbalancer ls +--------------------------------------+----------------------------------+-------------+--------------+-----------+----------------------------------------------------+ | ID | Name | Algorithm | Public IP | State | Backends | +--------------------------------------+----------------------------------+-------------+--------------+-----------+----------------------------------------------------+ | 30005345-35z1-4f4b-8a4d-3a0691958d4c | clusterName-svcNamespace-svcName | round_robin | XXX.X.XXX.XX | available | 192.168.1.4, 192.168.1.2, 192.168.1.4, 192.168.1.2 | +--------------------------------------+----------------------------------+-------------+--------------+-----------+----------------------------------------------------+ ``` Running `civo loadbalancer show ` will show you the requested load balancer details. ```sh [protosam@nullhost]$ civo loadbalancer show 30005345-35z1-4f4b-8a4d-3a0691958d4c +--------------------------------------+----------------------------------+-------------+--------------+-----------+--------------------------------------------------+----------------------------------------------------+ | ID | Name | Algorithm | Public IP | State | DNS Entry | Backends | +--------------------------------------+----------------------------------+-------------+--------------+-----------+--------------------------------------------------+----------------------------------------------------+ | 30005345-35z1-4f4b-8a4d-3a0691958d4c | clusterName-svcNamespace-svcName | round_robin | XXX.X.XXX.XX | available | 30005345-35z1-4f4b-8a4d-3a0691958d4c.lb.civo.com | 192.168.1.4, 192.168.1.2, 192.168.1.4, 192.168.1.2 | +--------------------------------------+----------------------------------+-------------+--------------+-----------+--------------------------------------------------+----------------------------------------------------+ ```

If you need to know how to use the API in the meantime, here's some curl examples. (click to expand)

## List Load Balancers ```sh [protosam@nullhost]$ curl -s -H "Authorization: bearer " https://api.civo.com/v2/loadbalancers/ | jq ``` ## Show Load Balancer by ID ```sh [protosam@nullhost]$ curl -s -H "Authorization: bearer " https://api.civo.com/v2/loadbalancers/ | jq ``` ## Create Load Balancer ```sh [protosam@nullhost]$ curl -X POST -H "Authorization: bearer " https://api.civo.com/v2/loadbalancers \ -H 'Content-Type: application/json' \ -d '{ "name": "somelb", "algorithm": "round_robin", "backends":[ { "ip": "192.168.1.4", "protocol": "TCP", "source_port": 80, "target_port": 31961 } ] }' {"id":"403e7bbf-7bb2-43e5-861d-6668f0d955e0","name":"somelb","algorithm":"round_robin","backends":[{"ip":"192.168.1.4","protocol":"TCP","source_port":80,"target_port":31961}],"public_ip":"","private_ip":"","firewall_id":"9668d6a5-39fc-4b61-a8a6-a5c491580ea0","state":""} [protosam@nullhost]$ civo loadbalancers show 403e7bbf-7bb2-43e5-861d-6668f0d955e0 +--------------------------------------+--------+-------------+---------------+-----------+--------------------------------------------------+-------------+ | ID | Name | Algorithm | Public IP | State | DNS Entry | Backends | +--------------------------------------+--------+-------------+---------------+-----------+--------------------------------------------------+-------------+ | 403e7bbf-7bb2-43e5-861d-6668f0d955e0 | somelb | round_robin | 212.2.247.249 | available | 403e7bbf-7bb2-43e5-861d-6668f0d955e0.lb.civo.com | 192.168.1.4 | +--------------------------------------+--------+-------------+---------------+-----------+--------------------------------------------------+-------------+ ``` ## Update a Load Balancer ```sh [protosam@nullhost]$ curl -X PUT -H "Authorization: bearer " https://api.civo.com/v2/loadbalancers/403e7bbf-7bb2-43e5-861d-6668f0d955e0 \ -H 'Content-Type: application/json' \ -d '{ "algorithm": "round_robin", "backends":[ { "ip": "192.168.1.1", "protocol": "TCP", "source_port": 80, "target_port": 31961 } ] }' {"id":"403e7bbf-7bb2-43e5-861d-6668f0d955e0","name":"somelb","algorithm":"round_robin","backends":[{"ip":"192.168.1.1","protocol":"TCP","source_port":80,"target_port":31961}],"public_ip":"212.2.247.249","private_ip":"192.168.1.3","firewall_id":"9668d6a5-39fc-4b61-a8a6-a5c491580ea0","state":"available"} [protosam@nullhost]$ civo loadbalancers show 403e7bbf-7bb2-43e5-861d-6668f0d955e0 +--------------------------------------+--------+-------------+---------------+-----------+--------------------------------------------------+-------------+ | ID | Name | Algorithm | Public IP | State | DNS Entry | Backends | +--------------------------------------+--------+-------------+---------------+-----------+--------------------------------------------------+-------------+ | 403e7bbf-7bb2-43e5-861d-6668f0d955e0 | somelb | round_robin | 212.2.247.249 | available | 403e7bbf-7bb2-43e5-861d-6668f0d955e0.lb.civo.com | 192.168.1.1 | +--------------------------------------+--------+-------------+---------------+-----------+--------------------------------------------------+-------------+ ``` ## Delete a Load Balancer ```sh [protosam@nullhost]$ curl -X DELETE -H "Authorization: bearer " https://api.civo.com/v2/loadbalancers/403e7bbf-7bb2-43e5-861d-6668f0d955e0 {"result":"success"} ```

Edit: Turns out there are source files for the create, update, and remove features.

haardikdharma10 commented 2 years ago

Thanks for the feedback @protosam! Will raise this with the team and the docs should be updated soon 😄

Ujjwal2421 commented 2 years ago

@haardikdharma10 I made a PR adding the docs file for Load Balancer #222.

haardikdharma10 commented 2 years ago

Thanks @Ujjwal2421. Commented 😄