Skip to content

Commit

Permalink
docs: adapt to new commands
Browse files Browse the repository at this point in the history
  • Loading branch information
davlgd committed Jan 10, 2025
1 parent 0c9ae96 commit 0b255eb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 60 deletions.
7 changes: 3 additions & 4 deletions bin/clever.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,10 @@ async function run () {
}, makeDefault.makeDefault);

// NETWORK GROUP COMMANDS
const ngCreateExternalPeerCommand = cliparse.command('external-peer', {
/* const ngCreateExternalPeerCommand = cliparse.command('external-peer', {
description: 'Create an external peer in a Network Group',
args: [args.ngRessourceIdOrLabel, args.publicKey, args.ngIdOrLabel],
}, ng.createExternalPeer);
}, ng.createExternalPeer); */
const ngDeleteExternalPeerCommand = cliparse.command('external-peer', {
description: 'Delete an external peer from a Network Group',
args: [args.ngRessourceIdOrLabel, args.ngIdOrLabel],
Expand All @@ -813,7 +813,7 @@ async function run () {
description: 'Create a Network Group',
args: [args.ngLabel],
privateOptions: [opts.ngMembersIds, opts.ngDescription, opts.optTags],
commands: [ngCreateExternalPeerCommand],
// commands: [ngCreateExternalPeerCommand],
}, ng.createNg);
const ngDeleteCommand = cliparse.command('delete', {
description: 'Delete a Network Group',
Expand All @@ -823,7 +823,6 @@ async function run () {
const ngLinkCommand = cliparse.command('link', {
description: 'Link a member or an external peer to a Network Group',
args: [args.ngRessourceIdOrLabel, args.ngIdOrLabel],
options: [opts.ngMemberLabel],
}, ng.linkToNg);
const ngUnlinkCommand = cliparse.command('unlink', {
description: 'Unlink a member or an external peer from a Network Group',
Expand Down
77 changes: 35 additions & 42 deletions docs/ng.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Network Groups (NG) are a way to create a private secure network between resources inside Clever Cloud infrastructure, using [Wireguard](https://www.wireguard.com/). It's also possible to connect external resources to a Network Group. There are three components to this feature:

* Network Group: A group of resources that can communicate with each through an encrypted tunnel
* Member: A resource that can be part of a Network Group (`application`, `addon` or `external`)
* Network Group: a group of resources that can communicate with each through an encrypted tunnel
* Member: a resource that can be part of a Network Group (`application`, `addon` or `external`)
* Peer: Instance of a resource connected to a Network Group (can be `external`)

A Network Group is defined by an ID (`ngId`) and a `label`. It can be completed by a `description` and `tags`.
Expand All @@ -20,22 +20,20 @@ When you create a Network Group, a Wireguard configuration is generated with a c
When an application connects to a Network Group, you can reach it on any port inside a NG through its domain name. Any instance of this application is a peer, you can reach independently through an IP (from the attributed CIDR). It works the same way for add-ons and external resources. During alpha testing phase, only applications are supported.

> [!TIP]
> A Network Group member domain name is composed this way: `<memberID>.m.<ngID>.ng.clever-cloud.com`
> A Network Group member domain name is composed this way: `<memberID>.m.<ngID>.ng-cc.cloud`
## Prerequisites

To use Network Groups, you need [Clever Tools installed](/docs/setup-systems.md) in a test version or higher than `4.0.0`. You can check your version with the following command:
To use Network Groups, you need [Clever Tools installed](/docs/setup-systems.md) in a test version or higher than `3.10`. You can check your version with the following command:

```
clever version
```

To activate the Network Groups feature, you need to create a `clever-tools-features.json` file in your `~/.config/clever-cloud/` directory with the following content:
Activate `ng` feature flag to activate network groups:

```json
{
"ng": true
}
```
clever features enable ng
```

Then, check it works with the following command:
Expand All @@ -57,31 +55,15 @@ clever ng create myNG
You can create it declaring its members:

```
clever ng create myNG --members-ids appId1,appId2
clever ng create myNG --members-ids appId,addonId,externalId
```

You can add a description, tags and ask for a JSON output (`--format` or `-F`):
You can add a description and tags:

```
clever ng create myNG --description "My first NG" --tags test,ng -F json
```

## List Network Groups

Once created, you can list your Network Groups:

```
clever ng list
┌─────────┬───────-┬─────────-─┬───────────────┬─────────────────┬─────────┬───────┐
| (index) │ id │ label │ networkIp │ lastAllocatedIp │ members │ peers │
├─────────┼────────┼───────────┼───────────────┼─────────────────┼─────────┼───────┤
│ 0 │ 'ngId' │ 'ngLabel' │ '10.x.y.z/16' │ '10.x.y.z' │ X │ Y │
└─────────┴────────┴──────────-┴───────────────┴─────────────────┴─────────┴───────┘
clever ng create myNG --description "My first NG" --tags test,ng
```

A `json` formatted output is available.

## Delete Network Groups

You can delete a Network Group through its ID or label:
Expand All @@ -91,35 +73,46 @@ clever ng delete ngId
clever ng delete ngLabel
```

## Manage members of a Network Group
## List Network Groups

To add an application to a Network Group (a `label` is optional):
Once created, you can list your Network Groups:

```
clever ng members add ngId appId
clever ng members add ngId appId --label 'member label'
clever ng
┌─────────┬───────-┬─────────-─┬───────────────┬─────────┬───────┐
| (index) │ ID │ Label │ Network CIDR │ Members │ Peers │
├─────────┼────────┼───────────┼───────────────┼─────────┼───────┤
│ 0 │ 'ngId' │ 'ngLabel' │ '10.x.y.z/16' │ X │ Y │
└─────────┴────────┴──────────-┴───────────────┴─────────┴───────┘
```

To get information about members (a `json` formatted output is available):
A `json` formatted output is available with the `--format/-F json` option.

## (Un)Link a resource to a Network Group

To (un)link an application, add-on or external peer to a Network Group:

```
clever ng members list ngId_or_ngLabel
clever ng members get ngId_or_ngLabel memberId
clever ng members link appId ngIdOrLabel
clever ng members unlink addonId ngIdorLabel
```

To delete a member from a Network Group:
## Get information of a Network Group, a member or a peer

To get information about a network group or a resource (a `json` formatted output is available):

```
clever ng members remove ngId_or_ngLabel memberId
clever ng get ngIdOrLabel -F json
clever ng get ressourceIdOrName
```

## Manage peers of a Network Group
## Get Wireguard configuration of a Peer

To get information about peers (a `json` formatted output is available):
To get the Wireguard configuration of a peer (a `json` formatted output is available):

```
clever ng peers list ngId_or_ngLabel
clever ng peers get ngId_or_ngLabel peerId
clever ng get-config peerIdOrLabel
```

## Demos & examples
Expand All @@ -128,4 +121,4 @@ You can find ready to deploy projects using Network Groups in the following repo

- XXX

Create your own and let us know!
Create your own and [let us know](https://github.com/CleverCloud/Community/discussions/categories/network-groups)!
4 changes: 2 additions & 2 deletions src/commands/ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function deleteNg (params) {
/** Create an external peer in a Network Group
* @param {Object} params
* @param {string} params.args[0] External peer ID or label
* @param {string} params.args[1] Wireguard® public key
* @param {string} params.args[1] Wireguard public key
* @param {string} params.args[2] Network Group ID or label
* @param {string} params.options.org Organisation ID or name
*/
Expand All @@ -50,7 +50,7 @@ export async function createExternalPeer (params) {
}

if (!publicKey) {
throw new Error('A Wireguard® public key is required');
throw new Error('A Wireguard public key is required');
}
await NGRessources.createExternalPeerWithParent(ngIdOrLabel, idOrLabel.ngRessourceLabel, publicKey, org);
Logger.println(`${colors.bold.green('✓')} External peer ${colors.green(idOrLabel.ngRessourceLabel)} successfully created in Network Group ${colors.green(ngIdOrLabel.ngLabel || ngIdOrLabel.ngId)}`);
Expand Down
27 changes: 15 additions & 12 deletions src/experimental-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ Learn more about Materia KV: https://www.clever-cloud.com/developers/doc/addons/
},
ng: {
status: 'beta',
description: 'Manage Network Groups to link applications, add-ons, external peers through a Wireguard® network',
description: 'Manage Network Groups to link applications, add-ons, external peers through a Wireguard network',
instructions: `
- Create a Network Group:
clever ng create myNG
- Create a Network Group with members (application, add-on, external):
clever ng create myNG --members-ids appId1,appId2
- Add an application to an existing Network Group:
clever ng add-app myNG myApp
- List Network Groups:
clever ng list
- List Network Groups members:
clever ng members list myNG
- List Network Groups peers (instances of a member):
clever ng peers list myNG
clever ng
- Delete a Network Group:
clever ng delete myNG
Learn more about Network Groups: https://github.com/CleverCloud/clever-tools/tree/master/docs/ng.md`,
- Create a Network Group with members (application, add-on, external):
clever ng create myNG --members-ids appId1,appId2
- (Un)Link an application to an existing Network Group:
clever ng link appId myNG
clever ng unlink appId myNG
- Get the Wireguard configuration of a peer:
clever ng get-config peerIdOrLabel
- Get details about a Network Group, a member or a peer:
clever ng get myNg
clever ng get appId
clever ng get peerId
clever ng get memberLabel
Learn more about Network Groups: https://github.com/CleverCloud/clever-tools/blob/davlgd-new-ng/docs/ng.md`,
},
};

0 comments on commit 0b255eb

Please sign in to comment.