restart scheduler and controller-manager too

This commit is contained in:
Matthew Mosesohn 2017-03-24 18:29:28 +03:00
parent eab686bd56
commit 1e1dfe2cab
6 changed files with 24 additions and 18 deletions

View file

@ -54,6 +54,8 @@
command: "{{ bin_dir }}/kubectl create -f {{kube_config_dir}}/{{system_namespace}}-ns.yml"
retries: 4
delay: "{{ retry_stagger | random + 3 }}"
register: create_system_ns
until: create_system_ns.rc == 0
changed_when: False
when: kubesystem|failed and inventory_hostname == groups['kube-master'][0]
tags: apps

View file

@ -1,4 +1,13 @@
---
- name: "Post-upgrade | restart kubelet on all masters"
service:
name: kubelet
state: restarted
delegate_to: "{{item}}"
with_items: "{{groups['kube-master']}}"
register: kube_apiserver_manifest_replaced
when: needs_etcd_migration|bool
- name: "Post-upgrade | etcd3 upgrade | purge etcd2 k8s data"
command: "{{ bin_dir }}/etcdctl --endpoints={{ etcd_access_addresses }} rm -r /registry"
environment:

View file

@ -55,13 +55,15 @@
set_fact:
needs_etcd_migration: "{{ kube_apiserver_storage_backend == 'etcd3' and data_migrated.stdout_lines|length == 0 and old_data_exists.rc == 0 }}"
- name: "Pre-upgrade | Write invalid image to kube-apiserver manifest if necessary on all kube-masters"
- name: "Pre-upgrade | Write invalid image to master manifests on all kube-masters"
replace:
dest: /etc/kubernetes/manifests/kube-apiserver.manifest
dest: "/etc/kubernetes/manifests/{{item[1]}}.manifest"
regexp: '(\s+)image:\s+.*?$'
replace: '\1image: kill.apiserver.using.fake.image.in:manifest'
delegate_to: "{{item}}"
with_items: "{{groups['kube-master']}}"
delegate_to: "{{item[0]}}"
with_nested:
- "{{groups['kube-master']}}"
- ["kube-apiserver", "kube-controller-manager", "kube-scheduler"]
register: kube_apiserver_manifest_replaced
when: (secret_changed|default(false) or etcd_secret_changed|default(false) or needs_etcd_migration|bool) and kube_apiserver_manifest.stat.exists
@ -95,13 +97,3 @@
delegate_to: "{{item}}"
with_items: "{{groups['etcd']}}"
when: needs_etcd_migration|bool
- name: "Pre-upgrade | restart kubelet on all masters"
service:
name: kubelet
state: restarted
delegate_to: "{{item}}"
with_items: "{{groups['kube-master']}}"
register: kube_apiserver_manifest_replaced
when: needs_etcd_migration|bool

View file

@ -27,9 +27,9 @@
sync_tokens: true
when: >-
{%- set tokens = {'sync': False} -%}
{%- for server in groups['kube-master'] | intersect(ansible_play_hosts)
{%- for server in groups['kube-master'] | intersect(ansible_play_batch)
if (not hostvars[server].known_tokens.stat.exists) or
(hostvars[server].known_tokens.stat.checksum != known_tokens_master.stat.checksum|default('')) -%}
(hostvars[server].known_tokens.stat.checksum|default('') != known_tokens_master.stat.checksum|default('')) -%}
{%- set _ = tokens.update({'sync': True}) -%}
{%- endfor -%}
{{ tokens.sync }}

View file

@ -0,0 +1,3 @@
drain_grace_period: 30
drain_timeout: 40s

View file

@ -1,9 +1,9 @@
---
- name: See if node is in ready state
command: "kubectl get nodes | grep {{ inventory_hostname }}"
shell: "kubectl get nodes | grep {{ inventory_hostname }}"
register: kubectl_nodes
delegate_to: "{{ groups['kube-master'][0] }}"
ignore_errors: true
failed_when: false
- set_fact:
needs_cordoning: >-