Skip to content

Commit

Permalink
2.0.0b7: update dependencies and add new test to make sure smol-k8s-l…
Browse files Browse the repository at this point in the history
…ab works on kind (#125)

* update dependencies and add new test to make sure smol-k8s-lab works on kind at least

* only run tests on non-main branches

* make sure poetry is installed in ci/cd

* make sure the correct version of python is installed

* properly source virtual env for poetry

* fix spacing in help text

* update poetry dependencies

* fix kind extra kubelet args to format correctly

* fix using alternative config files

* add a test hostname for Argo CD in CI/CD test of smol-k8s-lab

* add test email for smol-k8s-lab ci/cd testing

* removing bitwarden from base tests for smol-k8s-lab in ci/cd

* update kubelet args

* don't ask for bitwarden credentials unless global external secrets is set to bitwarden as provider

* fix order of args issue with preparing helm and adding new repos

* install argocd cli in ci/cd

* update help text screenshot

* don't wait for bitwarden eso provider if we're not using bitwarden
  • Loading branch information
jessebot authored Jan 9, 2024
1 parent 687e6e4 commit 9cedbf8
Show file tree
Hide file tree
Showing 14 changed files with 1,616 additions and 467 deletions.
1,108 changes: 1,108 additions & 0 deletions .github/smol_k8s_lab_config.yaml

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions .github/workflows/test-smol-k8s-lab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Test smol-k8s-lab
on:
push:
branches-ignore:
- "main"
jobs:
smol_k8s_lab_kind:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install smol-k8s-lab via poetry
run: poetry install

- name: Install Argo CD
run: |
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64
- name: source virtual env and test smol-k8s-lab
run: |
source .venv/bin/activate
smol-k8s-lab -c .github/smol_k8s_lab_config.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Checkout our [TUI docs](https://small-hack.github.io/smol-k8s-lab/tui/create_mod

## Beta release of 2.0.0

`v2.0.0b6` 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.0b6/#history)) you can do:
`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:

```bash
pip install smol_k8s_lab==2.0.0b6
pip install smol_k8s_lab==2.0.0b7
```

This should have actually been 1.0, but I misunderstood semver, and now here we are, with another major version update.
Expand Down
182 changes: 85 additions & 97 deletions docs/assets/images/screenshots/help_text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
691 changes: 343 additions & 348 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "smol_k8s_lab"
version = "2.0.0b6"
description = "Bootstrap simple projects on Kubernetes with kind, k3d, and k3s. this is an alpha release"
version = "2.0.0b7"
description = "Bootstrap simple projects on Kubernetes with kind, k3d, and k3s. This is a beta release"
authors = ["Jesse Hitch <jessebot@linux.com>",
"Max Roby <emax@cloudydev.net>"]
readme = "README.md"
Expand Down
18 changes: 13 additions & 5 deletions smol_k8s_lab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from rich.panel import Panel

# custom libs and constants
from .constants import INITIAL_USR_CONFIG, XDG_CONFIG_FILE
from .constants import INITIAL_USR_CONFIG, XDG_CONFIG_FILE, load_yaml
from .env_config import check_os_support, process_configs
from .bitwarden.bw_cli import BwCLI
from .bitwarden.tui.bitwarden_app import BitwardenCredentialsApp
Expand Down Expand Up @@ -137,23 +137,31 @@ def main(config: str = "",
# declaring the default name to be smol-k8s-lab
cluster_name = "smol-k8s-lab"

if interactive or INITIAL_USR_CONFIG['smol_k8s_lab']['tui']['enabled']:
cluster_name, USR_CFG, SECRETS, bitwarden_credentials = launch_config_tui()
# verify if the TUI should be used
tui_enabled = INITIAL_USR_CONFIG['smol_k8s_lab']['tui']['enabled']
if config:
config_dict = load_yaml(config)
tui_enabled = config_dict['smol_k8s_lab']['tui']['enabled']
else:
config_dict = INITIAL_USR_CONFIG

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()
USR_CFG, SECRETS = process_configs(config_dict)

# if we're using bitwarden, unlock the vault
pw_mngr = USR_CFG['smol_k8s_lab']['local_password_manager']
using_bw_pw_manager = pw_mngr['enabled'] and pw_mngr['name'] == 'bitwarden'
using_bweso = SECRETS['global_external_secrets']

if using_bw_pw_manager or using_bweso:
if using_bw_pw_manager or using_bweso == 'bitwarden':
# get bitwarden credentials from the env if there are any
password = env.get("BW_PASSWORD", None)
client_id = env.get("BW_CLIENTID", None)
Expand Down
6 changes: 3 additions & 3 deletions smol_k8s_lab/config/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ k8s_distros:
# change the kubelet config for this node in k3s, feel free to add more values
kubelet_extra_args:
node-labels: "ingress-ready=true"
maxPods: 110
podsPerCore: 0
resolvConf: "/etc/resolv.conf"
max-pods: 110
pods-per-core: 0
resolv-conf: "/etc/resolv.conf"
networking_args:
ipFamily: "ipv4"
disableDefaultCNI: false
Expand Down
2 changes: 1 addition & 1 deletion smol_k8s_lab/k8s_apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def setup_base_apps(k8s_obj: K8s,
cilium_enabled = cilium_dict['enabled']
ingress_nginx_enabled = ingress_dict["enabled"]
# make sure helm is installed and the repos are up to date
prepare_helm(k8s_distro, metallb_enabled, cilium_enabled, argo_enabled,
prepare_helm(k8s_distro, argo_enabled, metallb_enabled, cilium_enabled,
argo_secrets_plugin_enabled)

# needed for network policy editor and hubble UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def configure_external_secrets(k8s_obj: K8s,
install_with_argocd(k8s_obj, 'external-secrets-operator', eso_dict['argo'])
wait_for_argocd_app('external-secrets-operator')

# wait for bitwarden external secrets provider to be up
wait_for_argocd_app('bitwarden-eso-provider')
if bitwarden:
# wait for bitwarden external secrets provider to be up
wait_for_argocd_app('bitwarden-eso-provider')


def setup_bweso_provider(k8s_obj: K8s, distro: str, bitwarden: BwCLI = None) -> None:
Expand Down
6 changes: 5 additions & 1 deletion smol_k8s_lab/k8s_distros/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import logging as log
from os import path
from ruamel.yaml import YAML
from ruamel.yaml.scalarstring import PreservedScalarString as pss
from shutil import which


Expand Down Expand Up @@ -89,6 +90,9 @@ def build_kind_config(cfg_file: str = "~/.config/smol-k8s-lab/kind_cfg.yaml",
}

if kubelet_extra_args:
for arg, value in kubelet_extra_args.items():
kubelet_extra_args[arg] = f'"{value}"'

# adding any extra kubelet args you'd like to the kind node
kube_adm_config = {
'kind': 'InitConfiguration',
Expand All @@ -99,7 +103,7 @@ def build_kind_config(cfg_file: str = "~/.config/smol-k8s-lab/kind_cfg.yaml",

# only add extra kubelet args if any were passed in
node_config['kubeadmConfigPatches'] = [
safe_yaml.dump_to_string(kube_adm_config)
pss(safe_yaml.dump_to_string(kube_adm_config)).replace("'","")
]

kind_cfg = {
Expand Down
9 changes: 7 additions & 2 deletions smol_k8s_lab/tui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from smol_k8s_lab.tui.base import BaseApp
from smol_k8s_lab.constants import load_yaml
from smol_k8s_lab.utils.rich_cli.console_logging import print_msg
import sys


def launch_config_tui():
def launch_config_tui(config_file: str = ""):
"""
Run all the TUI screens
"""
res = BaseApp().run()
if config_file:
config = load_yaml(config_file)
res = BaseApp(config).run()
else:
res = BaseApp().run()
if not res:
print_msg("[blue]♥[/] [cyan]Have a nice day[/] [blue]♥\n", style="italic")
sys.exit()
Expand Down
5 changes: 4 additions & 1 deletion smol_k8s_lab/tui/distro_widgets/kubelet_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
from textual.widget import Widget
from textual.widgets import Input, Button, Label

VALUE_SUGGESTIONS = SuggestFromList(("ingress-ready=true"))
VALUE_SUGGESTIONS = SuggestFromList(("ingress-ready=true",
"pods-per-core",
"resolv-conf",
"max-pods"))

kubelet_help = (
"Add key value pairs to pass to your [steel_blue][b][link=https://kubernetes.io/docs/"
Expand Down
5 changes: 2 additions & 3 deletions smol_k8s_lab/utils/rich_cli/help_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@ def options_help():

if RECORD:
help_dict['config'] = (
'Full path and name of the YAML config file to parse.\n Defaults to '
'Full path and name of the YAML config file to parse.\nDefaults to '
'[light_steel_blue]$XDG_CONFIG_HOME/smol-k8s-lab/config.yaml[/]'
)
else:
help_dict['config'] = (
'Full path and name of the YAML config file to parse.\n Defaults to '
'Full path and name of the YAML config file to parse.\nDefaults to '
f'[light_steel_blue]{XDG_CONFIG_FILE}[/]'
)


return help_dict


Expand Down

0 comments on commit 9cedbf8

Please sign in to comment.