🐛 Selecting "New Cluster" causes distro section of configfile to be overwritten #132

Closed
opened 2024-01-10 18:11:57 +00:00 by cloudymax · 7 comments
cloudymax commented 2024-01-10 18:11:57 +00:00 (Migrated from github.com)

Describe the Bug

As a user with a k3s config that has lots of kubelet args, I prefer to configure all of them via the config file like so:

# which distros of Kubernetes to deploy. Options: kind, k3s, k3d
# NOTE: only kind and k3d are available on macOS at this time
k8s_distros:
  k3s:
    # set to true to enable deploying a Kubernetes cluster using k3s
    enabled: true
    # if k8s_distro set to k3s/k3d, you can add an array of extra arguments to pass
    # to the k3s install script as a k3s.yaml file. If you enable cilium, we
    # automatically pass in flannel-backend: none and disable-network-policy: true
    k3s_yaml:
      # if you enable MetalLB, we automatically add servicelb to the disable list
      # enables encryption at rest for Kubernetes secrets
      secrets-encryption: true
      node-external-ip: 100.64.0.1
      # disables traefik so we can enable ingress-nginx, remove if you're using traefik
      disable:
      - traefik
      - servicelb
      node-label:
      - ingress-ready=true
      kubelet-arg:
      - max_pods=150
      - node-ip=192.168.50.100
      - cpu-manager-policy=static
      - kube-reserved=cpu=1,memory=2Gi,ephemeral-storage=1Gi
      - system-reserved=cpu=1,memory=2Gi,ephemeral-storage=1Gi
    nodes:
      control_plane: 1
      workers: 0

When I launch the TUI and select "New Cluster", my config file is overwritten to the following:

# which distros of Kubernetes to deploy. Options: kind, k3s, k3d
# NOTE: only kind and k3d are available on macOS at this time
k8s_distros:
  k3s:
    # set to true to enable deploying a Kubernetes cluster using k3s
    enabled: true
    # if k8s_distro set to k3s/k3d, you can add an array of extra arguments to pass
    # to the k3s install script as a k3s.yaml file. If you enable cilium, we
    # automatically pass in flannel-backend: none and disable-network-policy: true
    k3s_yaml:
      # if you enable MetalLB, we automatically add servicelb to the disable list
      # enables encryption at rest for Kubernetes secrets
      secrets-encryption: true
      node-external-ip: 100.64.0.1
      # disables traefik so we can enable ingress-nginx, remove if you're using traefik
      disable:
      - traefik
      node-label:
      - ingress-ready=true
      kubelet-arg:
      - max_pods=150
    nodes:
      control_plane: 1
      workers: 0

However there is no issue if only using the cli

Steps to Reproduce Bug

  1. add some kubelet args to your config file
  2. launch the tui
  3. select "New Cluster"
  4. Exit the TUI
  5. Inspect your config file

Expected behavior

I would assume that the data from the config file would be loaded into the tui on init

User info (please complete the following information):

  • OS release: Debian12
  • Kubernetes distro: k3s
  • Version of smol-k8s-lab: v2.0.0
  • Config file contents: see above
## Describe the Bug As a user with a k3s config that has lots of kubelet args, I prefer to configure all of them via the config file like so: ```yaml # which distros of Kubernetes to deploy. Options: kind, k3s, k3d # NOTE: only kind and k3d are available on macOS at this time k8s_distros: k3s: # set to true to enable deploying a Kubernetes cluster using k3s enabled: true # if k8s_distro set to k3s/k3d, you can add an array of extra arguments to pass # to the k3s install script as a k3s.yaml file. If you enable cilium, we # automatically pass in flannel-backend: none and disable-network-policy: true k3s_yaml: # if you enable MetalLB, we automatically add servicelb to the disable list # enables encryption at rest for Kubernetes secrets secrets-encryption: true node-external-ip: 100.64.0.1 # disables traefik so we can enable ingress-nginx, remove if you're using traefik disable: - traefik - servicelb node-label: - ingress-ready=true kubelet-arg: - max_pods=150 - node-ip=192.168.50.100 - cpu-manager-policy=static - kube-reserved=cpu=1,memory=2Gi,ephemeral-storage=1Gi - system-reserved=cpu=1,memory=2Gi,ephemeral-storage=1Gi nodes: control_plane: 1 workers: 0 ``` When I launch the TUI and select "New Cluster", my config file is overwritten to the following: ```yaml # which distros of Kubernetes to deploy. Options: kind, k3s, k3d # NOTE: only kind and k3d are available on macOS at this time k8s_distros: k3s: # set to true to enable deploying a Kubernetes cluster using k3s enabled: true # if k8s_distro set to k3s/k3d, you can add an array of extra arguments to pass # to the k3s install script as a k3s.yaml file. If you enable cilium, we # automatically pass in flannel-backend: none and disable-network-policy: true k3s_yaml: # if you enable MetalLB, we automatically add servicelb to the disable list # enables encryption at rest for Kubernetes secrets secrets-encryption: true node-external-ip: 100.64.0.1 # disables traefik so we can enable ingress-nginx, remove if you're using traefik disable: - traefik node-label: - ingress-ready=true kubelet-arg: - max_pods=150 nodes: control_plane: 1 workers: 0 ``` However there is no issue if only using the cli ### Steps to Reproduce Bug 1. add some kubelet args to your config file 2. launch the tui 3. select "New Cluster" 4. Exit the TUI 5. Inspect your config file #### Expected behavior I would assume that the data from the config file would be loaded into the tui on init ## User info (please complete the following information): - OS release: `Debian12` - Kubernetes distro: `k3s` - Version of `smol-k8s-lab`: v2.0.0 - Config file contents: see above
jessebot commented 2024-01-10 18:27:11 +00:00 (Migrated from github.com)

Thanks for reporting this! I'll take a look tonight!

Thanks for reporting this! I'll take a look tonight!
jessebot commented 2024-01-10 19:18:20 +00:00 (Migrated from github.com)

fixing in #133

fixing in #133
cloudymax commented 2024-01-10 20:36:16 +00:00 (Migrated from github.com)

Unfortunately it's only mostly fixed, options that contain more than one comma get split prematurely:|

# which distros of Kubernetes to deploy. Options: kind, k3s, k3d
# NOTE: only kind and k3d are available on macOS at this time
k8s_distros:
  k3s:
    # set to true to enable deploying a Kubernetes cluster using k3s
    enabled: true
    # if k8s_distro set to k3s/k3d, you can add an array of extra arguments to pass
    # to the k3s install script as a k3s.yaml file. If you enable cilium, we
    # automatically pass in flannel-backend: none and disable-network-policy: true
    k3s_yaml:
      # if you enable MetalLB, we automatically add servicelb to the disable list
      # enables encryption at rest for Kubernetes secrets
      secrets-encryption: true
      node-external-ip: 100.64.0.1
      # disables traefik so we can enable ingress-nginx, remove if you're using traefik
      disable:
      - traefik
      - servicelb
      node-label:
      - ingress-ready=true
      kubelet-arg:
      - max_pods=150
      - node-ip=192.168.50.100
      - cpu-manager-policy=static
      - kube-reserved=cpu=1
      - memory=2Gi
      - ephemeral-storage=1Gi
      - system-reserved=cpu=1
      - memory=2Gi
      - ephemeral-storage=1Gi
    nodes:
      control_plane: 1
      workers: 0
Unfortunately it's only mostly fixed, options that contain more than one comma get split prematurely:| ```yaml # which distros of Kubernetes to deploy. Options: kind, k3s, k3d # NOTE: only kind and k3d are available on macOS at this time k8s_distros: k3s: # set to true to enable deploying a Kubernetes cluster using k3s enabled: true # if k8s_distro set to k3s/k3d, you can add an array of extra arguments to pass # to the k3s install script as a k3s.yaml file. If you enable cilium, we # automatically pass in flannel-backend: none and disable-network-policy: true k3s_yaml: # if you enable MetalLB, we automatically add servicelb to the disable list # enables encryption at rest for Kubernetes secrets secrets-encryption: true node-external-ip: 100.64.0.1 # disables traefik so we can enable ingress-nginx, remove if you're using traefik disable: - traefik - servicelb node-label: - ingress-ready=true kubelet-arg: - max_pods=150 - node-ip=192.168.50.100 - cpu-manager-policy=static - kube-reserved=cpu=1 - memory=2Gi - ephemeral-storage=1Gi - system-reserved=cpu=1 - memory=2Gi - ephemeral-storage=1Gi nodes: control_plane: 1 workers: 0 ``` - [kube-reserved](https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/#kube-reserved) and [system-reserved](https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/#system-reserved) have a non-standard format that gets broken if it's split prematurely.
jessebot commented 2024-01-11 07:32:43 +00:00 (Migrated from github.com)

ok, so this is going to require a second section for kubelet args to get this under control for k3s. Allow me a day or so to work on this as I need to add a tab to the k3s tui screen to fix this.

ok, so this is going to require a second section for kubelet args to get this under control for k3s. Allow me a day or so to work on this as I need to add a tab to the k3s tui screen to fix this.
jessebot commented 2024-01-12 08:32:27 +00:00 (Migrated from github.com)

ok, I've got most of this done in #135. I just need to fix this add new k3s option button and figure out another bug with the kubelet args duplicating. See screenshots below for current status:

Screenshot of smol-k8s-lab's TUI on the k3s screen showing that there's been tabs added for both k3s.yaml and kubelet args. the k3s.yaml tab is selected Screenshot of smol-k8s-lab's TUI on the k3s screen showing that there's been tabs added for both k3s.yaml and kubelet args. The kubelet args tab is selected and it shows the max-pods option duplicated infinitely for some reason
ok, I've got most of this done in #135. I just need to fix this add new k3s option button and figure out another bug with the kubelet args duplicating. See screenshots below for current status: <img width="1079" alt="Screenshot of smol-k8s-lab's TUI on the k3s screen showing that there's been tabs added for both k3s.yaml and kubelet args. the k3s.yaml tab is selected" src="https://github.com/small-hack/smol-k8s-lab/assets/2389292/acfc0cfb-4c2b-4baa-9c0b-44a99265dfe9"> <img width="1079" alt="Screenshot of smol-k8s-lab's TUI on the k3s screen showing that there's been tabs added for both k3s.yaml and kubelet args. The kubelet args tab is selected and it shows the max-pods option duplicated infinitely for some reason" src="https://github.com/small-hack/smol-k8s-lab/assets/2389292/d5d3e714-c634-465c-a5dd-08a86ae4212d">
jessebot commented 2024-01-12 10:03:11 +00:00 (Migrated from github.com)

ok, fixed that issue, now just need to fix an issue to allow there to be multiple distros enabled at once, as right now, we assume you're launching either one cluster, or many clusters using kind or k3d. I want to add k8s_distros.selected:

k8s_distros:
  selected: "kind"

and then we can use the "selected" field, instead of the k8s_distros.DISTRO.enabled field, as the selected is really just for the current operations via the tui or cli, and enabled is relative to the OS (e.g. k3s doesn't work on macOS yet). After that's fixed, I'll regenerate screenshots and cut a new release :)

ok, fixed that issue, now just need to fix an issue to allow there to be multiple distros enabled at once, as right now, we assume you're launching either one cluster, or many clusters using kind or k3d. I want to add `k8s_distros.selected`: ```yaml k8s_distros: selected: "kind" ``` and then we can use the "selected" field, instead of the `k8s_distros.DISTRO.enabled` field, as the selected is really just for the current operations via the tui or cli, and enabled is relative to the OS (e.g. k3s doesn't work on macOS yet). After that's fixed, I'll regenerate screenshots and cut a new release :)
jessebot commented 2024-01-12 13:34:38 +00:00 (Migrated from github.com)

ok, fixed that issue, now just need to fix an issue to allow there to be multiple distros enabled at once, as right now, we assume you're launching either one cluster, or many clusters using kind or k3d. I want to add k8s_distros.selected:

k8s_distros:
  selected: "kind"

and then we can use the "selected" field, instead of the k8s_distros.DISTRO.enabled field, as the selected is really just for the current operations via the tui or cli, and enabled is relative to the OS (e.g. k3s doesn't work on macOS yet). After that's fixed, I'll regenerate screenshots and cut a new release :)

so scratch this, I don't actually think it's necessary :) The issue was actually that I was querying a widget incorrectly after using multiple times. I was using self.query_one when I needed to use self.get_widget_by_id because we use the same kubelet widget for all distros now. Just finishing up testing now!

> ok, fixed that issue, now just need to fix an issue to allow there to be multiple distros enabled at once, as right now, we assume you're launching either one cluster, or many clusters using kind or k3d. I want to add `k8s_distros.selected`: > > ```yaml > k8s_distros: > selected: "kind" > ``` > > and then we can use the "selected" field, instead of the `k8s_distros.DISTRO.enabled` field, as the selected is really just for the current operations via the tui or cli, and enabled is relative to the OS (e.g. k3s doesn't work on macOS yet). After that's fixed, I'll regenerate screenshots and cut a new release :) so scratch this, I don't actually think it's necessary :) The issue was actually that I was querying a widget incorrectly after using multiple times. I was using `self.query_one` when I needed to use `self.get_widget_by_id` because we use the same kubelet widget for all distros now. Just finishing up testing now!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
small-hack/smol-k8s-lab#132
No description provided.