Skip to content

Commit

Permalink
Ensure to use kubectl after wait for first control plane pods
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia1243 committed Apr 26, 2024
1 parent 50e4e66 commit 4436dbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions kubemarine/kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,6 @@ def upgrade_first_control_plane(upgrade_group: NodeGroup, cluster: KubernetesClu

copy_admin_config(cluster.log, first_control_plane)

# In some versions, kubeadm reverts resolvConf to the default during `upgrade apply`
# Remove default resolvConf from kubelet-config ConfigMap for debian OS family
first_control_plane.call(components.patch_kubelet_configmap)

expect_kubernetes_version(cluster, version, apply_filter=node_name)
components.wait_for_pods(first_control_plane)
exclude_node_from_upgrade_list(first_control_plane, node_name)
Expand Down
6 changes: 6 additions & 0 deletions kubemarine/procedures/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from kubemarine.core import utils
from kubemarine.core.cluster import KubernetesCluster, EnrichmentStage
from kubemarine.core.resources import DynamicResources
from kubemarine.kubernetes import components
from kubemarine.procedures import install


Expand Down Expand Up @@ -104,11 +105,16 @@ def edit_kube_proxy_conntrack_min(kube_proxy_cm: dict) -> dict:
}

kubernetes.upgrade_first_control_plane(upgrade_group, cluster, **drain_kwargs)
first_control_plane = cluster.nodes['control-plane'].get_first_member()

# After first control-plane upgrade is finished we may loose our CoreDNS changes.
# Thus, we need to re-apply our CoreDNS changes immediately after first control-plane upgrade.
install.deploy_coredns(cluster)

# In some versions, kubeadm reverts resolvConf to the default during `upgrade apply`
# Remove default resolvConf from kubelet-config ConfigMap for debian OS family
first_control_plane.call(components.patch_kubelet_configmap)

kubernetes.upgrade_other_control_planes(upgrade_group, cluster, **drain_kwargs)

if cluster.nodes.get('worker', []):
Expand Down
2 changes: 2 additions & 0 deletions test/unit/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from kubemarine import kubernetes, system, plugins, thirdparties
from kubemarine.core import errors, utils as kutils, static, log, flow, schema
from kubemarine.core.cluster import KubernetesCluster, EnrichmentStage
from kubemarine.kubernetes import components
from kubemarine.procedures import upgrade, install
from kubemarine import demo

Expand Down Expand Up @@ -1151,6 +1152,7 @@ def _run_tasks(self, tasks_filter: str) -> demo.FakeResources:
def _run_kubernetes_task(self) -> demo.FakeResources:
with utils.mock_call(kubernetes.upgrade_first_control_plane), \
utils.mock_call(install.deploy_coredns), \
utils.mock_call(components.patch_kubelet_configmap), \
utils.mock_call(kubernetes.upgrade_other_control_planes), \
utils.mock_call(kubernetes.upgrade_workers), \
utils.mock_call(upgrade.kubernetes_cleanup_nodes_versions):
Expand Down

0 comments on commit 4436dbc

Please sign in to comment.