Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavcracker committed Jan 24, 2025
1 parent b476273 commit 78f3a42
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 5 additions & 2 deletions kubemarine/kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ def join_control_plane(cluster: KubernetesCluster, node: NodeGroup, join_dict: d
node.sudo("mkdir -p /etc/kubernetes")
node.put(io.StringIO(config), '/etc/kubernetes/join-config.yaml', sudo=True)



# put control-plane patches
components.create_kubeadm_patches_for_node(cluster, node)

Expand Down Expand Up @@ -1313,7 +1315,8 @@ def migrate_kubeadm_config(group: NodeGroup, config_file: str) -> None:
if minor_version > 31:
config = config_file
# Perform migration
group.sudo(f"kubeadm config migrate --old-config {config} --new-config {config}", hide=True)
log.debug(f"Kubeadm config migration successful: {config}")
group.sudo(f"kubeadm config migrate --old-config {config} --new-config {config}-migrated", hide=True)
log.debug(f"Kubeadm config migration successful: {config}-migrated")
group.sudo(f"cp {config}-migrated {config}")
else:
log.debug(f"No migration needed for Kubernetes version: {k8s_version}")
14 changes: 12 additions & 2 deletions kubemarine/kubernetes/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,18 @@ def _upload_config(cluster: KubernetesCluster, control_plane: AbstractGroup[RunR
utils.dump_file(cluster, config, f"{name}_{control_plane.get_node_name()}.yaml")

control_plane.put(io.StringIO(config), remote_path, sudo=True)

log = cluster.log
k8s_version = cluster.inventory['services']['kubeadm']['kubernetesVersion']
log.debug(f"Cluster Kubernetes version: {k8s_version}")
minor_version = int(k8s_version.lstrip('v').split('.')[1])
# If minor version > 31, proceed with migration
if minor_version > 31:
control_plane.sudo(f"kubeadm config migrate --old-config {remote_path} --new-config {remote_path}-migrated")
log.debug(f"Kubeadm config migration successful: {remote_path}-migrated")
control_plane.sudo(f"cp {remote_path}-migrated {remote_path}")
else:
log.debug(f"No migration needed for Kubernetes version: {k8s_version}")


def _update_configmap(cluster: KubernetesCluster, control_plane: NodeGroup, configmap: str,
Expand Down Expand Up @@ -895,7 +907,6 @@ def compare_kubelet_config(cluster: KubernetesCluster, *, with_inventory: bool)
def compare_configmap(cluster: KubernetesCluster, configmap: str) -> Optional[str]:
control_plane = cluster.nodes['control-plane'].get_first_member()
kubeadm_config = KubeadmConfig(cluster)

if configmap == 'kubelet-config':
# Do not check kubelet-config ConfigMap, because some properties may be deleted from KubeletConfiguration
# if set to default, for example readOnlyPort: 0, protectKernelDefaults: false
Expand Down Expand Up @@ -961,7 +972,6 @@ def compare_configmap(cluster: KubernetesCluster, configmap: str) -> Optional[st
fromfile=f'{configmap} ConfigMap',
tofile=f"{configmap} ConfigMap merged 'services.{section}' section")


def _detect_changes(logger: log.EnhancedLogger, old: str, new: str, fromfile: str, tofile: str) -> bool:
diff = utils.get_yaml_diff(old, new, fromfile, tofile)
if diff is not None:
Expand Down

0 comments on commit 78f3a42

Please sign in to comment.