Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move node selection from --limit to --extra-vars=node<nodename>" #2948

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,26 @@ Remove nodes

You may want to remove **worker** nodes to your existing cluster. This can be done by re-running the `remove-node.yml` playbook. First, all nodes will be drained, then stop some kubernetes services and delete some certificates, and finally execute the kubectl command to delete these nodes. This can be combined with the add node function, This is generally helpful when doing something like autoscaling your clusters. Of course if a node is not working, you can remove the node and install it again.

- Add worker nodes to the list under kube-node if you want to delete them (or utilize a [dynamic inventory](https://docs.ansible.com/ansible/intro_dynamic_inventory.html)).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of these two kinds of deletions should be added. There is only one description at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Add worker nodes to the list under kube-node if you want to delete them (or utilize a dynamic inventory).
    ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml -b -v
    --private-key=~/.ssh/private_key
    We still need this description. Please add. Thanks.

- Run the ansible-playbook command, substituting `remove-node.yml`:
Add worker nodes to the list under kube-node if you want to delete them (or utilize a [dynamic inventory](https://docs.ansible.com/ansible/intro_dynamic_inventory.html)).

ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml -b -v \
--private-key=~/.ssh/private_key


We support two ways to select the nodes:

- Use `--extra-vars "node=<nodename>,<nodename2>"` to select the node you want to delete.
```
ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml -b -v \
--private-key=~/.ssh/private_key \
--extra-vars "node=nodename,nodename2"
```
or
- Use `--limit nodename,nodename2` to select the node
```
ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml -b -v \
--private-key=~/.ssh/private_key
--private-key=~/.ssh/private_key \
--limit nodename,nodename2"
```

Connecting to Kubernetes
Expand Down
4 changes: 2 additions & 2 deletions remove-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ansible_ssh_pipelining: true
gather_facts: true

- hosts: etcd:k8s-cluster:vault:calico-rr
- hosts: "{{ node | default('etcd:k8s-cluster:vault:calico-rr') }}"
vars_prompt:
name: "delete_nodes_confirmation"
prompt: "Are you sure you want to delete nodes state? Type 'yes' to delete nodes."
Expand All @@ -22,7 +22,7 @@
roles:
- { role: remove-node/pre-remove, tags: pre-remove }

- hosts: kube-node
- hosts: "{{ node | default('kube-node') }}"
roles:
- { role: kubespray-defaults }
- { role: reset, tags: reset }
Expand Down
2 changes: 1 addition & 1 deletion roles/remove-node/post-remove/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- name: Delete node
command: kubectl delete node {{ item }}
with_items:
- "{{ groups['kube-node'] }}"
- "{{ node.split(',') | default(groups['kube-node']) }}"
delegate_to: "{{ groups['kube-master']|first }}"
run_once: true
ignore_errors: yes
2 changes: 1 addition & 1 deletion roles/remove-node/pre-remove/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
--timeout {{ drain_timeout }}
--delete-local-data {{ item }}
with_items:
- "{{ groups['kube-node'] }}"
- "{{ node.split(',') | default(groups['kube-node']) }}"
failed_when: false
delegate_to: "{{ groups['kube-master']|first }}"
run_once: true
Expand Down