Skip to content

Commit

Permalink
Merge branch 'w/2.5/bugfix/GH-2601-fix-bootstrap-restore' into tmp/oc…
Browse files Browse the repository at this point in the history
…topus/w/2.6/bugfix/GH-2601-fix-bootstrap-restore
  • Loading branch information
bert-e committed Jun 9, 2020
2 parents c3f68de + 7aceefd commit 56e0ee4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions salt/_modules/metalk8s_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,22 @@ def method(manifest=None, name=None, kind=None, apiVersion=None,
update_object = _object_manipulation_function('update')


# Check if a specific object exists
def object_exists(kind, apiVersion, name, **kwargs):
"""
Simple helper to check if an object exists or not
CLI Examples:
.. code-block:: bash
salt-call metalk8s_kubernetes.object_exists kind="Node" apiVersion="v1" name="MyNode"
"""
return get_object(
kind=kind, apiVersion=apiVersion, name=name, **kwargs
) is not None


# Listing resources can benefit from a simpler signature
def list_objects(kind, apiVersion, namespace='default', all_namespaces=False,
field_selector=None, label_selector=None, **kwargs):
Expand Down
11 changes: 11 additions & 0 deletions salt/metalk8s/kubernetes/mark-control-plane/deployed.sls.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
{%- set node_name = pillar.bootstrap_id %}
{%- set cri_socket = kubelet.service.options['container-runtime-endpoint'] %}

Ensure node {{ node_name }} exists:
test.configurable_test_state:
- changes: False
- result: __slot__:salt:metalk8s_kubernetes.object_exists(
kind="Node", apiVersion="v1", name="{{ node_name }}")
# Retry as kubelet may take time to register
- retry:
attempts: 5

Mark control plane node:
metalk8s_kubernetes.object_updated:
- name: {{ node_name }}
Expand All @@ -24,3 +33,5 @@ Mark control plane node:
effect: "NoSchedule"
- key: "node-role.kubernetes.io/infra"
effect: "NoSchedule"
- require:
- test: Ensure node {{ node_name }} exists

0 comments on commit 56e0ee4

Please sign in to comment.