Cockpit CLI is a command-line interface (CLI) tool designed for managing various resources within the Cockpit project. This CLI facilitates user registration, node management, labeling, schema validation, configuration management, and more. The goal of this tool is to provide an easy-to-use and maintainable interface for interacting with the Cockpit project's resources.
- User Management: Register and login to the system.
- Node Management: List, query, and claim nodes based on specific criteria.
- Label Management: Add, update, and delete labels for nodes.
- Schema Management: Create, retrieve, validate, and delete schemas.
- Configuration Management: Manage both config groups and standalone configs, including placing, listing, and diffing configurations.
Ensure you have the following installed:
Additionally, you need to clone and set up the tools repository from https://github.com/c12s/tools, which includes scripts to pull all other repositories and start Docker containers.
-
Clone the tools repository:
git clone https://github.com/c12s/tools.git
-
Navigate to the tools directory and follow the setup instructions in the README.md file of the tools repository to pull all necessary repositories and start Docker containers:
cd tools ./install.sh ./start.sh
or for Windows:
./start-windows.sh
-
Clone the cockpit repository in the same parent directory where the tools repository is located:
cd .. git clone https://github.com/bunjo01/cockpit.git
-
Navigate to the cockpit project directory:
cd cockpit
-
Build the CLI:
go build -o cockpit
-
Add the executable to your PATH:
-
On Linux/macOS:
export PATH=$PATH:$(pwd)
-
On Windows (Command Prompt):
set PATH=%PATH%;%cd%
-
On Windows (PowerShell):
$env:PATH += ";$PWD"
Register a new user.
-
Command: cockpit register
-
Options:
- --email: Email address of the user.
- --name: Name of the user.
- --org: Organization of the user.
- --surname: Surname of the user.
- --username: Username of the user.
-
Example:
cockpit register --email '[email protected]' --name 'name' --org 'c12s' --surname 'surname' --username 'user'
Login with an existing user.
-
Command: cockpit login
-
Options:
- --username: Username of the user.
-
Example:
cockpit login --username 'user'
List all nodes.
-
Command: cockpit list nodes
-
Options:
- --query: Query to filter nodes.
-
Example:
cockpit list nodes cockpit list nodes --query 'memory-totalGB > 2'
Claim nodes based on specific criteria.
-
Command: cockpit claim nodes
-
Options:
- --org: Organization.
- --query: Query to filter nodes.
-
Example:
cockpit claim nodes --org 'c12s' --query 'memory-totalGB > 2'
List nodes allocated to an organization.
-
Command: cockpit list nodes allocated
-
Options:
- --org: Organization.
- --query: Query to filter nodes.
-
Example:
cockpit list nodes allocated --org 'c12s' cockpit list nodes allocated --org 'c12s' --query 'memory-totalGB > 2'
Create relations between entities.
-
Command: cockpit create relations
-
Options:
- --ids: IDs of the entities.
- --kinds: Kinds of the entities.
-
Example:
cockpit create relations --ids 'c12s|dev' --kinds 'org|namespace'
Add a label to a node.
-
Command: cockpit put label
-
Options:
- --org: Organization of the node.
- --node-id: ID of the node.
- --key: Key of the label.
- --value: Value of the label.
-
Example:
cockpit put label --org 'c12s' --node-id 'nodeId' --key 'newlabel' --value '25.00'
Delete a label from a node.
-
Command: cockpit delete label
-
Options:
- --org: Organization of the node.
- --nodeId: ID of the node.
- --key: Key of the label.
-
Example:
cockpit delete label --org 'c12s' --node-id 'nodeId' --key 'newlabel'
Create a new schema.
-
Command: cockpit create schema
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --schema-name: Name of the schema.
- --version: Version of the schema.
- --path: Path to the schema file.
-
Example:
cockpit create schema --org 'c12s' --namespace 'default' --schema-name 'schema' --version 'v1.0.0' --path 'request/schema/create-schema.yaml'
Retrieve schema version details.
-
Command: cockpit get schema version
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --schema: Name of the schema.
-
Example:
cockpit get schema version --org 'c12s' --namespace 'default' --schema-name 'schema'
Retrieve a specific schema.
-
Command: cockpit get schema
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --schema: Name of the schema.
- --version: Version of the schema.
-
Example:
cockpit get schema --org 'c12s' --namespace 'default' --schema-name 'schema' --version 'v1.0.0'
Validate a schema.
-
Command: cockpit validate schema
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --schema: Name of the schema.
- --version: Version of the schema.
- --path: Path to the validation file.
-
Example:
cockpit validate schema --org 'c12s' --namespace 'default' --schema-name 'schema' --version 'v1.0.0' --path 'request/schema/validate-schema.yaml'
Delete a schema.
-
Command: cockpit delete schema
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --schema: Name of the schema.
- --version: Version of the schema.
-
Example:
cockpit delete schema --org 'c12s' --namespace 'default' --schema-name 'schema' --version 'v1.0.0'
Add a configuration group.
-
Command: cockpit put config group
-
Options:
- --path: Path to the config group file.
-
Example:
cockpit put config group --path 'request/config-group/create-config-group.yaml'
Retrieve a configuration group.
-
Command: cockpit get config group
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --name: Name of the config group.
- --version: Version of the config group.
- --output: Output format (json, yaml).
-
Example:
cockpit get config group --org 'c12s' --namespace 'default' --name 'app_config' --version 'v1.0.1'
List all configuration groups.
-
Command: cockpit list config group
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --output: Output format (json, yaml).
-
Example:
cockpit list config group --org 'c12s' --namespace 'default'
Compare differences between configuration groups.
-
Command: cockpit diff config group
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --names: Names of the config groups.
- --versions: Versions of the config groups.
- --output: Output format (json, yaml).
-
Example:
cockpit diff config group --org 'c12s' --namespace 'default' --names 'app_config|app_config' --versions 'v1.0.0|v1.0.1' cockpit diff config group --org 'c12s' --namespace 'default' --names 'app_config' --versions 'v1.0.0|v1.0.1' cockpit diff config group --org 'c12s' --namespace 'default' --names 'app_config|app_config' --versions 'v1.0.0'
Place a configuration group.
-
Command: cockpit place config group
-
Options:
- --path: Path to the placement file.
-
Example:
cockpit place config group --path 'request/config-group/create-config-group-placements.yaml'
List all placements of a configuration group.
-
Command: cockpit list config group placements
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --name: Name of the config group.
- --version: Version of the config group.
-
Example:
cockpit list config group placements --org 'c12s' --namespace 'default' --name 'app_config' --version 'v1.0.0'
Delete a configuration group.
-
Command: cockpit delete config group
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --name: Name of the config group.
- --version: Version of the config group.
- --output: Output format (json, yaml).
-
Example:
cockpit delete config group --org 'c12s' --namespace 'default' --name 'app_config' --version 'v1.0.1'
Add a standalone configuration.
-
Command: cockpit put standalone config
-
Options:
- --path: Path to the config file.
-
Example:
cockpit put standalone config --path 'request/standalone-config/create-standalone-config.json'
Retrieve a standalone configuration.
-
Command: cockpit get standalone config
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --name: Name of the config.
- --version: Version of the config.
- --output: Output format (json, yaml).
-
Example:
cockpit get standalone config --org 'c12s' --namespace 'default' --name 'db_config' --version 'v1.0.1'
List all standalone configurations.
-
Command: cockpit list standalone config
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --output: Output format (json, yaml).
-
Example:
cockpit list standalone config --org 'c12s' --namespace 'default'
Compare differences between standalone configurations.
-
Command: cockpit diff standalone config
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --names: Names of the configs.
- --versions: Versions of the configs.
- --output: Output format (json, yaml).
-
Example:
cockpit diff standalone config --org 'c12s' --namespace 'default' --names 'db_config|db_config' --versions 'v1.0.1|v1.0.0' cockpit diff standalone config --org 'c12s' --namespace 'default' --names 'db_config' --versions 'v1.0.1|v1.0.0' cockpit diff standalone config --org 'c12s' --namespace 'default' --names 'db_config|db_config' --versions 'v1.0.1'
Place a standalone configuration.
-
Command: cockpit place standalone config
-
Options:
- --path: Path to the placement file.
-
Example:
cockpit place standalone config --path 'request/standalone-config/create-standalone-config-placements.yaml'
List all placements of a standalone configuration.
-
Command: cockpit list standalone config placements
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --name: Name of the config.
- --version: Version of the config.
-
Example:
cockpit list standalone config placements --org 'c12s' --namespace 'default' --name 'db_config' --version 'v1.0.0'
Delete a standalone configuration.
-
Command: cockpit delete standalone config
-
Options:
- --org: Organization.
- --namespace: Namespace.
- --name: Name of the config.
- --version: Version of the config.
- --output: Output format (json, yaml).
-
Example:
cockpit delete standalone config --org 'c12s' --namespace 'default' --name 'db_config' --version 'v1.0.1'
Retrieve metrics for a specific node.
-
Command: cockpit get node metrics
-
Options:
- --node-id: Node ID (required).
- --all: Display all metrics (optional).
- --sort: Sort metrics by 'cpu', 'memory', 'disk', 'network receive', 'network transmit' or 'bandwidth'.
-
Example:
cockpit get node metrics --node-id 'nodeID' cockpit get node metrics --node-id 'nodeID' --all-services --sort 'memory'
Contributions are welcome! Please follow these steps to contribute:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/YourFeature
-
Make your changes.
-
Commit your changes:
git commit -m 'Add new feature'
-
Push to the branch:
git push origin feature/YourFeature
-
Open a pull request and describe your changes.
This project is licensed under the MIT License. See the LICENSE file for more information.