Infrastructure installer for Kubernetes and data platforms
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
k4s CLI Tool
A CLI tool for managing installations and Kubernetes operations.
Project Structure
src/k4s: Main package code.k4s.yml: Optional configuration file for component operations (install/certs).tests/: Tests.
Development Setup
-
Clone the repository (if you haven't already):
git clone <repository_url> cd k4s
-
Create and activate a virtual environment: It's highly recommended to use a virtual environment to manage project dependencies.
python3 -m venv .venv source .venv/bin/activate
(On Windows, use
.venv\Scripts\activate) -
Install dependencies: Install the required Python packages, including development tools like
pytest.python3 -m pip install -r requirements.txt
-
Install the CLI in editable mode: This allows you to run the
k4s(andk4) command from your terminal and have your code changes immediately reflected without reinstalling.python3 -m pip install -e .
After this step, you should be able to run
k4s --helpork4 --helpfrom your terminal (while the virtual environment is active). -
Running Tests: Tests are located in the
tests/directory and can be run usingpytest.python3 -m pytest
(Ensure you are in the project root directory where
pytest.iniis located).-
Running Specific Tests: You can run tests in a specific file, or even a specific test function:
# Run all tests in a specific file python3 -m pytest tests/core/test_downloader.py # Run a specific test function within a file python3 -m pytest tests/core/test_downloader.py::test_download_file_success_with_specific_filename # Run tests containing a specific keyword in their name python3 -m pytest -k "downloader"
-
Viewing Print Statements and Live Logs During Tests: By default, pytest captures output. To see
print()statements or live logging from your tests:# Show standard output (print statements) and disable output capturing python3 -m pytest -s # Show logs at a specific level (e.g., INFO or DEBUG) python3 -m pytest --log-cli-level=INFO python3 -m pytest --log-cli-level=DEBUG # Combine them to see print statements and detailed logs for a specific test file python3 -m pytest -s --log-cli-level=DEBUG tests/core/test_downloader.py
-
Usage
Once installed in editable mode (or as a package), you can use k4s or its alias k4.
- Some commands (e.g.
install,certs) use ak4s.ymlconfiguration file. You can specify a path using the global--configoption:k4s --config path/to/your/custom_k4s.yml install <component_name> # or using the alias k4 --config path/to/your/custom_k4s.yml install <component_name>
- Commands like
contextandclusterdo not requirek4s.yml.
Verbosity
-q/--quiet: only final results and errors- default: concise step output
-v: adds explanations (with optional typing effect)-vv: debug output (more details)
Typing effect can be toggled with --typing/--no-typing.
Contexts (SSH targets)
Create and manage connection contexts (stored under ~/.k4s/contexts.yml):
# interactive wizard
k4s init
# or explicit flags
k4s context add prod -h 10.0.0.10 -u root -i ~/.ssh/id_rsa --current
# list / switch / test
k4s context list
k4s context use prod
k4s context test
Kubernetes clusters (RKE2)
Create an RKE2 cluster using node contexts:
# preflight only (recommended)
k4s cluster preflight \
--control-plane cp1 \
--worker w1
# plan only
k4s cluster create --name lab --type rke2 \
--control-plane cp1 \
--worker w1 \
--cni canal \
--dry-run
# apply (installs rke2 on the nodes)
k4s cluster create --name lab --type rke2 \
--control-plane cp1 \
--worker w1 \
--cni canal
Fetch kubeconfig from the control-plane:
k4s cluster kubeconfig --name lab --control-plane cp1
Supported platforms (current)
This project is early and currently targets Linux servers with systemd.
- Kubernetes (RKE2):
- Required: Linux + systemd, SSH access,
curl, root orsudo -n - Tested: Ubuntu/Debian-family hosts (best-effort for other systemd distros)
- Required: Linux + systemd, SSH access,
- Local machine (running k4s):
- macOS/Linux supported for running the CLI (requires Python 3.12+)
Use k4s cluster preflight to see what each node reports (OS, kernel, systemd, curl, sudo).
Components (install/certs)
Example installing a component (requires k4s.yml present or --config is used):
bash k4s install my_component_1 k4 install my_component_2
Certificate Management
k4s provides certificate operations using the k4s certs command group.
k4s certs apply: Applies the uploaded certificates, setting paths, permissions, and running notification handlers (e.g., reloading a service).k4s certs apply: Applies a certificate configuration using the selected issuer defined ink4s.yml.
This functionality can be controlled declaratively via a certificates section in your k4s.yml or imperatively using command-line flags.
Publishing to PyPI
See docs/pypi-publish.md for build and upload steps.
TODO
- Add detailed usage instructions for each command.
- Describe configuration options in
k4s.ymlin more detail.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file k4s-0.0.1a1.tar.gz.
File metadata
- Download URL: k4s-0.0.1a1.tar.gz
- Upload date:
- Size: 74.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95c908bf4211a9807a6400e81c09cb5e933cb6b49f79b6eedb606adccc8b591e
|
|
| MD5 |
a16c9ab667c039cb66b8b3563de324fc
|
|
| BLAKE2b-256 |
4e3f8803d90d46c07b1b6067abad4d47bd091aa59f336e55bf5101092ee95ba2
|
File details
Details for the file k4s-0.0.1a1-py3-none-any.whl.
File metadata
- Download URL: k4s-0.0.1a1-py3-none-any.whl
- Upload date:
- Size: 91.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8a0837103b12636062d36bc8978a1b06ce513c86dc9ee23147118d4abc8e393
|
|
| MD5 |
3b42433482cc0427c5941820eacd3d1c
|
|
| BLAKE2b-256 |
39cb103dc96a67d54f4c9bcbbf8bc0f40829f85036623903920114a4ddb0b6c1
|