k3-cluster-cli 0.1.3__py3-none-any.whl

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.
File without changes
cluster_cli/main.py ADDED
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env python3
2
+ import subprocess
3
+ import sys
4
+ import typer
5
+ import requests
6
+
7
+ app = typer.Typer()
8
+
9
+ # Version info
10
+ __version__ = "0.1.3"
11
+ PYPI_PACKAGE_NAME = "k3-cluster-cli"
12
+
13
+
14
+ def get_latest_version_from_pypi():
15
+ """Fetch the latest version from PyPI."""
16
+ try:
17
+ response = requests.get(
18
+ f"https://pypi.org/pypi/{PYPI_PACKAGE_NAME}/json",
19
+ timeout=5
20
+ )
21
+ response.raise_for_status()
22
+ data = response.json()
23
+ return data["info"]["version"]
24
+ except Exception as e:
25
+ print(f"Warning: Could not check PyPI for updates: {e}", file=sys.stderr)
26
+ return None
27
+
28
+
29
+ @app.command()
30
+ def version():
31
+ """Show the current version and check for updates."""
32
+ print(f"cluster CLI version {__version__}")
33
+
34
+ latest = get_latest_version_from_pypi()
35
+
36
+ if latest:
37
+ if latest == __version__:
38
+ print("✓ You are running the latest version")
39
+ else:
40
+ print(f"→ New version available: {latest}")
41
+ print(f" Run 'cluster upgrade' to update")
42
+
43
+
44
+ @app.command()
45
+ def upgrade():
46
+ """Upgrade the cluster CLI to the latest version from PyPI."""
47
+ print("=== Checking for latest version ===")
48
+ latest = get_latest_version_from_pypi()
49
+
50
+ if not latest:
51
+ print("Error: Could not fetch latest version from PyPI")
52
+ sys.exit(1)
53
+
54
+ if latest == __version__:
55
+ print("✓ Already running the latest version")
56
+ return
57
+
58
+ print(f"Upgrading from {__version__} to {latest}...")
59
+
60
+ try:
61
+ result = subprocess.run(
62
+ [sys.executable, "-m", "pip", "install", "--upgrade", "--break-system-packages", PYPI_PACKAGE_NAME],
63
+ capture_output=True,
64
+ text=True
65
+ )
66
+
67
+ if result.returncode != 0:
68
+ print(f"Error upgrading: {result.stderr}")
69
+ sys.exit(1)
70
+
71
+ print(f"\n✓ Successfully upgraded to version {latest}")
72
+ print(" Restart your shell or run 'hash -r' to use the new version")
73
+
74
+ except Exception as e:
75
+ print(f"Error during upgrade: {e}")
76
+ sys.exit(1)
77
+
78
+
79
+ @app.command()
80
+ def reboot():
81
+ """Check cluster health and reboot the node."""
82
+ print("=== Checking cluster health ===")
83
+ subprocess.run(["kubectl", "get", "nodes"])
84
+ subprocess.run("kubectl get pods -A | grep -v 'Running\\|Completed'", shell=True)
85
+
86
+ print()
87
+ response = typer.confirm("Proceed with reboot?")
88
+
89
+ if response:
90
+ print("=== Rebooting in 5 seconds ===")
91
+ subprocess.run(["sleep", "5"])
92
+ subprocess.run(["sudo", "reboot"])
93
+
94
+
95
+ @app.command()
96
+ def info():
97
+ """Watch cluster info with live updates."""
98
+ watch_cmd = """
99
+ echo "=== NODES ==="
100
+ kubectl top nodes
101
+ echo ""
102
+ echo "=== NODE STATUS ==="
103
+ kubectl get nodes
104
+ echo ""
105
+ echo "=== PODS (all namespaces) ==="
106
+ kubectl top pods -A --sort-by=memory | head -15
107
+ echo ""
108
+ echo "=== PROBLEM PODS ==="
109
+ kubectl get pods -A | grep -v Running | grep -v Completed | head -10
110
+ """
111
+ subprocess.run(["watch", "-n", "1", watch_cmd])
112
+
113
+
114
+ if __name__ == "__main__":
115
+ app()
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: k3-cluster-cli
3
+ Version: 0.1.3
4
+ Summary: Minimal CLI for managing your K3s cluster
5
+ Author-email: Aleksey Lichtman <alichtman@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://gitlab.com/aleksey-lichtman/k3-cluster-cli
8
+ Project-URL: Repository, https://gitlab.com/aleksey-lichtman/k3-cluster-cli
9
+ Project-URL: Issues, https://gitlab.com/aleksey-lichtman/k3-cluster-cli/-/issues
10
+ Keywords: k3s,kubernetes,cluster,cli,raspberry-pi
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: System Administrators
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: System :: Systems Administration
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: typer>=0.9.0
25
+ Requires-Dist: requests>=2.31.0
26
+ Dynamic: license-file
27
+
28
+ # K3s Cluster CLI
29
+
30
+ Minimal CLI for managing your K3s cluster.
31
+
32
+ ## Installation
33
+
34
+ ### From PyPI (Recommended)
35
+
36
+ **On Raspberry Pi / Debian-based systems:**
37
+ ```bash
38
+ pip install --break-system-packages k3-cluster-cli
39
+ ```
40
+
41
+ **On other systems:**
42
+ ```bash
43
+ pip install k3-cluster-cli
44
+ ```
45
+
46
+ **Alternative: Using pipx (recommended for CLI tools):**
47
+ ```bash
48
+ pipx install k3-cluster-cli
49
+ ```
50
+
51
+ ### From Source
52
+
53
+ ```bash
54
+ git clone https://gitlab.com/aleksey-lichtman/k3-cluster-cli.git
55
+ cd k3-cluster-cli
56
+ pip install -e .
57
+ ```
58
+
59
+ ## Commands
60
+
61
+ ```bash
62
+ cluster reboot # Check cluster health and reboot
63
+ cluster info # Watch live cluster info
64
+ cluster version # Check for updates
65
+ cluster upgrade # Upgrade to latest version
66
+ ```
67
+
68
+ ## Requirements
69
+
70
+ - Python 3.8+
71
+ - kubectl (configured for your cluster)
72
+ - Access to a K3s cluster
73
+
74
+ ## Development
75
+
76
+ Build the package:
77
+
78
+ ```bash
79
+ python -m build
80
+ ```
81
+
82
+ ## License
83
+
84
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,8 @@
1
+ cluster_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ cluster_cli/main.py,sha256=_sP0tG5caCB6anaOG7nl-_6J3mbKQJTaIoxYXbLJ5lg,3091
3
+ k3_cluster_cli-0.1.3.dist-info/licenses/LICENSE,sha256=NMwHD_TEfISn8bfkRiLP4VsCoBVqycPZ-urJk2NinH4,1073
4
+ k3_cluster_cli-0.1.3.dist-info/METADATA,sha256=75iQDs3Yp_7frVEMsHN-dqPVJSDAXnyWPZ4It7m-GYg,2084
5
+ k3_cluster_cli-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ k3_cluster_cli-0.1.3.dist-info/entry_points.txt,sha256=E7cNaexkUDgl4WAwt7VoI25WGjssFxxta5MEgC4Er8s,49
7
+ k3_cluster_cli-0.1.3.dist-info/top_level.txt,sha256=ku5pqB972t2lIFHMRnRb4hRwWtecz-qMOZQIEeRcyKo,12
8
+ k3_cluster_cli-0.1.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cluster = cluster_cli.main:app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aleksey Lichtman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ cluster_cli