@kustodian/plugin-k0s 1.0.0 → 1.0.1
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.
- package/README.md +57 -0
- package/package.json +1 -1
- package/src/executor.ts +9 -3
- package/src/provider.ts +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @kustodian/plugin-k0s
|
|
2
|
+
|
|
3
|
+
A [k0s](https://k0sproject.io/) cluster provider plugin for [Kustodian](https://github.com/lucasilverentand/kustodian).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @kustodian/plugin-k0s
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This plugin provides k0s cluster lifecycle management through the [k0sctl](https://github.com/k0sproject/k0sctl) tool. It implements the `ClusterProviderType` interface from `@kustodian/plugins`.
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
- **Cluster Bootstrap**: Automatically generates k0sctl configuration from your node definitions and deploys k0s
|
|
18
|
+
- **Kubeconfig Retrieval**: Fetch kubeconfig from deployed clusters
|
|
19
|
+
- **Cluster Reset**: Tear down clusters with optional force mode
|
|
20
|
+
- **Configuration Validation**: Validates node configurations before deployment
|
|
21
|
+
- **Dry Run Support**: Test configurations without applying changes
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
|
|
25
|
+
- [k0sctl](https://github.com/k0sproject/k0sctl) must be installed and available in your PATH
|
|
26
|
+
- SSH access to target nodes
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { create_k0s_plugin, create_k0s_provider } from '@kustodian/plugin-k0s';
|
|
32
|
+
|
|
33
|
+
// Create provider with options
|
|
34
|
+
const provider = create_k0s_provider({
|
|
35
|
+
k0s_version: '1.30.0+k0s.0',
|
|
36
|
+
telemetry_enabled: false,
|
|
37
|
+
dynamic_config: true,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Or use the plugin directly
|
|
41
|
+
const plugin = create_k0s_plugin({
|
|
42
|
+
k0s_version: '1.30.0+k0s.0',
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Provider Options
|
|
47
|
+
|
|
48
|
+
| Option | Type | Description |
|
|
49
|
+
|--------|------|-------------|
|
|
50
|
+
| `k0s_version` | `string` | k0s version to install |
|
|
51
|
+
| `telemetry_enabled` | `boolean` | Enable k0s telemetry (default: `false`) |
|
|
52
|
+
| `dynamic_config` | `boolean` | Enable dynamic configuration |
|
|
53
|
+
| `default_ssh` | `SshConfigType` | Default SSH configuration for nodes |
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/package.json
CHANGED
package/src/executor.ts
CHANGED
|
@@ -76,7 +76,7 @@ function is_exec_error(
|
|
|
76
76
|
* Checks if k0sctl is available in the system PATH.
|
|
77
77
|
*/
|
|
78
78
|
export async function check_k0sctl_available(): Promise<ResultType<string, KustodianErrorType>> {
|
|
79
|
-
const result = await exec_command('k0sctl', ['version']);
|
|
79
|
+
const result = await exec_command('k0sctl', ['version'], { timeout: 5000 });
|
|
80
80
|
|
|
81
81
|
if (!result.success) {
|
|
82
82
|
return result;
|
|
@@ -124,7 +124,10 @@ export async function k0sctl_kubeconfig(
|
|
|
124
124
|
config_path: string,
|
|
125
125
|
options: ExecOptionsType = {},
|
|
126
126
|
): Promise<ResultType<string, KustodianErrorType>> {
|
|
127
|
-
const result = await exec_command('k0sctl', ['kubeconfig', '--config', config_path],
|
|
127
|
+
const result = await exec_command('k0sctl', ['kubeconfig', '--config', config_path], {
|
|
128
|
+
timeout: 30000,
|
|
129
|
+
...options,
|
|
130
|
+
});
|
|
128
131
|
|
|
129
132
|
if (!result.success) {
|
|
130
133
|
return result;
|
|
@@ -150,7 +153,10 @@ export async function k0sctl_reset(
|
|
|
150
153
|
args.push('--force');
|
|
151
154
|
}
|
|
152
155
|
|
|
153
|
-
const result = await exec_command('k0sctl', args,
|
|
156
|
+
const result = await exec_command('k0sctl', args, {
|
|
157
|
+
timeout: 60000,
|
|
158
|
+
...options,
|
|
159
|
+
});
|
|
154
160
|
|
|
155
161
|
if (!result.success) {
|
|
156
162
|
return result;
|
package/src/provider.ts
CHANGED
|
@@ -117,6 +117,12 @@ export function create_k0s_provider(options: K0sProviderOptionsType = {}): Clust
|
|
|
117
117
|
},
|
|
118
118
|
|
|
119
119
|
async get_kubeconfig(node_list: NodeListType): Promise<ResultType<string, KustodianErrorType>> {
|
|
120
|
+
// Check k0sctl is available
|
|
121
|
+
const k0sctl_check = await check_k0sctl_available();
|
|
122
|
+
if (!is_success(k0sctl_check)) {
|
|
123
|
+
return k0sctl_check;
|
|
124
|
+
}
|
|
125
|
+
|
|
120
126
|
// If we have a config path from install, use it
|
|
121
127
|
if (config_path) {
|
|
122
128
|
return k0sctl_kubeconfig(config_path);
|