Skip to content

Commit

Permalink
Merge branch 'main' into new_k8s_versions
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00ace committed May 30, 2024
2 parents 498c783 + 8faa54d commit bd02edd
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 38 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
41 changes: 22 additions & 19 deletions magnum_cluster_api/cmd/image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down
41 changes: 23 additions & 18 deletions magnum_cluster_api/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Empty file.
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions magnum_cluster_api/files/run/kubeadm/configure-kube-proxy.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF >> /run/kubeadm/kubeadm.yaml
---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
metricsBindAddress: "0.0.0.0:10249"
EOF
22 changes: 22 additions & 0 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# under the License.

import glob
import importlib.resources
import json
import os
import textwrap
Expand Down Expand Up @@ -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",
},
},
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit bd02edd

Please sign in to comment.