@bryanjbelanger/talos-skills 1.0.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.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Talos Linux Skills Suite for Pi
2
+
3
+ A complete **Pi Skills** suite for managing immutable [Talos Linux](https://www.talos.dev) Kubernetes clusters and machine nodes directly via `talosctl`.
4
+
5
+ ---
6
+
7
+ ## Included Skills
8
+
9
+ | Skill | Description | Usage Command |
10
+ | :--- | :--- | :--- |
11
+ | **`talos-cluster`** | Generating configs, applying node configurations, bootstrapping etcd, fetching `kubeconfig`, and validating cluster health. | `/skill:talos-cluster` |
12
+ | **`talos-node`** | Inspecting machine services, viewing logs (`kubelet`, `dmesg`), rebooting, OS upgrades, and node resets. | `/skill:talos-node` |
13
+
14
+ ---
15
+
16
+ ## Prerequisites
17
+
18
+ * **Node.js v20.6+**
19
+ * `talosctl` CLI (automatically downloaded and configured on first use if absent).
20
+
21
+ ---
22
+
23
+ ## Installation & Usage
24
+
25
+ ### Option A: Install via npm package
26
+ In any project:
27
+ ```bash
28
+ npm install --save-dev @bryanjbelanger/talos-skills
29
+ ```
30
+ And add to `.pi/settings.json`:
31
+ ```json
32
+ {
33
+ "skills": ["node_modules/@bryanjbelanger/talos-skills"]
34
+ }
35
+ ```
36
+
37
+ ---
38
+
39
+ ## License
40
+
41
+ MIT License
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@bryanjbelanger/talos-skills",
3
+ "version": "1.0.0",
4
+ "description": "Talos Linux Kubernetes cluster management skills suite for Pi agent using talosctl CLI.",
5
+ "type": "module",
6
+ "main": "scripts/talosctl-helper.js",
7
+ "bin": {
8
+ "talosctl-helper": "scripts/talosctl-helper.js"
9
+ },
10
+ "files": [
11
+ "skills/",
12
+ "scripts/",
13
+ "README.md"
14
+ ],
15
+ "pi": {
16
+ "skills": [
17
+ "skills"
18
+ ]
19
+ },
20
+ "keywords": [
21
+ "pi",
22
+ "pi-skill",
23
+ "talos",
24
+ "talosctl",
25
+ "kubernetes",
26
+ "k8s",
27
+ "siderolabs",
28
+ "devops"
29
+ ],
30
+ "author": "Bryan Belanger <bryanbelanger@hotmail.com>",
31
+ "license": "MIT"
32
+ }
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import os from "os";
5
+ import { execSync } from "child_process";
6
+
7
+ const TALOS_VERSION = "v1.9.4";
8
+
9
+ function getPlatform() {
10
+ const platform = os.platform();
11
+ const arch = os.arch();
12
+ let osName = platform;
13
+ if (platform === "darwin") osName = "darwin";
14
+ else if (platform === "linux") osName = "linux";
15
+ else if (platform === "win32") osName = "windows";
16
+
17
+ let archName = arch;
18
+ if (arch === "x64") archName = "amd64";
19
+ else if (arch === "arm64") archName = "arm64";
20
+
21
+ return { osName, archName };
22
+ }
23
+
24
+ async function ensureTalosctl() {
25
+ try {
26
+ execSync("talosctl version --client --short", { stdio: "ignore" });
27
+ return "talosctl";
28
+ } catch {
29
+ // Check local bin fallback
30
+ const binDir = path.join(process.env.HOME || "", ".local", "bin");
31
+ const localBinary = path.join(binDir, process.platform === "win32" ? "talosctl.exe" : "talosctl");
32
+ if (fs.existsSync(localBinary)) {
33
+ return localBinary;
34
+ }
35
+
36
+ fs.mkdirSync(binDir, { recursive: true });
37
+ const { osName, archName } = getPlatform();
38
+ const downloadUrl = `https://github.com/siderolabs/talos/releases/download/${TALOS_VERSION}/talosctl-${osName}-${archName}`;
39
+
40
+ console.log(`Downloading talosctl ${TALOS_VERSION} for ${osName}/${archName}...`);
41
+ const res = await fetch(downloadUrl);
42
+ if (!res.ok) throw new Error(`Failed to download talosctl from ${downloadUrl}: ${res.statusText}`);
43
+
44
+ const fileStream = fs.createWriteStream(localBinary);
45
+ const reader = res.body.getReader();
46
+ while (true) {
47
+ const { done, value } = await reader.read();
48
+ if (done) break;
49
+ fileStream.write(value);
50
+ }
51
+ fileStream.end();
52
+
53
+ if (process.platform !== "win32") {
54
+ fs.chmodSync(localBinary, 0o755);
55
+ }
56
+
57
+ console.log(`talosctl installed to ${localBinary}`);
58
+ return localBinary;
59
+ }
60
+ }
61
+
62
+ async function main() {
63
+ const binary = await ensureTalosctl();
64
+ const args = process.argv.slice(2);
65
+ if (args.length > 0) {
66
+ try {
67
+ const output = execSync(`"${binary}" ${args.join(" ")}`, { encoding: "utf-8" });
68
+ console.log(output);
69
+ } catch (err) {
70
+ console.error(err.stdout || err.stderr || err.message);
71
+ process.exit(err.status || 1);
72
+ }
73
+ } else {
74
+ console.log(`talosctl binary ready: ${binary}`);
75
+ }
76
+ }
77
+
78
+ main().catch(err => {
79
+ console.error("Error:", err.message);
80
+ process.exit(1);
81
+ });
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: talos-cluster
3
+ description: Create, configure, bootstrap, and validate Talos Linux Kubernetes clusters using talosctl. Use when generating machine configs, applying node configs, bootstrapping etcd, fetching kubeconfig, or checking cluster health.
4
+ ---
5
+
6
+ # Talos Linux Cluster Management
7
+
8
+ ## Preflight
9
+
10
+ Verify `talosctl` is installed (auto-installed if missing via helper):
11
+ ```bash
12
+ node ./scripts/talosctl-helper.js version --client
13
+ ```
14
+
15
+ ---
16
+
17
+ ## 1. Generate Machine Configs
18
+
19
+ Generate Talos machine configurations for control plane and worker nodes along with `talosconfig`:
20
+ ```bash
21
+ # Syntax: talosctl gen config <cluster-name> <cluster-endpoint-url> --output-dir <dir>
22
+ node ./scripts/talosctl-helper.js gen config "vbox-dc" "https://10.0.10.10:6443" --output-dir ./talos-config
23
+ ```
24
+ *Produces `controlplane.yaml`, `worker.yaml`, and `talosconfig`.*
25
+
26
+ ---
27
+
28
+ ## 2. Apply Machine Config to Nodes
29
+
30
+ Apply the generated machine configs to fresh Talos nodes in maintenance mode:
31
+
32
+ ```bash
33
+ # Apply to Control Plane Node (insecure initial apply before TLS PKI is active)
34
+ node ./scripts/talosctl-helper.js apply-config --insecure --nodes 10.0.10.10 --file ./talos-config/controlplane.yaml
35
+
36
+ # Apply to Worker Node
37
+ node ./scripts/talosctl-helper.js apply-config --insecure --nodes 10.0.20.20 --file ./talos-config/worker.yaml
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 3. Configure Local talosctl Client
43
+
44
+ Merge the generated `talosconfig` context and target the control plane endpoint:
45
+ ```bash
46
+ # Merge context
47
+ node ./scripts/talosctl-helper.js config merge ./talos-config/talosconfig
48
+ node ./scripts/talosctl-helper.js config endpoint 10.0.10.10
49
+ node ./scripts/talosctl-helper.js config node 10.0.10.10
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 4. Bootstrap etcd Cluster
55
+
56
+ Bootstrap the primary control plane node (run **once** per cluster):
57
+ ```bash
58
+ node ./scripts/talosctl-helper.js bootstrap --nodes 10.0.10.10
59
+ ```
60
+
61
+ ---
62
+
63
+ ## 5. Retrieve Kubeconfig & Verify Health
64
+
65
+ Fetch cluster kubeconfig and verify Kubernetes API accessibility:
66
+ ```bash
67
+ # Retrieve kubeconfig
68
+ node ./scripts/talosctl-helper.js kubeconfig . --nodes 10.0.10.10
69
+
70
+ # Validate cluster health
71
+ node ./scripts/talosctl-helper.js health --nodes 10.0.10.10
72
+ ```
73
+
74
+ Verify with `kubectl`:
75
+ ```bash
76
+ kubectl --kubeconfig ./kubeconfig get nodes -o wide
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Advanced Topics & Reference Guides
82
+ * For machine config patches, inline JSON/YAML overlays, and HA VIP setup, see `references/config-patches.md`.
83
+
@@ -0,0 +1,36 @@
1
+ # Talos Machine Config Patches & HA Clusters
2
+
3
+ ## Machine Config Patches
4
+
5
+ Talos uses JSON/YAML Strategic Merge Patches (`--config-patch`) or inline JSON patches (`--config-patch-control-plane`) when generating machine configurations.
6
+
7
+ ### 1. Define Patch (`patch.yaml`)
8
+ Example: Enable VIP (Virtual IP) for HA Control Plane and enable extra kernel arguments:
9
+
10
+ ```yaml
11
+ machine:
12
+ network:
13
+ interfaces:
14
+ - interface: eth0
15
+ dhcp: true
16
+ vip:
17
+ ip: 10.0.10.100
18
+ sysctls:
19
+ net.ipv4.ip_forward: "1"
20
+ cluster:
21
+ extraManifests:
22
+ - https://raw.githubusercontent.com/alex1989hu/kubelet-serving-cert-approver/main/deploy/ha-control-plane-k8s-1.27.yaml
23
+ ```
24
+
25
+ ### 2. Apply Patch During Config Generation
26
+ ```bash
27
+ talosctl gen config "vbox-dc" "https://10.0.10.100:6443" \
28
+ --config-patch @patch.yaml \
29
+ --output-dir ./talos-config
30
+ ```
31
+
32
+ ### 3. Patching Live Nodes
33
+ Apply patches to live running nodes without full reconfiguration:
34
+ ```bash
35
+ talosctl patch machineconfig --nodes 10.0.10.10 --patch '[{"op": "replace", "path": "/machine/time/servers/0", "value": "pool.ntp.org"}]'
36
+ ```
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: talos-node
3
+ description: Manage Talos Linux nodes — inspect machine status, view service logs, reboot, upgrade, or reset nodes via talosctl. Use when checking Talos node health, viewing dmesg/logs, rebooting nodes, or upgrading Talos OS.
4
+ ---
5
+
6
+ # Talos Node Operations
7
+
8
+ ## Preflight
9
+
10
+ Verify `talosctl` client configuration:
11
+ ```bash
12
+ node ./scripts/talosctl-helper.js version --nodes 10.0.10.10
13
+ ```
14
+
15
+ ---
16
+
17
+ ## 1. Inspect Node Status & Services
18
+
19
+ ### View Machine Services & Resources
20
+ ```bash
21
+ # List running Talos machine services (etcd, kubelet, containerd, etc.)
22
+ node ./scripts/talosctl-helper.js service --nodes 10.0.10.10
23
+
24
+ # Get machine members and cluster state
25
+ node ./scripts/talosctl-helper.js get members --nodes 10.0.10.10
26
+ ```
27
+
28
+ ### View Logs & Kernel Messages
29
+ ```bash
30
+ # View kubelet or containerd logs
31
+ node ./scripts/talosctl-helper.js logs kubelet --nodes 10.0.10.10
32
+ node ./scripts/talosctl-helper.js logs containerd --nodes 10.0.10.10
33
+
34
+ # View kernel dmesg
35
+ node ./scripts/talosctl-helper.js dmesg --nodes 10.0.10.10
36
+ ```
37
+
38
+ ---
39
+
40
+ ## 2. Node Lifecycle Operations
41
+
42
+ ### Reboot Node
43
+ ```bash
44
+ node ./scripts/talosctl-helper.js reboot --nodes 10.0.10.10
45
+ ```
46
+
47
+ ### Upgrade Talos OS Image
48
+ Upgrade a node to a newer Talos Linux installer image:
49
+ ```bash
50
+ node ./scripts/talosctl-helper.js upgrade --nodes 10.0.10.10 --image factory.talos.dev/installer/v1.9.4
51
+ ```
52
+
53
+ ### Reset Node (Wipe & Return to Maintenance Mode)
54
+ Wipe node data disk and reset to clean installer state:
55
+ ```bash
56
+ node ./scripts/talosctl-helper.js reset --nodes 10.0.10.10 --system-labels-to-wipe STATE,EPHEMERAL --reboot
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Advanced Topics & Reference Guides
62
+ * For etcd snapshots, restores, process/memory stats, container inspection, and disk layouts, see `references/etcd-and-troubleshooting.md`.
63
+
@@ -0,0 +1,52 @@
1
+ # Talos Etcd Operations, Containers & Troubleshooting
2
+
3
+ ## Etcd Maintenance & Backup
4
+
5
+ ### 1. Etcd Status & Health
6
+ ```bash
7
+ # Check etcd members and health
8
+ talosctl etcd members --nodes 10.0.10.10
9
+ talosctl etcd status --nodes 10.0.10.10
10
+ talosctl etcd alarm list --nodes 10.0.10.10
11
+ ```
12
+
13
+ ### 2. Etcd Snapshot Backup & Restore
14
+ ```bash
15
+ # Take etcd snapshot
16
+ talosctl etcd snapshot ./etcd-backup.snapshot --nodes 10.0.10.10
17
+
18
+ # Defrag etcd database
19
+ talosctl etcd defrag --nodes 10.0.10.10
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Machine Inspection & Diagnostics
25
+
26
+ ### 1. Running Containers & Processes
27
+ ```bash
28
+ # List all running CRI containers on node
29
+ talosctl containers --nodes 10.0.10.10
30
+ talosctl containers --nodes 10.0.10.10 --kubernetes
31
+
32
+ # Inspect processes and resource usage
33
+ talosctl processes --nodes 10.0.10.10
34
+ talosctl stats --nodes 10.0.10.10
35
+ talosctl memory --nodes 10.0.10.10
36
+ ```
37
+
38
+ ### 2. Disks & Mounts
39
+ ```bash
40
+ # List disks and partition layout
41
+ talosctl disks --nodes 10.0.10.10
42
+ talosctl mounts --nodes 10.0.10.10
43
+ ```
44
+
45
+ ### 3. Read Machine Configuration & Files
46
+ ```bash
47
+ # Retrieve live running machine configuration
48
+ talosctl get machineconfig --nodes 10.0.10.10
49
+
50
+ # Read file from node filesystem
51
+ talosctl read /etc/hosts --nodes 10.0.10.10
52
+ ```