diff --git a/CHANGELOG.md b/CHANGELOG.md index 1454d307..cc0148e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [0.18.0](https://github.com/vexxhost/magnum-cluster-api/compare/v0.17.1...v0.18.0) (2024-05-30) + + +### Features + +* Update bind address for k8s components ([#197](https://github.com/vexxhost/magnum-cluster-api/issues/197)) ([4b1f5d8](https://github.com/vexxhost/magnum-cluster-api/commit/4b1f5d840fb9f2158e7c7d8ebca6f1a86fb8569f)) + + +### Bug Fixes + +* force a cluster upgrade all the time ([#382](https://github.com/vexxhost/magnum-cluster-api/issues/382)) ([436bcf2](https://github.com/vexxhost/magnum-cluster-api/commit/436bcf26eb3fb30efef67b01a8ad400ca1bcce03)) + ## [0.17.1](https://github.com/vexxhost/magnum-cluster-api/compare/v0.17.0...v0.17.1) (2024-05-28) diff --git a/magnum_cluster_api/cmd/image_builder.py b/magnum_cluster_api/cmd/image_builder.py index ce58da32..aec71834 100644 --- a/magnum_cluster_api/cmd/image_builder.py +++ b/magnum_cluster_api/cmd/image_builder.py @@ -66,7 +66,7 @@ def validate_version(_, __, value): @click.option( "--image-builder-version", show_default=True, - default="v0.1.25", + default="v0.1.29", help="Image builder tag (or commit) to use for building image", ) def main(ctx: click.Context, operating_system, version, image_builder_version): @@ -146,25 +146,28 @@ def main(ctx: click.Context, operating_system, version, image_builder_version): # NOTE(mnaser): We use the latest tested daily ISO for Ubuntu 22.04 in order # to avoid a lengthy upgrade process. - if operating_system == "ubuntu-2204": - iso = "jammy-live-server-amd64.iso" - customization["iso_url"] = ( - f"http://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/current/{iso}" - ) - - # Get the SHA256 sum for the ISO - r = requests.get( - "http://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/current/SHA256SUMS" - ) - r.raise_for_status() - for line in r.text.splitlines(): - if iso in line: - customization["iso_checksum"] = line.split()[0] - break - - # Assert that we have the checksum - assert "iso_checksum" in customization + # NOTE(jrosser): This can be uncommented again when + # https://github.com/vexxhost/magnum-cluster-api/issues/378 is fixed + # if operating_system == "ubuntu-2204": + # iso = "jammy-live-server-amd64.iso" + # + # customization["iso_url"] = ( + # f"http://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/current/{iso}" + # ) + # + # # Get the SHA256 sum for the ISO + # r = requests.get( + # "http://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/current/SHA256SUMS" + # ) + # r.raise_for_status() + # for line in r.text.splitlines(): + # if iso in line: + # customization["iso_checksum"] = line.split()[0] + # break + # + # # Assert that we have the checksum + # assert "iso_checksum" in customization if operating_system == "rockylinux-8": iso = "Rocky-x86_64-minimal.iso" diff --git a/magnum_cluster_api/driver.py b/magnum_cluster_api/driver.py index 859250b1..d02c8ee1 100644 --- a/magnum_cluster_api/driver.py +++ b/magnum_cluster_api/driver.py @@ -281,20 +281,21 @@ def upgrade_cluster( ): """ Upgrade a cluster to a new version of Kubernetes. + + The only label that we change during the upgrade is the `kube_tag` label. + + Historically, the upgrade cluster has been a "hammer" that was used to sync the + Kubernetes Cluster API objects with the Magnum objects. However, by doing this, + we're losing the ability to maintain the existing labels of the cluster. + + For now, upgrade cluster simply modifies the labels that are necessary for the + upgrade, nothing else. For the future, we can perhaps use the `update_cluster` + API. """ - # NOTE(mnaser): The only label that we change during the upgrade is the `kube_tag` - # label. - # - # Historically, the upgrade cluster has been a "hammer" that was - # used to sync the Kubernetes Cluster API objects with the Magnum - # objects. However, by doing this, we're losing the ability to - # maintain the existing labels of the cluster. - # - # For now, upgrade cluster simply modifies the labels that are - # necessary for the upgrade, nothing else. For the future, we - # can perhaps use the `update_cluster` API. - current_kube_tag = cluster.labels["kube_tag"] - new_kube_tag = cluster_template.labels["kube_tag"] + need_to_wait = ( + cluster.default_ng_master.image_id != cluster_template.image_id + or cluster.labels["kube_tag"] != cluster_template.labels["kube_tag"] + ) # XXX(mnaser): The Magnum API historically only did upgrade one node group at a # time. This is a limitation of the Magnum API and not the Magnum @@ -305,17 +306,21 @@ def upgrade_cluster( # we ignore the `nodegroup` parameter and upgrade the entire cluster # at once. cluster.cluster_template_id = cluster_template.uuid - cluster.labels["kube_tag"] = new_kube_tag + cluster.labels["kube_tag"] = cluster_template.labels["kube_tag"] for ng in cluster.nodegroups: ng.status = fields.ClusterStatus.UPDATE_IN_PROGRESS ng.image_id = cluster_template.image_id - ng.labels["kube_tag"] = new_kube_tag + ng.labels["kube_tag"] = cluster_template.labels["kube_tag"] ng.save() - if current_kube_tag != new_kube_tag: - cluster_resource = objects.Cluster.for_magnum_cluster(self.k8s_api, cluster) - resources.apply_cluster_from_magnum_cluster(context, self.k8s_api, cluster) + # NOTE(mnaser): We run a full apply on the cluster regardless of the changes, since + # the expectation is that running an upgrade operation will change + # the cluster in some way. + cluster_resource = objects.Cluster.for_magnum_cluster(self.k8s_api, cluster) + resources.apply_cluster_from_magnum_cluster(context, self.k8s_api, cluster) + + if need_to_wait: cluster_resource.wait_for_observed_generation_changed() # NOTE(mnaser): We do not save the cluster object here because the Magnum driver diff --git a/magnum_cluster_api/files/__init__.py b/magnum_cluster_api/files/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/magnum_cluster_api/files/run/__init__.py b/magnum_cluster_api/files/run/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/magnum_cluster_api/files/run/kubeadm/__init__.py b/magnum_cluster_api/files/run/kubeadm/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh b/magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh new file mode 100644 index 00000000..ddc3e1d2 --- /dev/null +++ b/magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: Apache-2.0 + +set -o pipefail +set -o errexit +set -o nounset + +if grep -q "KubeProxyConfiguration" /run/kubeadm/kubeadm.yaml; then + exit 0 +fi + +cat <> /run/kubeadm/kubeadm.yaml +--- +apiVersion: kubeproxy.config.k8s.io/v1alpha1 +kind: KubeProxyConfiguration +metricsBindAddress: "0.0.0.0:10249" +EOF diff --git a/magnum_cluster_api/resources.py b/magnum_cluster_api/resources.py index 7eac091a..27f46001 100644 --- a/magnum_cluster_api/resources.py +++ b/magnum_cluster_api/resources.py @@ -13,6 +13,7 @@ # under the License. import glob +import importlib.resources import json import os import textwrap @@ -603,14 +604,23 @@ def get_object(self) -> objects.KubeadmControlPlaneTemplate: } ], }, + "etcd": { + "local": { + "extraArgs": { + "listen-metrics-urls": "http://0.0.0.0:2381", + }, + }, + }, "controllerManager": { "extraArgs": { + "bind-address": "0.0.0.0", "cloud-provider": "external", "profiling": "false", }, }, "scheduler": { "extraArgs": { + "bind-address": "0.0.0.0", "profiling": "false", }, }, @@ -631,6 +641,18 @@ def get_object(self) -> objects.KubeadmControlPlaneTemplate: ), "encoding": "base64", }, + { + "path": "/run/kubeadm/configure-kube-proxy.sh", + "permissions": "0755", + "content": base64.encode_as_text( + importlib.resources.files( + "magnum_cluster_api.files.run.kubeadm" + ) + .joinpath("configure-kube-proxy.sh") + .read_text() + ), + "encoding": "base64", + }, ], "initConfiguration": { "nodeRegistration": { diff --git a/pyproject.toml b/pyproject.toml index 90f669db..f62d418a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "magnum-cluster-api" -version = "0.17.1" +version = "0.18.0" description = "Cluster API driver for Magnum" authors = ["Mohammed Naser "] license = "Apache-2.0"