fix(core): update
This commit is contained in:
60
readme.md
60
readme.md
@@ -1,21 +1,28 @@
|
||||
# @serve.zone/cloudly
|
||||
A cloud manager utilizing Docker Swarmkit, designed for operations on Cloudron, and supports various cloud platforms like DigitalOcean, Hetzner Cloud, and Cloudflare.
|
||||
|
||||
A comprehensive multi-cloud manager leveraging Docker Swarmkit for orchestrating containerized applications and integrating various cloud services like DigitalOcean, Hetzner Cloud, and Cloudflare, with robust configuration and API management capabilities.
|
||||
|
||||
## Install
|
||||
|
||||
To install `@serve.zone/cloudly`, run the following command in your terminal:
|
||||
|
||||
```bash
|
||||
npm install @serve.zone/cloudly --save
|
||||
```
|
||||
|
||||
This will install the package and add it to your project's `package.json` dependencies.
|
||||
|
||||
## Usage
|
||||
|
||||
`@serve.zone/cloudly` is designed to help you manage and configure cloud environments. This package provides a comprehensive TypeScript and ESM-based interface for interacting with various cloud services, including Docker Swarmkit cluster management, and integration with cloud providers such as DigitalOcean, Hetzner Cloud, and Cloudflare.
|
||||
|
||||
### Getting Started
|
||||
|
||||
Before diving into the specifics, ensure your environment is properly set up. This includes having Node.js installed (preferably the latest LTS version), and if you are working in a TypeScript project, ensure TypeScript is configured.
|
||||
|
||||
#### Initializing Cloudly
|
||||
First, import `Cloudly` class from the package and initialize it as shown below:
|
||||
|
||||
First, import the `Cloudly` class from the package and initialize it as shown below:
|
||||
|
||||
```typescript
|
||||
import { Cloudly } from '@serve.zone/cloudly';
|
||||
@@ -26,6 +33,7 @@ const myCloudlyInstance = new Cloudly();
|
||||
The `Cloudly` class is the entry point to using the library features. It prepares the environment for configuring the cloud services.
|
||||
|
||||
#### Configuration
|
||||
|
||||
Configuration plays a pivotal role in how `@serve.zone/cloudly` operates. The library expects certain configurations to be provided, which can include credentials for cloud services, database connections, etc.
|
||||
|
||||
For example, to configure a connection to MongoDB, specify your MongoDB details as shown:
|
||||
@@ -38,16 +46,22 @@ const myCloudlyConfig = {
|
||||
mongoDbUser: 'myUser',
|
||||
mongoDbPass: 'myPassword',
|
||||
},
|
||||
// Additional configuration values...
|
||||
cfToken: 'your_cloudflare_api_token',
|
||||
environment: 'development',
|
||||
letsEncryptEmail: 'lets_encrypt_email@example.com',
|
||||
publicUrl: 'example.com',
|
||||
publicPort: 8443,
|
||||
hetznerToken: 'your_hetzner_api_token',
|
||||
};
|
||||
|
||||
const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
||||
```
|
||||
|
||||
#### Managing Docker Swarmkit Cluster
|
||||
### Managing Docker Swarmkit Clusters
|
||||
|
||||
Cloudly allows managing Docker Swarmkit clusters through an abstracted interface, simplifying operations such as deployment and scaling. Below are examples to demonstrate these capabilities.
|
||||
|
||||
### Example: Start a Cloudly Instance and Add a Cluster
|
||||
#### Example: Initializing a Cloudly Instance and Adding a Cluster
|
||||
|
||||
```typescript
|
||||
import { Cloudly, ClusterManager } from '@serve.zone/cloudly';
|
||||
@@ -65,7 +79,7 @@ async function main() {
|
||||
letsEncryptEmail: 'lets_encrypt_email@example.com',
|
||||
publicUrl: 'example.com',
|
||||
publicPort: 8443,
|
||||
hetznerToken: 'your_hetzner_api_token'
|
||||
hetznerToken: 'your_hetzner_api_token',
|
||||
};
|
||||
|
||||
const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
||||
@@ -88,10 +102,15 @@ async function main() {
|
||||
|
||||
console.log('Cluster added:', newCluster);
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
### Example: Manage Cloudflare DNS Records
|
||||
### Additional Use Cases
|
||||
|
||||
#### Managing Cloudflare DNS Records
|
||||
|
||||
You can manage Cloudflare DNS records using the `CloudflareConnector` provided by Cloudly.
|
||||
|
||||
```typescript
|
||||
import { Cloudly, CloudflareConnector } from '@serve.zone/cloudly';
|
||||
@@ -109,7 +128,7 @@ async function manageDNSRecords() {
|
||||
letsEncryptEmail: 'lets_encrypt_email@example.com',
|
||||
publicUrl: 'example.com',
|
||||
publicPort: 8443,
|
||||
hetznerToken: 'your_hetzner_api_token'
|
||||
hetznerToken: 'your_hetzner_api_token',
|
||||
};
|
||||
|
||||
const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
||||
@@ -135,7 +154,9 @@ async function manageDNSRecords() {
|
||||
manageDNSRecords();
|
||||
```
|
||||
|
||||
### Example: Integrate with DigitalOcean
|
||||
#### Integrating with DigitalOcean
|
||||
|
||||
Integrate with DigitalOcean to manage droplets and other resources.
|
||||
|
||||
```typescript
|
||||
import { Cloudly, DigitalOceanConnector } from '@serve.zone/cloudly';
|
||||
@@ -153,7 +174,7 @@ async function manageDroplet() {
|
||||
letsEncryptEmail: 'lets_encrypt_email@example.com',
|
||||
publicUrl: 'example.com',
|
||||
publicPort: 8443,
|
||||
hetznerToken: 'your_hetzner_api_token'
|
||||
hetznerToken: 'your_hetzner_api_token',
|
||||
};
|
||||
|
||||
const myCloudlyInstance = new Cloudly(myCloudlyConfig);
|
||||
@@ -180,8 +201,11 @@ manageDroplet();
|
||||
```
|
||||
|
||||
### Using Cloudly Web Interface
|
||||
|
||||
If your project includes a web interface to manage various sections like DNS, deployments, clusters, etc., you can use the provided elements and state management. Below is an example of setting up a dashboard using the components defined:
|
||||
|
||||
#### Web Dashboard Example
|
||||
|
||||
```typescript
|
||||
import { commitinfo } from '../00_commitinfo_data.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
@@ -212,7 +236,7 @@ import { CloudlyViewServices } from './cloudly-view-services.js';
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'cvault-dashboard': CloudlyDashboard;
|
||||
'cloudly-dashboard': CloudlyDashboard;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +251,7 @@ export class CloudlyDashboard extends DeesElement {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
document.title = `cloudly v${commitinfo.version}`;
|
||||
const subcription = appstate.dataState
|
||||
.select((stateArg) => stateArg)
|
||||
.subscribe((dataArg) => {
|
||||
@@ -309,6 +334,10 @@ export class CloudlyDashboard extends DeesElement {
|
||||
name: 'Backups',
|
||||
element: CloudlyViewBackups,
|
||||
},
|
||||
{
|
||||
name: 'Fleet',
|
||||
element: CloudlyViewBackups,
|
||||
}
|
||||
] as plugins.deesCatalog.IView[]}
|
||||
></dees-simple-appdash>
|
||||
</dees-simple-login>
|
||||
@@ -329,7 +358,7 @@ export class CloudlyDashboard extends DeesElement {
|
||||
action: async () => {
|
||||
await plugins.deesCatalog.DeesModal.createAndShow({
|
||||
heading: 'About',
|
||||
content: html`configvault ${commitinfo.version}`,
|
||||
content: html`cloudly ${commitinfo.version}`,
|
||||
menuOptions: [
|
||||
{
|
||||
name: 'close',
|
||||
@@ -352,11 +381,12 @@ export class CloudlyDashboard extends DeesElement {
|
||||
if (loginState.jwt) {
|
||||
this.jwt = loginState.jwt;
|
||||
await simpleLogin.switchToSlottedContent();
|
||||
await appstate.dataState.dispatchAction(appstate.getDataAction, null);
|
||||
await appstate.dataState.dispatchAction(appstate.getAllDataAction, null);
|
||||
}
|
||||
}
|
||||
|
||||
private async login(username: string, password: string) {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
console.log(`attempting to login...`);
|
||||
const simpleLogin = this.shadowRoot.querySelector('dees-simple-login');
|
||||
const form = simpleLogin.shadowRoot.querySelector('dees-form');
|
||||
@@ -370,7 +400,7 @@ export class CloudlyDashboard extends DeesElement {
|
||||
this.jwt = state.jwt;
|
||||
form.setStatus('success', 'Logged in!');
|
||||
await simpleLogin.switchToSlottedContent();
|
||||
await appstate.dataState.dispatchAction(appstate.getDataAction, null);
|
||||
await appstate.dataState.dispatchAction(appstate.getAllDataAction, null);
|
||||
} else {
|
||||
form.setStatus('error', 'Login failed!');
|
||||
await domtools.convenience.smartdelay.delayFor(2000);
|
||||
@@ -382,8 +412,6 @@ export class CloudlyDashboard extends DeesElement {
|
||||
}
|
||||
```
|
||||
|
||||
This script sets up a cloud management dashboard for interacting with various cloud services seamlessly. It covers creating clusters, managing DNS records, handling cloud-provider-specific resources, and much more.
|
||||
|
||||
With the examples provided above, you should now have a good understanding of how to use `@serve.zone/cloudly` to manage your cloud infrastructure programmatically. For deeper insights and additional features, refer to the documentation relevant to specific modules and methods used in your application.
|
||||
|
||||
## License and Legal Information
|
||||
|
Reference in New Issue
Block a user