@serve.zone/cli 5.0.3 β†’ 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +4 -4
  2. package/readme.md +283 -187
  3. package/ts_cliclient/readme.md +283 -187
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serve.zone/cli",
3
- "version": "5.0.3",
3
+ "version": "5.3.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "exports": {
@@ -9,10 +9,10 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@serve.zone/api": "5.0.3",
13
- "@serve.zone/interfaces": "5.0.3",
12
+ "@serve.zone/api": "5.3.0",
13
+ "@serve.zone/interfaces": "5.3.0",
14
14
  "@push.rocks/projectinfo": "^5.0.1",
15
- "@push.rocks/qenv": "^6.1.0",
15
+ "@push.rocks/qenv": "^6.1.3",
16
16
  "@push.rocks/smartcli": "^4.0.11"
17
17
  },
18
18
  "devDependencies": {
package/readme.md CHANGED
@@ -1,246 +1,342 @@
1
- # @serve.zone/cli
1
+ # @serve.zone/cli πŸš€
2
2
 
3
- A comprehensive command-line interface (CLI) tool for managing multi-cloud environments, leveraging the features of the @serve.zone/cloudly platform. This CLI is crafted to facilitate seamless interactions with complex cloud configurations and deployments, utilizing Docker Swarmkit orchestration.
3
+ **Command-line interface for Cloudly.** Manage your multi-cloud infrastructure from the terminal with powerful, intuitive commands.
4
4
 
5
- ## Install
5
+ ## 🎯 What is @serve.zone/cli?
6
6
 
7
- To begin using the `@serve.zone/cli` in your projects, install it via npm by running:
7
+ The Cloudly CLI brings the full power of the Cloudly platform to your terminal. Whether you're automating deployments, managing secrets, or monitoring services, the CLI provides a streamlined interface for all your cloud operations.
8
+
9
+ ## ✨ Features
10
+
11
+ - **⚑ Fast & Efficient** - Optimized for speed and minimal resource usage
12
+ - **πŸ” Secure Authentication** - Token-based authentication with secure storage
13
+ - **πŸ“ Intuitive Commands** - Clear, consistent command structure
14
+ - **🎨 Formatted Output** - Beautiful, readable output with color coding
15
+ - **πŸ”„ Scriptable** - Perfect for CI/CD pipelines and automation
16
+ - **πŸ“Š Comprehensive** - Access to all Cloudly features from the terminal
17
+
18
+ ## πŸš€ Installation
19
+
20
+ ### Global Installation (Recommended)
8
21
 
9
22
  ```bash
10
- npm install @serve.zone/cli --save
23
+ pnpm add -g @serve.zone/cli
11
24
  ```
12
25
 
13
- This command will download the package and integrate it into your project's `node_modules` directory, reflecting the dependency in your `package.json`.
26
+ ### Local Installation
27
+
28
+ ```bash
29
+ pnpm add @serve.zone/cli
30
+ ```
31
+
32
+ ## 🎬 Quick Start
33
+
34
+ ```bash
35
+ # Configure your Cloudly instance
36
+ servezone config --url https://cloudly.example.com
14
37
 
15
- ## Usage
38
+ # Login with your service token
39
+ servezone login --token your-service-token
16
40
 
17
- The `@serve.zone/cli` is a powerful command-line tool aimed at developers and system administrators who are managing containerized applications across various cloud platforms. Through this CLI, users can interact with their cloud infrastructure efficiently, enabling and extending `Cloudly’s` capabilities directly from the terminal.
41
+ # List your clusters
42
+ servezone clusters list
18
43
 
19
- ### Prerequisites
44
+ # Deploy a service
45
+ servezone deploy --cluster production --image myapp:latest
46
+ ```
20
47
 
21
- Before proceeding to use the `@serve.zone/cli`, ensure your system meets the following prerequisites:
22
- - Latest Node.js LTS version installed.
23
- - Familiarity with basic command-line operations.
24
- - Properly configured cloud service accounts (like Cloudflare, Hetzner), necessary for managing respective services.
48
+ ## πŸ”‘ Authentication
25
49
 
26
- ### Setting Up the CLI
50
+ ### Initial Setup
27
51
 
28
- Begin setting up the `Cloudly` instance for CLI usage:
29
- ```typescript
30
- // Import required modules
31
- import { Cloudly } from '@serve.zone/cloudly';
32
- import * as path from 'path';
52
+ ```bash
53
+ # Set your Cloudly instance URL
54
+ servezone config --url https://cloudly.example.com
33
55
 
34
- // Define the configuration needed for cloud operations
35
- const cloudlyConfig = {
36
- cfToken: 'your-cloudflare-token',
37
- hetznerToken: 'your-hetzner-token',
38
- environment: 'production',
39
- publicUrl: 'your-public-url',
40
- };
56
+ # Authenticate with a service token
57
+ servezone login --token YOUR_SERVICE_TOKEN
58
+
59
+ # Or use environment variables
60
+ export CLOUDLY_URL=https://cloudly.example.com
61
+ export CLOUDLY_TOKEN=YOUR_SERVICE_TOKEN
62
+ ```
41
63
 
42
- // Instantiate and start the Cloudly instance
43
- const cloudlyInstance = new Cloudly(cloudlyConfig);
44
- await cloudlyInstance.start();
64
+ ### Managing Profiles
45
65
 
46
- // Log the setup information to ensure it’s correct
47
- console.log(`Cloudly is set up at ${cloudlyInstance.config.data.publicUrl}`);
66
+ ```bash
67
+ # Create a profile for different environments
68
+ servezone profile create production --url https://prod.cloudly.com
69
+ servezone profile create staging --url https://stage.cloudly.com
70
+
71
+ # Switch between profiles
72
+ servezone profile use production
73
+
74
+ # List all profiles
75
+ servezone profile list
48
76
  ```
49
77
 
50
- This snippet initializes a Cloudly instance with necessary environment configuration, setting the groundwork for all subsequent CLI operations.
51
-
52
- ### Core Operations with the CLI
53
-
54
- Here's how you leverage various operational commands within the CLI feature:
55
-
56
- #### Managing Clusters
57
-
58
- To create, list, and delete clusters, you’ll require invoking the `Cloudly` class with its cluster management logic:
59
-
60
- ```typescript
61
- // Module imports
62
- import { Cloudly } from '@serve.zone/cloudly';
63
-
64
- // Async function for cluster management
65
- async function manageCluster() {
66
- // Prepare configuration
67
- const config = {
68
- cfToken: 'YOUR_CLOUDFLARE_TOKEN',
69
- hetznerToken: 'YOUR_HETZNER_TOKEN',
70
- };
71
-
72
- // Initialize Cloudly
73
- const cloudlyInstance = new Cloudly(config);
74
- await cloudlyInstance.start();
75
-
76
- // Example: Creating a new cluster
77
- const cluster = await cloudlyInstance.clusterManager.createCluster({
78
- id: 'example_cluster_id',
79
- data: {
80
- name: 'example_cluster',
81
- servers: [],
82
- sshKeys: [],
83
- }
84
- });
85
-
86
- // Log cluster details
87
- console.log('Cluster created:', cluster);
88
- }
78
+ ## πŸ“š Core Commands
79
+
80
+ ### 🌐 Cluster Management
81
+
82
+ ```bash
83
+ # List all clusters
84
+ servezone clusters list
85
+
86
+ # Get cluster details
87
+ servezone clusters info production-cluster
88
+
89
+ # Create a new cluster
90
+ servezone clusters create \
91
+ --name production-cluster \
92
+ --region eu-central \
93
+ --nodes 3
94
+
95
+ # Scale a cluster
96
+ servezone clusters scale production-cluster --nodes 5
97
+
98
+ # Delete a cluster
99
+ servezone clusters delete staging-cluster
100
+ ```
101
+
102
+ ### 🐳 Service Deployment
103
+
104
+ ```bash
105
+ # Deploy a service
106
+ servezone deploy \
107
+ --cluster production \
108
+ --name api-service \
109
+ --image myapp:2.0.0 \
110
+ --replicas 3 \
111
+ --port 80:3000
112
+
113
+ # Update a service
114
+ servezone service update api-service \
115
+ --image myapp:2.1.0 \
116
+ --replicas 5
117
+
118
+ # Scale a service
119
+ servezone service scale api-service --replicas 10
120
+
121
+ # Remove a service
122
+ servezone service remove api-service
123
+ ```
124
+
125
+ ### πŸ” Secret Management
126
+
127
+ ```bash
128
+ # Create a secret
129
+ servezone secrets create \
130
+ --name database-url \
131
+ --value "postgres://user:pass@host/db"
132
+
133
+ # Create a secret group
134
+ servezone secrets create-group \
135
+ --name api-secrets \
136
+ --secret DATABASE_URL=postgres://... \
137
+ --secret REDIS_URL=redis://...
138
+
139
+ # List secrets
140
+ servezone secrets list
141
+
142
+ # Get secret value
143
+ servezone secrets get database-url
144
+
145
+ # Delete a secret
146
+ servezone secrets delete old-secret
89
147
  ```
90
- With the above example, you can dynamically manage cluster configurations, ensuring your application components are effectively orchestrated across cloud environments.
91
-
92
- #### Deploying Services
93
-
94
- Deploying cloud-native services within your clusters can be achieved through the CLI:
95
-
96
- ```typescript
97
- import { Cloudly } from '@serve.zone/cloudly';
98
-
99
- // Function to handle service deployment
100
- async function deployService() {
101
- const config = {
102
- cfToken: 'YOUR_CLOUDFLARE_TOKEN',
103
- hetznerToken: 'YOUR_HETZNER_TOKEN',
104
- };
105
-
106
- const cloudlyInstance = new Cloudly(config);
107
- await cloudlyInstance.start();
108
-
109
- // Deploy a new service to a specified cluster
110
- const newService = {
111
- id: 'example_service_id',
112
- data: {
113
- name: 'example_service',
114
- imageId: 'example_image_id',
115
- imageVersion: '1.0.0',
116
- environment: {},
117
- ports: { web: 80 }
118
- }
119
- };
120
-
121
- // Store service into database and deploy
122
- console.log('Deploying service:', newService)
123
- await cloudlyInstance.serverManager.deployService(newService);
124
- }
125
-
126
- deployService();
148
+
149
+ ### πŸ“¦ Image Management
150
+
151
+ ```bash
152
+ # List images
153
+ servezone images list
154
+
155
+ # Push a new image
156
+ servezone images push \
157
+ --name myapp \
158
+ --version 2.0.0 \
159
+ --file ./myapp.tar
160
+
161
+ # Tag an image
162
+ servezone images tag myapp:2.0.0 myapp:latest
163
+
164
+ # Delete an image
165
+ servezone images delete myapp:1.0.0
127
166
  ```
128
167
 
129
- By streamlining your service deployments through CLI, you ensure reproducibility and clarity in development operations.
168
+ ### πŸ“Š Monitoring & Logs
169
+
170
+ ```bash
171
+ # View service logs
172
+ servezone logs api-service
173
+
174
+ # Follow logs in real-time
175
+ servezone logs api-service --follow
130
176
 
131
- #### Managing Certificates
177
+ # Filter logs
178
+ servezone logs api-service --since 1h --grep ERROR
132
179
 
133
- Ensuring secure connections by managing SSL certificates is essential. The CLI aids in this through Let's Encrypt integration:
180
+ # Get service status
181
+ servezone service status api-service
134
182
 
135
- ```typescript
136
- import { Cloudly } from '@serve.zone/cloudly';
183
+ # Monitor cluster health
184
+ servezone clusters health production-cluster
185
+ ```
137
186
 
138
- // Function to acquire a certificate
139
- async function getCertificate() {
140
- const config = {
141
- cfToken: 'YOUR_CLOUDFLARE_TOKEN',
142
- hetznerToken: 'YOUR_HETZNER_TOKEN',
143
- };
187
+ ### πŸ”§ DNS Management
144
188
 
145
- const cloudlyInstance = new Cloudly(config);
146
- await cloudlyInstance.start();
189
+ ```bash
190
+ # List DNS records
191
+ servezone dns list --domain example.com
147
192
 
148
- // Fetch certificate using Let's Encrypt
149
- const domainName = 'example.com';
150
- const cert = await cloudlyInstance.letsencryptConnector.getCertificateForDomain(domainName);
151
- console.log(`Obtained certificate for domain ${domainName}:`, cert);
152
- }
193
+ # Create a DNS record
194
+ servezone dns create \
195
+ --domain example.com \
196
+ --name api \
197
+ --type A \
198
+ --value 192.168.1.1
153
199
 
154
- getCertificate();
200
+ # Update a DNS record
201
+ servezone dns update api.example.com --value 192.168.1.2
202
+
203
+ # Delete a DNS record
204
+ servezone dns delete old.example.com
155
205
  ```
156
206
 
157
- This process facilitates the automation of SSL certificates provisioning, ensuring high security in your apps.
207
+ ## 🎯 Advanced Usage
158
208
 
159
- ### Automating Tasks with the CLI
209
+ ### Environment Variables
160
210
 
161
- Task scheduling is a feature you can utilize to automate recurring processes. Here’s an example of how `@serve.zone/cli` accomplishes task scheduling:
211
+ ```bash
212
+ # Set environment variables for a service
213
+ servezone deploy \
214
+ --name api-service \
215
+ --env NODE_ENV=production \
216
+ --env PORT=3000 \
217
+ --env DATABASE_URL=@secret:database-url
218
+ ```
162
219
 
163
- ```typescript
164
- import { TaskBuffer } from '@push.rocks/taskbuffer';
220
+ ### Configuration Files
221
+
222
+ Create a `cloudly.yaml` file:
223
+
224
+ ```yaml
225
+ cluster: production
226
+ service:
227
+ name: api-service
228
+ image: myapp:latest
229
+ replicas: 3
230
+ ports:
231
+ - 80:3000
232
+ environment:
233
+ NODE_ENV: production
234
+ DATABASE_URL: "@secret:database-url"
235
+ ```
165
236
 
166
- // Schedule a task to run every day
167
- const dailyTask = new TaskBuffer({
168
- schedule: '0 0 * * *', // Using cron schedule
169
- taskFunction: async () => {
170
- console.log('Performing daily backup check...');
171
- // Include backup logic here
172
- },
173
- });
237
+ Deploy using the config file:
174
238
 
175
- // Initiate task scheduling
176
- dailyTask.start();
239
+ ```bash
240
+ servezone deploy --config cloudly.yaml
177
241
  ```
178
242
 
179
- Scheduled tasks like periodic maintenance, data synchronization, or backups ensure you keep your cloud environment robust and reliable.
243
+ ### Batch Operations
180
244
 
181
- ### Integrating Third-Party APIs
245
+ ```bash
246
+ # Deploy multiple services
247
+ servezone deploy --config services/*.yaml
182
248
 
183
- Expand the scope of your applications with API integrations offered via `@serve.zone/cli`:
249
+ # Update all services in a namespace
250
+ servezone service update --namespace api --image-tag v2.0.0
184
251
 
185
- ```typescript
186
- import { Cloudly } from '@serve.zone/cloudly';
252
+ # Delete all staging resources
253
+ servezone cleanup --environment staging
254
+ ```
255
+
256
+ ## πŸ”„ CI/CD Integration
187
257
 
188
- // Function to send notifications
189
- async function sendNotification() {
190
- const cloudlyConfig = {
191
- cfToken: 'your-cloudflare-token',
192
- hetznerToken: 'your-hetzner-token',
193
- };
258
+ ### GitHub Actions
194
259
 
195
- const cloudly = new Cloudly(cloudlyConfig);
196
- await cloudly.start();
260
+ ```yaml
261
+ - name: Deploy to Cloudly
262
+ run: |
263
+ servezone config --url ${{ secrets.CLOUDLY_URL }}
264
+ servezone login --token ${{ secrets.CLOUDLY_TOKEN }}
265
+ servezone deploy \
266
+ --cluster production \
267
+ --name api-service \
268
+ --image myapp:${{ github.sha }}
269
+ ```
197
270
 
198
- // Configure and send push notification
199
- await cloudly.externalApiManager.sendPushMessage({
200
- deviceToken: 'some_device_token',
201
- message: 'Hello from Cloudly!',
202
- });
203
- }
271
+ ### GitLab CI
204
272
 
205
- sendNotification();
273
+ ```yaml
274
+ deploy:
275
+ script:
276
+ - servezone config --url $CLOUDLY_URL
277
+ - servezone login --token $CLOUDLY_TOKEN
278
+ - servezone deploy --config cloudly.yaml
206
279
  ```
207
280
 
208
- API integrations via the CLI extend Cloudly’s reach, enabling comprehensive service interconnections.
281
+ ## 🎨 Output Formats
209
282
 
210
- ### Security and Access Management
283
+ ```bash
284
+ # JSON output for scripting
285
+ servezone clusters list --output json
211
286
 
212
- Effective identity management is possible through `@serve.zone/cli`. Manage user roles, token validations, and more:
287
+ # YAML output
288
+ servezone service info api-service --output yaml
213
289
 
214
- ```typescript
215
- import { Cloudly } from '@serve.zone/cloudly';
290
+ # Table output (default)
291
+ servezone images list --output table
216
292
 
217
- // Configuring and verifying identity
218
- async function authenticateUser() {
219
- const cloudlyConfig = {
220
- cfToken: 'your-cloudflare-token',
221
- hetznerToken: 'your-hetzner-token',
222
- };
293
+ # Quiet mode (IDs only)
294
+ servezone clusters list --quiet
295
+ ```
223
296
 
224
- const cloudly = new Cloudly(cloudlyConfig);
225
- await cloudly.start();
297
+ ## πŸ› οΈ Troubleshooting
226
298
 
227
- // Sample user credentials
228
- const userIdentity = {
229
- userId: 'unique_user_id',
230
- jwt: 'user_jwt_token',
231
- };
299
+ ```bash
300
+ # Enable debug output
301
+ servezone --debug clusters list
302
+
303
+ # Check CLI version
304
+ servezone version
232
305
 
233
- // Validate identity
234
- const isValid = cloudly.authManager.validateIdentity(userIdentity);
235
- console.log(`Is user identity valid? ${isValid}`);
236
- }
306
+ # Test connection
307
+ servezone ping
237
308
 
238
- authenticateUser();
309
+ # View configuration
310
+ servezone config show
311
+
312
+ # Clear cache and credentials
313
+ servezone logout --clear-cache
239
314
  ```
240
315
 
241
- The applications of identity validation streamline operational security and enforce access controls across your systems.
316
+ ## πŸ“ Command Reference
242
317
 
243
- These examples offer a glimpse into the vast potential of @serve.zone/cli, which combines automation, security, and flexibility for state-of-the-art cloud management. You are encouraged to build upon this documentation to harness Cloudly's full capabilities in your infrastructure and process ecosystems. Let the CLI transform your cloud management experience with precision and adaptability.
318
+ ```bash
319
+ servezone --help # Show all commands
320
+ servezone <command> --help # Show command-specific help
321
+ servezone clusters --help # Show cluster commands
322
+ servezone service --help # Show service commands
323
+ servezone secrets --help # Show secret commands
324
+ ```
325
+
326
+ ## πŸ”Œ Shell Completion
327
+
328
+ Enable tab completion for your shell:
329
+
330
+ ```bash
331
+ # Bash
332
+ servezone completion bash > /etc/bash_completion.d/servezone
333
+
334
+ # Zsh
335
+ servezone completion zsh > ~/.zsh/completions/_servezone
336
+
337
+ # Fish
338
+ servezone completion fish > ~/.config/fish/completions/servezone.fish
339
+ ```
244
340
 
245
341
  ## License and Legal Information
246
342
 
@@ -259,4 +355,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
259
355
 
260
356
  For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
261
357
 
262
- By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
358
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -1,246 +1,342 @@
1
- # @serve.zone/cli
1
+ # @serve.zone/cli πŸš€
2
2
 
3
- A comprehensive command-line interface (CLI) tool for managing multi-cloud environments, leveraging the features of the @serve.zone/cloudly platform. This CLI is crafted to facilitate seamless interactions with complex cloud configurations and deployments, utilizing Docker Swarmkit orchestration.
3
+ **Command-line interface for Cloudly.** Manage your multi-cloud infrastructure from the terminal with powerful, intuitive commands.
4
4
 
5
- ## Install
5
+ ## 🎯 What is @serve.zone/cli?
6
6
 
7
- To begin using the `@serve.zone/cli` in your projects, install it via npm by running:
7
+ The Cloudly CLI brings the full power of the Cloudly platform to your terminal. Whether you're automating deployments, managing secrets, or monitoring services, the CLI provides a streamlined interface for all your cloud operations.
8
+
9
+ ## ✨ Features
10
+
11
+ - **⚑ Fast & Efficient** - Optimized for speed and minimal resource usage
12
+ - **πŸ” Secure Authentication** - Token-based authentication with secure storage
13
+ - **πŸ“ Intuitive Commands** - Clear, consistent command structure
14
+ - **🎨 Formatted Output** - Beautiful, readable output with color coding
15
+ - **πŸ”„ Scriptable** - Perfect for CI/CD pipelines and automation
16
+ - **πŸ“Š Comprehensive** - Access to all Cloudly features from the terminal
17
+
18
+ ## πŸš€ Installation
19
+
20
+ ### Global Installation (Recommended)
8
21
 
9
22
  ```bash
10
- npm install @serve.zone/cli --save
23
+ pnpm add -g @serve.zone/cli
11
24
  ```
12
25
 
13
- This command will download the package and integrate it into your project's `node_modules` directory, reflecting the dependency in your `package.json`.
26
+ ### Local Installation
27
+
28
+ ```bash
29
+ pnpm add @serve.zone/cli
30
+ ```
31
+
32
+ ## 🎬 Quick Start
33
+
34
+ ```bash
35
+ # Configure your Cloudly instance
36
+ servezone config --url https://cloudly.example.com
14
37
 
15
- ## Usage
38
+ # Login with your service token
39
+ servezone login --token your-service-token
16
40
 
17
- The `@serve.zone/cli` is a powerful command-line tool aimed at developers and system administrators who are managing containerized applications across various cloud platforms. Through this CLI, users can interact with their cloud infrastructure efficiently, enabling and extending `Cloudly’s` capabilities directly from the terminal.
41
+ # List your clusters
42
+ servezone clusters list
18
43
 
19
- ### Prerequisites
44
+ # Deploy a service
45
+ servezone deploy --cluster production --image myapp:latest
46
+ ```
20
47
 
21
- Before proceeding to use the `@serve.zone/cli`, ensure your system meets the following prerequisites:
22
- - Latest Node.js LTS version installed.
23
- - Familiarity with basic command-line operations.
24
- - Properly configured cloud service accounts (like Cloudflare, Hetzner), necessary for managing respective services.
48
+ ## πŸ”‘ Authentication
25
49
 
26
- ### Setting Up the CLI
50
+ ### Initial Setup
27
51
 
28
- Begin setting up the `Cloudly` instance for CLI usage:
29
- ```typescript
30
- // Import required modules
31
- import { Cloudly } from '@serve.zone/cloudly';
32
- import * as path from 'path';
52
+ ```bash
53
+ # Set your Cloudly instance URL
54
+ servezone config --url https://cloudly.example.com
33
55
 
34
- // Define the configuration needed for cloud operations
35
- const cloudlyConfig = {
36
- cfToken: 'your-cloudflare-token',
37
- hetznerToken: 'your-hetzner-token',
38
- environment: 'production',
39
- publicUrl: 'your-public-url',
40
- };
56
+ # Authenticate with a service token
57
+ servezone login --token YOUR_SERVICE_TOKEN
58
+
59
+ # Or use environment variables
60
+ export CLOUDLY_URL=https://cloudly.example.com
61
+ export CLOUDLY_TOKEN=YOUR_SERVICE_TOKEN
62
+ ```
41
63
 
42
- // Instantiate and start the Cloudly instance
43
- const cloudlyInstance = new Cloudly(cloudlyConfig);
44
- await cloudlyInstance.start();
64
+ ### Managing Profiles
45
65
 
46
- // Log the setup information to ensure it’s correct
47
- console.log(`Cloudly is set up at ${cloudlyInstance.config.data.publicUrl}`);
66
+ ```bash
67
+ # Create a profile for different environments
68
+ servezone profile create production --url https://prod.cloudly.com
69
+ servezone profile create staging --url https://stage.cloudly.com
70
+
71
+ # Switch between profiles
72
+ servezone profile use production
73
+
74
+ # List all profiles
75
+ servezone profile list
48
76
  ```
49
77
 
50
- This snippet initializes a Cloudly instance with necessary environment configuration, setting the groundwork for all subsequent CLI operations.
51
-
52
- ### Core Operations with the CLI
53
-
54
- Here's how you leverage various operational commands within the CLI feature:
55
-
56
- #### Managing Clusters
57
-
58
- To create, list, and delete clusters, you’ll require invoking the `Cloudly` class with its cluster management logic:
59
-
60
- ```typescript
61
- // Module imports
62
- import { Cloudly } from '@serve.zone/cloudly';
63
-
64
- // Async function for cluster management
65
- async function manageCluster() {
66
- // Prepare configuration
67
- const config = {
68
- cfToken: 'YOUR_CLOUDFLARE_TOKEN',
69
- hetznerToken: 'YOUR_HETZNER_TOKEN',
70
- };
71
-
72
- // Initialize Cloudly
73
- const cloudlyInstance = new Cloudly(config);
74
- await cloudlyInstance.start();
75
-
76
- // Example: Creating a new cluster
77
- const cluster = await cloudlyInstance.clusterManager.createCluster({
78
- id: 'example_cluster_id',
79
- data: {
80
- name: 'example_cluster',
81
- servers: [],
82
- sshKeys: [],
83
- }
84
- });
85
-
86
- // Log cluster details
87
- console.log('Cluster created:', cluster);
88
- }
78
+ ## πŸ“š Core Commands
79
+
80
+ ### 🌐 Cluster Management
81
+
82
+ ```bash
83
+ # List all clusters
84
+ servezone clusters list
85
+
86
+ # Get cluster details
87
+ servezone clusters info production-cluster
88
+
89
+ # Create a new cluster
90
+ servezone clusters create \
91
+ --name production-cluster \
92
+ --region eu-central \
93
+ --nodes 3
94
+
95
+ # Scale a cluster
96
+ servezone clusters scale production-cluster --nodes 5
97
+
98
+ # Delete a cluster
99
+ servezone clusters delete staging-cluster
100
+ ```
101
+
102
+ ### 🐳 Service Deployment
103
+
104
+ ```bash
105
+ # Deploy a service
106
+ servezone deploy \
107
+ --cluster production \
108
+ --name api-service \
109
+ --image myapp:2.0.0 \
110
+ --replicas 3 \
111
+ --port 80:3000
112
+
113
+ # Update a service
114
+ servezone service update api-service \
115
+ --image myapp:2.1.0 \
116
+ --replicas 5
117
+
118
+ # Scale a service
119
+ servezone service scale api-service --replicas 10
120
+
121
+ # Remove a service
122
+ servezone service remove api-service
123
+ ```
124
+
125
+ ### πŸ” Secret Management
126
+
127
+ ```bash
128
+ # Create a secret
129
+ servezone secrets create \
130
+ --name database-url \
131
+ --value "postgres://user:pass@host/db"
132
+
133
+ # Create a secret group
134
+ servezone secrets create-group \
135
+ --name api-secrets \
136
+ --secret DATABASE_URL=postgres://... \
137
+ --secret REDIS_URL=redis://...
138
+
139
+ # List secrets
140
+ servezone secrets list
141
+
142
+ # Get secret value
143
+ servezone secrets get database-url
144
+
145
+ # Delete a secret
146
+ servezone secrets delete old-secret
89
147
  ```
90
- With the above example, you can dynamically manage cluster configurations, ensuring your application components are effectively orchestrated across cloud environments.
91
-
92
- #### Deploying Services
93
-
94
- Deploying cloud-native services within your clusters can be achieved through the CLI:
95
-
96
- ```typescript
97
- import { Cloudly } from '@serve.zone/cloudly';
98
-
99
- // Function to handle service deployment
100
- async function deployService() {
101
- const config = {
102
- cfToken: 'YOUR_CLOUDFLARE_TOKEN',
103
- hetznerToken: 'YOUR_HETZNER_TOKEN',
104
- };
105
-
106
- const cloudlyInstance = new Cloudly(config);
107
- await cloudlyInstance.start();
108
-
109
- // Deploy a new service to a specified cluster
110
- const newService = {
111
- id: 'example_service_id',
112
- data: {
113
- name: 'example_service',
114
- imageId: 'example_image_id',
115
- imageVersion: '1.0.0',
116
- environment: {},
117
- ports: { web: 80 }
118
- }
119
- };
120
-
121
- // Store service into database and deploy
122
- console.log('Deploying service:', newService)
123
- await cloudlyInstance.serverManager.deployService(newService);
124
- }
125
-
126
- deployService();
148
+
149
+ ### πŸ“¦ Image Management
150
+
151
+ ```bash
152
+ # List images
153
+ servezone images list
154
+
155
+ # Push a new image
156
+ servezone images push \
157
+ --name myapp \
158
+ --version 2.0.0 \
159
+ --file ./myapp.tar
160
+
161
+ # Tag an image
162
+ servezone images tag myapp:2.0.0 myapp:latest
163
+
164
+ # Delete an image
165
+ servezone images delete myapp:1.0.0
127
166
  ```
128
167
 
129
- By streamlining your service deployments through CLI, you ensure reproducibility and clarity in development operations.
168
+ ### πŸ“Š Monitoring & Logs
169
+
170
+ ```bash
171
+ # View service logs
172
+ servezone logs api-service
173
+
174
+ # Follow logs in real-time
175
+ servezone logs api-service --follow
130
176
 
131
- #### Managing Certificates
177
+ # Filter logs
178
+ servezone logs api-service --since 1h --grep ERROR
132
179
 
133
- Ensuring secure connections by managing SSL certificates is essential. The CLI aids in this through Let's Encrypt integration:
180
+ # Get service status
181
+ servezone service status api-service
134
182
 
135
- ```typescript
136
- import { Cloudly } from '@serve.zone/cloudly';
183
+ # Monitor cluster health
184
+ servezone clusters health production-cluster
185
+ ```
137
186
 
138
- // Function to acquire a certificate
139
- async function getCertificate() {
140
- const config = {
141
- cfToken: 'YOUR_CLOUDFLARE_TOKEN',
142
- hetznerToken: 'YOUR_HETZNER_TOKEN',
143
- };
187
+ ### πŸ”§ DNS Management
144
188
 
145
- const cloudlyInstance = new Cloudly(config);
146
- await cloudlyInstance.start();
189
+ ```bash
190
+ # List DNS records
191
+ servezone dns list --domain example.com
147
192
 
148
- // Fetch certificate using Let's Encrypt
149
- const domainName = 'example.com';
150
- const cert = await cloudlyInstance.letsencryptConnector.getCertificateForDomain(domainName);
151
- console.log(`Obtained certificate for domain ${domainName}:`, cert);
152
- }
193
+ # Create a DNS record
194
+ servezone dns create \
195
+ --domain example.com \
196
+ --name api \
197
+ --type A \
198
+ --value 192.168.1.1
153
199
 
154
- getCertificate();
200
+ # Update a DNS record
201
+ servezone dns update api.example.com --value 192.168.1.2
202
+
203
+ # Delete a DNS record
204
+ servezone dns delete old.example.com
155
205
  ```
156
206
 
157
- This process facilitates the automation of SSL certificates provisioning, ensuring high security in your apps.
207
+ ## 🎯 Advanced Usage
158
208
 
159
- ### Automating Tasks with the CLI
209
+ ### Environment Variables
160
210
 
161
- Task scheduling is a feature you can utilize to automate recurring processes. Here’s an example of how `@serve.zone/cli` accomplishes task scheduling:
211
+ ```bash
212
+ # Set environment variables for a service
213
+ servezone deploy \
214
+ --name api-service \
215
+ --env NODE_ENV=production \
216
+ --env PORT=3000 \
217
+ --env DATABASE_URL=@secret:database-url
218
+ ```
162
219
 
163
- ```typescript
164
- import { TaskBuffer } from '@push.rocks/taskbuffer';
220
+ ### Configuration Files
221
+
222
+ Create a `cloudly.yaml` file:
223
+
224
+ ```yaml
225
+ cluster: production
226
+ service:
227
+ name: api-service
228
+ image: myapp:latest
229
+ replicas: 3
230
+ ports:
231
+ - 80:3000
232
+ environment:
233
+ NODE_ENV: production
234
+ DATABASE_URL: "@secret:database-url"
235
+ ```
165
236
 
166
- // Schedule a task to run every day
167
- const dailyTask = new TaskBuffer({
168
- schedule: '0 0 * * *', // Using cron schedule
169
- taskFunction: async () => {
170
- console.log('Performing daily backup check...');
171
- // Include backup logic here
172
- },
173
- });
237
+ Deploy using the config file:
174
238
 
175
- // Initiate task scheduling
176
- dailyTask.start();
239
+ ```bash
240
+ servezone deploy --config cloudly.yaml
177
241
  ```
178
242
 
179
- Scheduled tasks like periodic maintenance, data synchronization, or backups ensure you keep your cloud environment robust and reliable.
243
+ ### Batch Operations
180
244
 
181
- ### Integrating Third-Party APIs
245
+ ```bash
246
+ # Deploy multiple services
247
+ servezone deploy --config services/*.yaml
182
248
 
183
- Expand the scope of your applications with API integrations offered via `@serve.zone/cli`:
249
+ # Update all services in a namespace
250
+ servezone service update --namespace api --image-tag v2.0.0
184
251
 
185
- ```typescript
186
- import { Cloudly } from '@serve.zone/cloudly';
252
+ # Delete all staging resources
253
+ servezone cleanup --environment staging
254
+ ```
255
+
256
+ ## πŸ”„ CI/CD Integration
187
257
 
188
- // Function to send notifications
189
- async function sendNotification() {
190
- const cloudlyConfig = {
191
- cfToken: 'your-cloudflare-token',
192
- hetznerToken: 'your-hetzner-token',
193
- };
258
+ ### GitHub Actions
194
259
 
195
- const cloudly = new Cloudly(cloudlyConfig);
196
- await cloudly.start();
260
+ ```yaml
261
+ - name: Deploy to Cloudly
262
+ run: |
263
+ servezone config --url ${{ secrets.CLOUDLY_URL }}
264
+ servezone login --token ${{ secrets.CLOUDLY_TOKEN }}
265
+ servezone deploy \
266
+ --cluster production \
267
+ --name api-service \
268
+ --image myapp:${{ github.sha }}
269
+ ```
197
270
 
198
- // Configure and send push notification
199
- await cloudly.externalApiManager.sendPushMessage({
200
- deviceToken: 'some_device_token',
201
- message: 'Hello from Cloudly!',
202
- });
203
- }
271
+ ### GitLab CI
204
272
 
205
- sendNotification();
273
+ ```yaml
274
+ deploy:
275
+ script:
276
+ - servezone config --url $CLOUDLY_URL
277
+ - servezone login --token $CLOUDLY_TOKEN
278
+ - servezone deploy --config cloudly.yaml
206
279
  ```
207
280
 
208
- API integrations via the CLI extend Cloudly’s reach, enabling comprehensive service interconnections.
281
+ ## 🎨 Output Formats
209
282
 
210
- ### Security and Access Management
283
+ ```bash
284
+ # JSON output for scripting
285
+ servezone clusters list --output json
211
286
 
212
- Effective identity management is possible through `@serve.zone/cli`. Manage user roles, token validations, and more:
287
+ # YAML output
288
+ servezone service info api-service --output yaml
213
289
 
214
- ```typescript
215
- import { Cloudly } from '@serve.zone/cloudly';
290
+ # Table output (default)
291
+ servezone images list --output table
216
292
 
217
- // Configuring and verifying identity
218
- async function authenticateUser() {
219
- const cloudlyConfig = {
220
- cfToken: 'your-cloudflare-token',
221
- hetznerToken: 'your-hetzner-token',
222
- };
293
+ # Quiet mode (IDs only)
294
+ servezone clusters list --quiet
295
+ ```
223
296
 
224
- const cloudly = new Cloudly(cloudlyConfig);
225
- await cloudly.start();
297
+ ## πŸ› οΈ Troubleshooting
226
298
 
227
- // Sample user credentials
228
- const userIdentity = {
229
- userId: 'unique_user_id',
230
- jwt: 'user_jwt_token',
231
- };
299
+ ```bash
300
+ # Enable debug output
301
+ servezone --debug clusters list
302
+
303
+ # Check CLI version
304
+ servezone version
232
305
 
233
- // Validate identity
234
- const isValid = cloudly.authManager.validateIdentity(userIdentity);
235
- console.log(`Is user identity valid? ${isValid}`);
236
- }
306
+ # Test connection
307
+ servezone ping
237
308
 
238
- authenticateUser();
309
+ # View configuration
310
+ servezone config show
311
+
312
+ # Clear cache and credentials
313
+ servezone logout --clear-cache
239
314
  ```
240
315
 
241
- The applications of identity validation streamline operational security and enforce access controls across your systems.
316
+ ## πŸ“ Command Reference
242
317
 
243
- These examples offer a glimpse into the vast potential of @serve.zone/cli, which combines automation, security, and flexibility for state-of-the-art cloud management. You are encouraged to build upon this documentation to harness Cloudly's full capabilities in your infrastructure and process ecosystems. Let the CLI transform your cloud management experience with precision and adaptability.
318
+ ```bash
319
+ servezone --help # Show all commands
320
+ servezone <command> --help # Show command-specific help
321
+ servezone clusters --help # Show cluster commands
322
+ servezone service --help # Show service commands
323
+ servezone secrets --help # Show secret commands
324
+ ```
325
+
326
+ ## πŸ”Œ Shell Completion
327
+
328
+ Enable tab completion for your shell:
329
+
330
+ ```bash
331
+ # Bash
332
+ servezone completion bash > /etc/bash_completion.d/servezone
333
+
334
+ # Zsh
335
+ servezone completion zsh > ~/.zsh/completions/_servezone
336
+
337
+ # Fish
338
+ servezone completion fish > ~/.config/fish/completions/servezone.fish
339
+ ```
244
340
 
245
341
  ## License and Legal Information
246
342
 
@@ -259,4 +355,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
259
355
 
260
356
  For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
261
357
 
262
- By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
358
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.