Skip to content

Commit

Permalink
kubeadm reconfigure implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia1243 committed Feb 1, 2024
1 parent bb10742 commit 7696737
Show file tree
Hide file tree
Showing 11 changed files with 676 additions and 283 deletions.
3 changes: 1 addition & 2 deletions kubemarine/admission.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ def restart_pods_task(cluster: KubernetesCluster) -> None:
first_control_plane.sudo("kubectl rollout restart ds %s -n %s" % (ds["metadata"]["name"], ds["metadata"]["namespace"]))

# we do not know to wait for, only for system pods maybe
cluster.log.debug("Waiting for system pods...")
kubernetes.wait_for_any_pods(cluster, first_control_plane)
kube_nodes.call(kubernetes.components.wait_for_pods)


def update_kubeadm_configmap_psp(first_control_plane: NodeGroup, target_state: str) -> str:
Expand Down
17 changes: 15 additions & 2 deletions kubemarine/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import difflib
import hashlib
import io
import ipaddress
Expand All @@ -22,7 +23,7 @@
import time
import tarfile

from typing import Tuple, Callable, List, TextIO, cast, Union, TypeVar, Dict, Sequence
from typing import Tuple, Callable, List, TextIO, cast, Union, TypeVar, Dict, Sequence, Optional

import deepdiff # type: ignore[import-untyped]
import yaml
Expand Down Expand Up @@ -170,7 +171,7 @@ def make_ansible_inventory(location: str, c: object) -> None:


def get_current_timestamp_formatted() -> str:
return datetime.now().strftime("%Y%m%d-%H%M%S")
return datetime.now().strftime("%Y-%m-%d-%H-%M-%S")


def get_final_inventory(c: object, initial_inventory: dict = None) -> dict:
Expand Down Expand Up @@ -488,6 +489,18 @@ def print_diff(logger: log.EnhancedLogger, diff: deepdiff.DeepDiff) -> None:
logger.debug(yaml.safe_dump(yaml.safe_load(diff.to_json())))


def get_unified_diff(old: str, new: str, fromfile: str = '', tofile: str = '') -> Optional[str]:
diff = list(difflib.unified_diff(
old.splitlines(), new.splitlines(),
fromfile=fromfile, tofile=tofile,
lineterm=''))

if diff:
return '\n'.join(diff)

return None


def isipv(address: str, versions: List[int]) -> bool:
return ipaddress.ip_network(address).version in versions

Expand Down
11 changes: 10 additions & 1 deletion kubemarine/core/yaml_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,13 @@ def list_merger(config: Merger, path: list, base: list, nxt: list) -> list:
],
["override"],
["override"]
)
)

override_merger: Merger = Merger(
[
(list, ["override"]),
(dict, ["merge"])
],
["override"],
["override"]
)
3 changes: 1 addition & 2 deletions kubemarine/k8s_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def renew_apply(control_planes: NodeGroup) -> None:
# for some reason simple pod delete do not work for certs update - we need to delete containers themselves
control_planes.call(force_restart_control_plane)

for control_plane in control_planes.get_ordered_members_list():
kubernetes.wait_for_any_pods(control_planes.cluster, control_plane, apply_filter=control_plane.get_node_name())
kubernetes.components.wait_for_pods(control_planes)


def force_restart_control_plane(control_planes: NodeGroup) -> None:
Expand Down
Loading

0 comments on commit 7696737

Please sign in to comment.