canonical / microk8s

MicroK8s is a small, fast, single-package Kubernetes for datacenters and the edge.
https://microk8s.io
Apache License 2.0
8.35k stars 763 forks source link

Ability to check if addons are out of date #4130

Open jack1902 opened 1 year ago

jack1902 commented 1 year ago

Summary

Currently using microk8s addons i cannot tell if addons are out of date between releases. Whilst i can check release-notes and compare versions, it would be ideal to have a command such as microk8s addons --check-for-updates or something similar such that i can re-run ansible playbooks without nuking the DNS addon resulting in chaos inside my cluster for a period of time on each rerun.

The main danger i forsee is that i can't update an addon repository without potentially breaking the disable command. As noted in another issue, if you update the addon-repository first before disabling any enabled addons, it might not uninstall properly. I originally thought i would just "check for updates" at the addon repo level but doing that results in disable not functioning

Why is this important?

Currently, i am using ansible to upgrade microk8s in various environments, upgrading microk8s alone isn't enough as addons also have to be updated. Currently i only make use of the dashboard and dns addons but i am debating using coredns directly as microk8s doesn't provide an upgrade path, only one that requires a full removal and reinstall which is less than ideal for production clusters

Are you interested in contributing to this feature?

not sure how to implement it exactly, but i can look to implement it if i know where to look

ktsakalozos commented 1 year ago

Hi @jack1902, sorry for the late reply. Indeed right now we do not expose a way to upgrade an addon.

The addons are under /var/snap/microk8s/common/addons/repository_name/addons/addon_name for example coredns is under /var/snap/microk8s/common/addons/core/addons/dns. The addon repositories are git repos so you can do:

$ cd /var/snap/microk8s/common/addons/core/
$ git status
On branch 1.27
Your branch is up to date with 'origin/1.27'.

nothing to commit, working tree clean
$ git remote -v
origin  /snap/microk8s/current/addons/core (fetch)
origin  /snap/microk8s/current/addons/core (push)

Notice that the core repository is shipped with the snap so you can use git or any other script to identify if there are changes under a specific directory. With microk8s addons repo update the repository under /var/snap/microk8s/common is synced with its remote repo. You can read more on the structure of the core addons repository at https://github.com/canonical/microk8s-core-addons.

jack1902 commented 1 year ago

ok thanks for the response, i cannot run microk8s addons repo update as that will result in the disable scripts being updated and then putting me in a postion that a manifest might no longer be tracked.

It is a bit difficult from the addons perspective as in order to safely perform an update to the addons i would first need to disable it on its current version to reenable having done an update. This feels like the only "safe" path because the disable scripts are relevant only for the version they ship with.

Since the tags in git for the core-repo even track the version of microk8s it shipped with, i'd have to get under the covers of understanding what paths an addon might use to then check if there have been changes to said path within ansible.

My biggest issue i have currently is disable / enable to update forces downtime and utter chaos inside my cluster when many of the addons in use such as coredns are designed to be updated in place and can be when using helm directly

stale[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jack1902 commented 1 month ago

Not stale