From 7b9a98899e3892c2feb43cfb31b76b6a2eccb3c0 Mon Sep 17 00:00:00 2001 From: jessebot Date: Wed, 10 Jan 2024 20:14:59 +0100 Subject: [PATCH 1/3] fix #132: don't overwrite k3s custom config --- docs/assets/images/screenshots/help_text.svg | 152 +++++++++--------- pyproject.toml | 2 +- smol_k8s_lab/tui/distro_screen.py | 28 ++-- smol_k8s_lab/tui/distro_widgets/k3s_config.py | 5 - 4 files changed, 93 insertions(+), 94 deletions(-) diff --git a/docs/assets/images/screenshots/help_text.svg b/docs/assets/images/screenshots/help_text.svg index 166f553ee..01d193174 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.                  โ”‚ -โ”‚โ”‚ -โ”‚-i--interactiveNew! โš™๏ธ Interactively configures  smol-k8s-labโ”‚ -โ”‚โ”‚ -โ”‚-v--versionPrint the version of smol-k8s-lab (v2.0.0)           โ”‚ -โ”‚โ”‚ -โ”‚-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.1)           โ”‚ +โ”‚โ”‚ +โ”‚-h--helpShow this message and exit.                          โ”‚ +โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ™ฅ docs: github.com/small-hack/smol-k8s-labโ”€โ•ฏ diff --git a/pyproject.toml b/pyproject.toml index 24d6d9ef6..d289a4734 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "smol_k8s_lab" -version = "2.0.0" +version = "2.0.1" description = "Bootstrap simple projects on Kubernetes with kind, k3d, and k3s." authors = ["Jesse Hitch ", "Max Roby "] diff --git a/smol_k8s_lab/tui/distro_screen.py b/smol_k8s_lab/tui/distro_screen.py index b7d698652..cd1608789 100755 --- a/smol_k8s_lab/tui/distro_screen.py +++ b/smol_k8s_lab/tui/distro_screen.py @@ -128,9 +128,9 @@ def on_mount(self) -> None: ) else: main_box.mount( - K3ConfigWidget( + K3sConfigWidget( self.current_distro, - DEFAULT_DISTRO_OPTIONS[self.current_distro], + self.cfg.get('k3s', DEFAULT_DISTRO_OPTIONS['k3s']), id=self.current_distro + "-pseudo-screen" ) ) @@ -158,7 +158,7 @@ def update_k8s_distro(self, event: Select.Changed) -> None: ) else: self.get_widget_by_id("distro-config-screen").mount( - K3ConfigWidget( + K3sConfigWidget( distro, DEFAULT_DISTRO_OPTIONS[distro], id=distro + "-pseudo-screen" @@ -253,11 +253,14 @@ def on_mount(self) -> None: # update tabbed content box tabbed_content = self.query_one(TabbedContent) - tabbed_content.border_title = ("Add [i]extra[/] options for " - "[#C1FF87]kind[/] config files") + tabbed_content.border_title = ( + "Add [i]extra[/] options for [#C1FF87]kind[/] config files" + ) + + subtitle = ( + "[b][@click=screen.launch_new_option_modal()] โž• kind option[/][/]" + ) - subtitle = ("[b][@click=screen.launch_new_option_modal()]" - "โž• kind option[/][/]") tabbed_content.border_subtitle = subtitle for tab in self.query("Tab"): @@ -273,13 +276,13 @@ def speak_when_tab_selected(self, event: TabbedContent.TabActivated) -> None: self.app.action_say(f"Selected tab is {event.tab.id}") -class K3ConfigWidget(Static): +class K3sConfigWidget(Static): """ a widget representing the entire kind configuration """ def __init__(self, distro: str, metadata: dict, id: str = "") -> None: - self.metadata = metadata self.distro = distro + self.metadata = metadata super().__init__(id=id) def compose(self) -> ComposeResult: @@ -289,8 +292,8 @@ def compose(self) -> ComposeResult: with Grid(classes="k8s-distro-config", id=f"{self.distro}-box"): # take number of nodes from config and make string - nodes = self.metadata.get('nodes', {'control_plane': 1, - 'workers': 0}) + nodes = self.metadata.get('nodes', + {'control_plane': 1, 'workers': 0}) control_nodes = str(nodes.get('control_plane', '1')) worker_nodes = str(nodes.get('workers', '0')) @@ -298,5 +301,6 @@ def compose(self) -> ComposeResult: yield NodeAdjustmentBox(self.distro, control_nodes, worker_nodes) # take extra k3s args if self.distro is k3s or k3d - yield K3sConfig(self.distro, self.metadata['k3s_yaml'], + yield K3sConfig(self.distro, + self.metadata['k3s_yaml'], id=f"{self.distro}-widget") diff --git a/smol_k8s_lab/tui/distro_widgets/k3s_config.py b/smol_k8s_lab/tui/distro_widgets/k3s_config.py index c02cb2e3f..19194e083 100644 --- a/smol_k8s_lab/tui/distro_widgets/k3s_config.py +++ b/smol_k8s_lab/tui/distro_widgets/k3s_config.py @@ -96,11 +96,6 @@ def on_mount(self) -> None: if arg: self.generate_row(arg, value) - # don't remember why we needed this, but testing breaks with these errors if it's on: - # RuntimeWarning: Enable tracemalloc to get the object allocation traceback - # RuntimeWarning: coroutine 'App.action_focus' was never awaited - # self.app.action_focus(self.query_one(".k3s-config-container")) - def on_button_pressed(self, event: Button.Pressed) -> None: """ get pressed button and act on it From 44065da2724fb56475b578c11cfbd47a872524fc Mon Sep 17 00:00:00 2001 From: jessebot Date: Wed, 10 Jan 2024 20:25:17 +0100 Subject: [PATCH 2/3] change README ordering of upgrade instructions and make sure tests ignore docs/ci changes --- .github/workflows/test-smol-k8s-lab.yml | 4 ++ README.md | 93 +++++++++++++------------ 2 files changed, 51 insertions(+), 46 deletions(-) diff --git a/.github/workflows/test-smol-k8s-lab.yml b/.github/workflows/test-smol-k8s-lab.yml index 5cde7e8b3..c94354e24 100644 --- a/.github/workflows/test-smol-k8s-lab.yml +++ b/.github/workflows/test-smol-k8s-lab.yml @@ -4,6 +4,10 @@ on: push: branches-ignore: - "main" + paths-ignore: + - ".github/**" + - "README.md" + - "docs/**" jobs: smol_k8s_lab_kind: runs-on: ubuntu-latest diff --git a/README.md b/README.md index eab4e58ae..3b6610a27 100644 --- a/README.md +++ b/README.md @@ -73,52 +73,6 @@ After you've followed the installation instructions, if you're *new* to `smol-k8 smol-k8s-lab ``` -
-

Upgrading your config to v1.x

- -If you've installed smol-k8s-lab prior to `v1.0.0`, please backup your old configuration, and then remove the `~/.config/smol-k8s-lab/config.yaml` (or `$XDG_CONFIG_HOME/smol-k8s-lab/config.yaml`) file entirely, then run the following: - -```yaml -# this upgrades smol-k8s-lab -pip3.11 install --upgrade smol-k8s-lab - -# this initializes a new configuration -smol-k8s-lab -``` - -### Adding custom Applications - -You can create any application you already have an Argo CD application repo for, by following a simple application YAML schema in `~/.config/smol-k8s-lab/config.yaml` like this: - -```yaml -apps: - # name of application to create in Argo CD - cert_manager: - # if set to false, we ignore this app - enabled: true - argo: - # secret keys to pass to Argo CD Application Set Generator - secret_keys: - # Used for letsencrypt-staging, to generate certs. If set to "" and cert-manager.enabled is true - # smol-k8s-lab will prompt for this value and save it back to this file for you. - email: "" - # git repo to install the Argo CD app from - repo: "https://github.com/small-hack/argocd-apps" - # path in the argo repo to point to. Trailing slash very important! - path: "ingress/cert-manager/" - # either the branch or tag to point at in the argo repo above - ref: "main" - # namespace to install the k8s app in - namespace: "ingress" - # source repos for cert-manager CD App Project (in addition to cert-manager.argo.repo) - project_source_repos: - - https://charts.jetstack.io -``` - -Note: the above application, cert-manager, is already included as a default application in smol-k8s-lab :) - - -

Upgrading config from v1.x to v2.x

@@ -193,6 +147,53 @@ apps:
+
+

Upgrading your config to v1.x

+ +If you've installed smol-k8s-lab prior to `v1.0.0`, please backup your old configuration, and then remove the `~/.config/smol-k8s-lab/config.yaml` (or `$XDG_CONFIG_HOME/smol-k8s-lab/config.yaml`) file entirely, then run the following: + +```yaml +# this upgrades smol-k8s-lab +pip3.11 install --upgrade smol-k8s-lab + +# this initializes a new configuration +smol-k8s-lab +``` + +### Adding custom Applications + +You can create any application you already have an Argo CD application repo for, by following a simple application YAML schema in `~/.config/smol-k8s-lab/config.yaml` like this: + +```yaml +apps: + # name of application to create in Argo CD + cert_manager: + # if set to false, we ignore this app + enabled: true + argo: + # secret keys to pass to Argo CD Application Set Generator + secret_keys: + # Used for letsencrypt-staging, to generate certs. If set to "" and cert-manager.enabled is true + # smol-k8s-lab will prompt for this value and save it back to this file for you. + email: "" + # git repo to install the Argo CD app from + repo: "https://github.com/small-hack/argocd-apps" + # path in the argo repo to point to. Trailing slash very important! + path: "ingress/cert-manager/" + # either the branch or tag to point at in the argo repo above + ref: "main" + # namespace to install the k8s app in + namespace: "ingress" + # source repos for cert-manager CD App Project (in addition to cert-manager.argo.repo) + project_source_repos: + - https://charts.jetstack.io +``` + +Note: the above application, cert-manager, is already included as a default application in smol-k8s-lab :) + +
+ + # Under the hood Note: this project is not officially affiliated with any of the below tooling or applications. From 1e9485b56abd6e99c7b326d56320cee2d04a9a47 Mon Sep 17 00:00:00 2001 From: jessebot Date: Wed, 10 Jan 2024 20:31:47 +0100 Subject: [PATCH 3/3] update pypi description --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d289a4734..1cad367a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "smol_k8s_lab" version = "2.0.1" -description = "Bootstrap simple projects on Kubernetes with kind, k3d, and k3s." +description = "CLI and TUI to quickly install slimmer Kubernetes distros and then manage apps declaratively using Argo CD" authors = ["Jesse Hitch ", "Max Roby "] readme = "README.md"