Open sanzoghenzo opened 2 years ago
This would be excellent! I'm struggling with the same pain, although I'm using Nix to manage my k3d config file.
it still needs a handier way to compare the state against the config file.
Is exactly my pain. I can destroy and re-create the cluster easily with k3d cluster
commands, but there isn't a way to figure out when the config file differs from the running cluster.
FYI, I've limited my goals to a local k3d deployment and switched to Taskfile.
The built-in checksum on the sources
files allows me to run the destroy+create the cluster only if I edit the file.
It is still overkill if I only need to change, for example, the loadbalancer port, but it is somehting.
version: "3"
vars:
K3D_CLUSTER_NAME:
sh: grep 'name:' k3d-cluster.yml | awk '{ print $2 }' | tr -d '\"'
tasks:
k3d:
desc: Install k3d. Use -f to upgrade
cmds:
- wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
status:
- command -v k3d
delete-cluster:
desc: Delete k3d cluster if it exists
cmds:
- k3d cluster delete {{.K3D_CLUSTER_NAME}} || true
silent: true
create-cluster:
desc: Create k3d cluster using the k3d-cluster.yml configuration
deps:
- k3d
sources:
- k3d-cluster.yml
cmds:
- task: delete-cluster
- k3d cluster create -c k3d-cluster.yml
Is your feature request related to a problem or a Pull Request
I can't find any related issues or PRs.
Scope of your request
New "apply" verb for "cluster" noun
Describe the solution you'd like
Be able to use the configuration file not only to create a cluster, but also to edit it, so that a configuration file can hold the desired state of the cluster.
Something like
kubectl apply
, but for k3d resources.I'm trying to setup a pyinfra deployment (something like an Ansible playbook) to be able to deploy a k3d cluster on my homelab; In order to have some idempotency I have to:
k3d cluster list
to see if a cluster with that name already existsk3d node edit
if changes are neededDescribe alternatives you've considered
I could accept destroying and re-create the cluster if the changes are big/to complex to handle, but it still needs a handier way to compare the state against the config file.