Skip to content

Commit

Permalink
Use kube_config_dir for kubeconfig (kubernetes-sigs#7996) (kubernetes…
Browse files Browse the repository at this point in the history
…-sigs#8037)

The path of kubeconfig should be configurable, and its default value
is /etc/kubernetes/admin.conf. Most paths of the file are configurable
but some were not. This make those configurable.
  • Loading branch information
oomichi authored and Kevin Huang committed Sep 15, 2022
1 parent 5d50822 commit d931ba2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion roles/kubernetes/control-plane/tasks/kubeadm-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
# FIXME: https://github.com/kubernetes/kubeadm/issues/1318
- name: kubeadm | scale down coredns replicas to 0 if not using coredns dns_mode
command: >-
{{ kubectl }}
{{ bin_dir }}/kubectl
--kubeconfig {{ kube_config_dir }}/admin.conf
-n kube-system
scale deployment/coredns --replicas 0
register: scale_down_coredns
Expand Down
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 @@

- name: remove-node | Drain node except daemonsets resource # noqa 301
command: >-
{{ kubectl }} drain
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf drain
--force
--ignore-daemonsets
--grace-period {{ drain_grace_period }}
Expand Down
2 changes: 1 addition & 1 deletion roles/upgrade/post-upgrade/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- upgrade_node_post_upgrade_pause_seconds != 0

- name: Uncordon node
command: "{{ kubectl }} uncordon {{ kube_override_hostname|default(inventory_hostname) }}"
command: "{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf uncordon {{ kube_override_hostname|default(inventory_hostname) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
when:
- needs_cordoning|default(false)
2 changes: 1 addition & 1 deletion roles/upgrade/pre-upgrade/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

rescue:
- name: Set node back to schedulable
command: "{{ kubectl }} uncordon {{ inventory_hostname }}"
command: "{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf uncordon {{ inventory_hostname }}"
when: upgrade_node_uncordon_after_drain_failure
- name: Fail after rescue
fail:
Expand Down

0 comments on commit d931ba2

Please sign in to comment.