From de54715cee60dc082d9f4e18cdc79af8b5cb8cff Mon Sep 17 00:00:00 2001 From: jessebot Date: Tue, 9 Jan 2024 16:17:11 +0100 Subject: [PATCH] remove setup scripts now that we have brew installation method; updating help screenshot --- README.md | 26 ++- docs/assets/images/screenshots/help_text.svg | 164 +++++++++---------- docs/installation.md | 35 ++-- pyproject.toml | 5 +- setup.sh | 53 ------ smol_k8s_lab/__init__.py | 9 - smol_k8s_lab/config/extras/Brewfile | 29 ---- smol_k8s_lab/k8s_distros/kind.py | 12 +- smol_k8s_lab/k8s_tools/setup_k8s_tools.py | 32 ---- smol_k8s_lab/utils/rich_cli/help_text.py | 4 - 10 files changed, 135 insertions(+), 234 deletions(-) delete mode 100755 setup.sh delete mode 100644 smol_k8s_lab/config/extras/Brewfile delete mode 100644 smol_k8s_lab/k8s_tools/setup_k8s_tools.py diff --git a/README.md b/README.md index 56d0fb975..a471af319 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,27 @@ Here's the same video with # Installation -B sure to check out our full [installation guide](https://small-hack.github.io/smol-k8s-lab/installation/), but the gist of it is `smol-k8s-lab` requires Python 3.11 (and [pip](https://pip.pypa.io/en/stable/installation/)). If you've already got it and [other pre-reqs](https://small-hack.github.io/smol-k8s-lab/installation/#prerequisites), you should be able to: +B sure to check out our full [installation guide](https://small-hack.github.io/smol-k8s-lab/installation/), but the gist of it is `smol-k8s-lab` can be installed via `pip` or `brew`. + +## brew + +[`brew`] is the preferred installation method for macOS/Debian/Ubuntu, as this will also install any prerequisites you need, so you don't need to worry about them. + +```bash +# tap the special homebrew repo for our formula +brew tap small-hack/homebrew-smol-k8s-lab +# then install +brew install smol-k8s-lab +``` + +Then you should be able to check the version and cli options with: + +```bash +smol-k8s-lab --help +``` + +## pip +`smol-k8s-lab` requires Python 3.11+ (and [pip](https://pip.pypa.io/en/stable/installation/)). If you've already got both and [other pre-reqs](https://small-hack.github.io/smol-k8s-lab/installation/#prerequisites), you should be able to: ```bash # install the CLI @@ -47,10 +67,10 @@ Checkout our [TUI docs](https://small-hack.github.io/smol-k8s-lab/tui/create_mod ## Beta release of 2.0.0 -`v2.0.0b7` is available for testing but docs and screenshots are still under development. ETA is about 1-2 weeks for those tests to be complete and the official `2.0.0` to be launched, which will support a full TUI and a range of new options in the config file. To begin testing that release (or [other pre-releases](https://pypi.org/project/smol_k8s_lab/2.0.0b7/#history)) you can do: +`v2.0.0b8` is available for testing but docs and screenshots are still under development. ETA is about 1-2 weeks for those tests to be complete and the official `2.0.0` to be launched, which will support a full TUI and a range of new options in the config file. To begin testing that release (or [other pre-releases](https://pypi.org/project/smol_k8s_lab/2.0.0b8/#history)) you can do: ```bash -pip install smol_k8s_lab==2.0.0b7 +pip install smol_k8s_lab==2.0.0b8 ``` This should have actually been 1.0, but I misunderstood semver, and now here we are, with another major version update. diff --git a/docs/assets/images/screenshots/help_text.svg b/docs/assets/images/screenshots/help_text.svg index eb1e536f1..332b7d9fc 100644 --- a/docs/assets/images/screenshots/help_text.svg +++ b/docs/assets/images/screenshots/help_text.svg @@ -1,4 +1,4 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - + + - term + term - + - -                           ๐Ÿงธsmol k8s lab - -Install slim Kubernetes distros + plus all your apps via Argo CD. - -Usage:smol-k8s-lab[OPTIONS] - -โ•ญโ”€ ส• แต”แดฅแต”ส” Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ -โ”‚โ”‚ -โ”‚-c--config CONFIG_FILEFull path and name of the YAML config file to parse.                โ”‚ -โ”‚Defaults to $XDG_CONFIG_HOME/smol-k8s-lab/config.yamlโ”‚ -โ”‚โ”‚ -โ”‚-D--delete CLUSTER_NAMEDelete an existing cluster by name.                                 โ”‚ -โ”‚โ”‚ -โ”‚-s--setupInstall/update extra tools such as argocd, cilium-cli, helm, k9s,   โ”‚ -โ”‚krew, kubectl, and more via brew.                                   โ”‚ -โ”‚โ”‚ -โ”‚-i--interactiveNew! โš™๏ธ Interactively configures  smol-k8s-labโ”‚ -โ”‚โ”‚ -โ”‚-v--versionPrint the version of smol-k8s-lab (v2.0.0b7)                        โ”‚ -โ”‚โ”‚ -โ”‚-h--helpShow this message and exit.                                         โ”‚ -โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ™ฅ docs: github.com/small-hack/smol-k8s-labโ”€โ•ฏ + +                           ๐Ÿงธsmol k8s lab + +Install slim Kubernetes distros + plus all your apps via Argo CD. + +Usage:smol-k8s-lab[OPTIONS] + +โ•ญโ”€ ส• แต”แดฅแต”ส” Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ +โ”‚โ”‚ +โ”‚-c--config CONFIG_FILEFull path and name of the YAML config file to parse. โ”‚ +โ”‚Defaults to $XDG_CONFIG_HOME/smol-k8s-lab/config.yamlโ”‚ +โ”‚โ”‚ +โ”‚-D--delete CLUSTER_NAMEDelete an existing cluster by name.                  โ”‚ +โ”‚โ”‚ +โ”‚-i--interactiveNew! โš™๏ธ Interactively configures  smol-k8s-labโ”‚ +โ”‚โ”‚ +โ”‚-v--versionPrint the version of smol-k8s-lab (v2.0.0b7)         โ”‚ +โ”‚โ”‚ +โ”‚-h--helpShow this message and exit.                          โ”‚ +โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ™ฅ docs: github.com/small-hack/smol-k8s-labโ”€โ•ฏ diff --git a/docs/installation.md b/docs/installation.md index 5f073bb44..35f4de12e 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -7,9 +7,31 @@ nav_order: 2 permalink: /install --- -## Prerequisites +!!! Note + `smol-k8s-lab` is only tested on Debian, Ubuntu, and macOS. It may run on other Linux distros and even WSL, but we do not actively test them at this time. + +## Install via `brew` + +[brew] is the preferred installation method for macOS/Debian/Ubuntu, as this will also install any prerequisites you need. + +```bash +# tap the special homebrew repo for our formula +brew tap small-hack/homebrew-smol-k8s-lab +# then install +brew install smol-k8s-lab +``` + +Then you should be able to check the version and cli options with: + +```bash +smol-k8s-lab --help +``` + +## Install via `pip` + +### Prerequisites -### Required +#### Required `smol-k8s-lab` cannot function without at least the following installed: @@ -17,15 +39,13 @@ permalink: /install - [`kubectl`](https://kubernetes.io/docs/tasks/tools/) - [`helm`](https://helm.sh/docs/intro/install/) - [`argocd`](https://argo-cd.readthedocs.io/en/stable/cli_installation/) -- Internet access -### Optional +#### Optional All of these are not Required for core functionality of `smol-k8s-lab`, but they greatly enhance the experience, so they are still recommended. | application | description | |-------------|--------------------------------------------------------------------------------------------------------------------------| -| [brew] | If installed, we can install all prerequisites for you (except python/pip, because you need those to run `smol-k8s-lab`) | | [docker] | needed for k3d, kind, and installing the mastodon app | | [bw] | only if you want to use Bitwarden to store your passwords | | [k3d] | only if you want to use k3d | @@ -33,11 +53,6 @@ All of these are not Required for core functionality of `smol-k8s-lab`, but they | [kind] | only if you want to use kind | | [mc] | only if you want smol-k8s-lab to create MinIO users and buckets for you | -## Install via `pip` - -!!! Note - `smol-k8s-lab` is only tested on Debian, Ubuntu, and macOS. It may run on other Linux distros and even WSL, but we do not actively test them at this time. - `pip` is probably the best way to install `smol-k8s-lab`, but you can also probably use `pipx`: diff --git a/pyproject.toml b/pyproject.toml index 89a1301f7..fa9db2eac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "smol_k8s_lab" -version = "2.0.0b7" +version = "2.0.0b8" description = "Bootstrap simple projects on Kubernetes with kind, k3d, and k3s. This is a beta release" authors = ["Jesse Hitch ", "Max Roby "] @@ -11,7 +11,7 @@ homepage = "https://small-hack.github.io/smol-k8s-lab" repository = "http://github.com/small-hack/smol-k8s-lab" documentation = "https://small-hack.github.io/smol-k8s-lab" keywords = ["kubernetes", "homelab", "kind", "k3s", "k8s"] -classifiers = ["Development Status :: 3 - Alpha", +classifiers = ["Development Status :: 4 - Beta", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Operating System :: MacOS :: MacOS X", @@ -20,7 +20,6 @@ classifiers = ["Development Status :: 3 - Alpha", "Topic :: System :: Installation/Setup", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)"] include = ["smol_k8s_lab/config/kind/kind_cluster_config.yaml", - "smol_k8s_lab/config/extras/Brewfile", "smol_k8s_lab/config/default_config.yaml"] [tool.poetry.urls] diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 101a9f389..000000000 --- a/setup.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -#============================================================================= -# USAGE: ./setup.sh -# DESCRIPTION: Setup the extra dependencies for the Smol K8s Lab -# REQUIREMENTS: python3.11, brew -# AUTHOR: @jessebot -#============================================================================= - -# if `which brew` returns a path -if [ -n "$(which brew)" ]; then - echo -e "\nInstalling/Updating brew dependencies...\n" - brew update - brew bundle --file=./deps/Brewfile - brew upgrade - echo -e "\nbrew dependencies installed." -else - echo -e "\nBrew not installed." - echo -e "\nPlease install brew by running the following command:" - echo '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' - echo -e "\nThen you can run the setup.sh script again." -fi - -# if kubectl installed then install plugins with krew plugin manager for kubectl -if [ -n "$(which kubectl)" ]; then - echo -e "\nInstalling/Upgrading krew plugins for kubectl...\n" - echo -e " -------------------------------------------------- " - echo -e "| Krew Plugin | Description |" - echo -e "|--------------|-----------------------------------|" - echo -e "| ctx | context switching |" - echo -e "| ns | changing namespaces of context |" - echo -e "| example | outputting example yaml |" - echo -e "| deprecations | check which things are deprecated |" - echo -e " -------------------------------------------------- \n" - - kubectl krew install < deps/kubectl_krew_plugins - kubectl krew upgrade -else - echo -e "\nkubectl not installed. Please install kubectl and rerun the script." -fi - -# make sure they've set a KUBECONFIG location -if [ -n "$KUBECONFIG" ]; then - if [[ "$(uname)" == *"Darwin"* ]]; then - echo "export KUBECONFIG=~/.kube/kubeconfig" >> ~/.bash_profile - else - echo "export KUBECONFIG=~/.kube/kubeconfig" >> ~/.bashrc - fi -fi - -# fin -echo -e "\033[92m\nSetup completed. Don't forget to run:\n" -echo 'echo "export KUBECONFIG=~/.kube/kubeconfig" >> ~/.bashrc' -echo -e "\n(Replace .bashrc with .bash_profile if you are on a mac)" diff --git a/smol_k8s_lab/__init__.py b/smol_k8s_lab/__init__.py index c55435f79..a3575b438 100755 --- a/smol_k8s_lab/__init__.py +++ b/smol_k8s_lab/__init__.py @@ -98,9 +98,6 @@ def process_log_config(log_dict: dict = {"level": "warn", "file": ""}): metavar="CLUSTER_NAME", type=str, help=HELP['delete']) -@option("--setup", "-s", - is_flag=True, - help=HELP['setup']) @option("--interactive", "-i", is_flag=True, help=HELP['interactive']) @@ -109,7 +106,6 @@ def process_log_config(log_dict: dict = {"level": "warn", "file": ""}): help=HELP['version']) def main(config: str = "", delete: bool = False, - setup: bool = False, log_file: str = "", version: bool = False, interactive: bool = False): @@ -148,11 +144,6 @@ def main(config: str = "", if interactive or tui_enabled: cluster_name, USR_CFG, SECRETS, bitwarden_credentials = launch_config_tui(config_dict) else: - if setup: - # installs required/extra tooling: kubectl, helm, k9s, argocd, krew - from .utils.setup_k8s_tools import do_setup - do_setup() - # process all of the config file, or create a new one and also grab secrets USR_CFG, SECRETS = process_configs(config_dict) diff --git a/smol_k8s_lab/config/extras/Brewfile b/smol_k8s_lab/config/extras/Brewfile deleted file mode 100644 index 4c35064c7..000000000 --- a/smol_k8s_lab/config/extras/Brewfile +++ /dev/null @@ -1,29 +0,0 @@ -# kubernetes in docker -brew "kind" - -# k3d is k3s in docker -brew "k3d" - -# kubernetes cli -brew "kubernetes-cli" - -# k8s package manager -brew "helm" - -# package manager installing kubectl plugins -brew "krew" - -# k8s dashboard -brew "k9s" - -# for Argo CD command line interface -brew "argocd" - -# this is for bitwarden to work as your password manager -brew "bitwarden-cli" - -# this is for managing cilium -brew "cilium-cli" - -# this is for managing minio clients -brew "minio-mc" diff --git a/smol_k8s_lab/k8s_distros/kind.py b/smol_k8s_lab/k8s_distros/kind.py index 2380b3747..7df89ad2b 100644 --- a/smol_k8s_lab/k8s_distros/kind.py +++ b/smol_k8s_lab/k8s_distros/kind.py @@ -13,6 +13,7 @@ from ruamel.yaml import YAML from ruamel.yaml.scalarstring import PreservedScalarString as pss from shutil import which +from sys import exit yaml = YAML() @@ -34,10 +35,15 @@ def create_kind_cluster(cluster_name: str, # make sure kind is installed first, and if not, install it if not which("kind"): msg = ("ส•โ€ขฬแดฅโ€ขฬ€ส” [b]kind[/b] is [warn]not installed[/warn]. " - "[i]We'll install it for you.[/i] ส•แต”แดฅแต”ส”") + "[i]We'll try to install it for you.[/i] ส•แต”แดฅแต”ส”") sub_header(msg) - log.debug("Installing kind with brew...") - subproc(['brew install kind'], spinner=True) + if which("brew"): + log.debug("Installing kind with brew...") + subproc(['brew install kind'], spinner=True) + else: + log.error("Sorry, you don't have brew installed. :( " + \ + "Please install [b]kind[/b] and run smol-k8s-lab again") + exit() log.debug("Creating a kind cluster...") diff --git a/smol_k8s_lab/k8s_tools/setup_k8s_tools.py b/smol_k8s_lab/k8s_tools/setup_k8s_tools.py deleted file mode 100644 index 22b2cec87..000000000 --- a/smol_k8s_lab/k8s_tools/setup_k8s_tools.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3.11 -""" - Name: extras -DESCRIPTION: install extra tooling related to k8s - AUTHOR: - LICENSE: GNU AFFERO GENERAL PUBLIC LICENSE Version 3 -""" -from os import path -from..utils.subproc import subproc -from .constants import PWD - - -def do_setup(): - """ - - Install/Update brew dependencies from Brewfile: - docker, kind, kubectl, helm, krew, k9s, argocd, bitwarden-cli - - Install/Update kubectl plugins with krew: - ctx, ns, example, deprecations - - returns True - """ - brewfile = path.join(PWD, 'config/extras/Brewfile') - cmds = [f"brew bundle --file={brewfile}", - "kubectl krew install ctx", - "kubectl krew install ns", - "kubectl krew install example", - "kubectl krew install deprecations", - "kubectl krew update", - "kubectl krew upgrade"] - subproc(cmds, error_ok=True) - - return True diff --git a/smol_k8s_lab/utils/rich_cli/help_text.py b/smol_k8s_lab/utils/rich_cli/help_text.py index 1eb27057b..88c3d0848 100755 --- a/smol_k8s_lab/utils/rich_cli/help_text.py +++ b/smol_k8s_lab/utils/rich_cli/help_text.py @@ -37,10 +37,6 @@ def options_help(): 'delete': 'Delete an existing cluster by name.', - 'setup': - 'Install/update extra tools such as argocd, cilium-cli, helm, k9s, krew, ' - 'kubectl, and more via brew.', - 'interactive': 'New! โš™๏ธ Interactively configures smol-k8s-lab',