Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement controlled upgrades #311

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
upgrade:
description: Upgrade the Kubernetes snaps
8 changes: 8 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def __init__(self, *args):
self.reconciler = Reconciler(self, self.reconcile)
self.tokens = TokensProvider(self, endpoint="tokens")

self.framework.observe(self.on.upgrade_action, self.on_upgrade_action)

def api_dependencies_ready(self):
common_name = kubernetes_snaps.get_public_address()
ca = self.certificates.ca
Expand Down Expand Up @@ -406,6 +408,12 @@ def install_cni_binaries(self):

log.info(f"Extracted 'cni-plugins' to {unpack_path}")

def on_upgrade_action(self, event):
"""Handle the upgrade action."""
with status.context(self.unit):
channel = self.model.config.get("channel")
kubernetes_snaps.upgrade_snaps(channel=channel, event=event, control_plane=True)

def reconcile(self, event):
"""Reconcile state change events."""
self.install_cni_binaries()
Expand Down