From f4c9caf90c78db007e95be64c4da9290acfdbc6e Mon Sep 17 00:00:00 2001 From: Chris Short Date: Tue, 13 Mar 2018 10:41:40 -0400 Subject: [PATCH] upgrade playbook ready Signed-off-by: Chris Short --- roles/upgrade/tasks/main.yml | 71 ------------------------- roles/upgrade/templates/kubernetes.list | 1 - upgrade.yml | 58 +++++++++++++++++++- 3 files changed, 56 insertions(+), 74 deletions(-) delete mode 100644 roles/upgrade/tasks/main.yml delete mode 100644 roles/upgrade/templates/kubernetes.list diff --git a/roles/upgrade/tasks/main.yml b/roles/upgrade/tasks/main.yml deleted file mode 100644 index 1eff9c2..0000000 --- a/roles/upgrade/tasks/main.yml +++ /dev/null @@ -1,71 +0,0 @@ ---- -# tasks file for upgrade - -- name: Add Google Cloud Repo Key - shell: curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - - -- name: Add Kubernetes to Available apt Sources - template: - src: kubernetes.list - dest: /etc/apt/sources.list.d/kubernetes.list - owner: root - group: root - mode: 0644 - -- name: apt-get update - apt: - update_cache: yes - autoclean: yes - autoremove: yes - -- name: Upgrade kubeadm - apt: - name: "{{ item }}" - state: latest - with_items: - - kubeadm - delegate_to: master - -#- name: Determine latest stable version of Kubernetes -# uri: -# url: https://dl.k8s.io/release/stable.txt -# return_content: yes -# register: stable_ver -- name: Determine latest stable version of Kubernetes - shell: curl -sSL https://dl.k8s.io/release/stable.txt - register: stable_ver - -- name: Upgrade cluster with kubeadm - shell: "kubeadm upgrade apply -y {{ stable_ver.stdout }}" - delegate_to: master - -- name: Cordon Hosts - shell: "kubectl cordon {{ inventory_hostname }}" - delegate_to: master - tags: cordon - -- name: Drain Hosts - shell: "kubectl drain {{ inventory_hostname }} --ignore-daemonsets" - delegate_to: master - ignore_errors: yes - tags: drain - -- name: Upgrade Y'all - apt: - name: "{{ item }}" - state: latest - with_items: - - kubelet - - kubectl - tags: - - kubelet - - kubectl - -- name: Uncordon Hosts - shell: "kubectl uncordon {{ inventory_hostname }}" - delegate_to: master - tags: uncordon - -- name: Show Nodes - shell: kubectl get nodes - delegate_to: master \ No newline at end of file diff --git a/roles/upgrade/templates/kubernetes.list b/roles/upgrade/templates/kubernetes.list deleted file mode 100644 index afbf3e6..0000000 --- a/roles/upgrade/templates/kubernetes.list +++ /dev/null @@ -1 +0,0 @@ -deb http://apt.kubernetes.io/ kubernetes-xenial main \ No newline at end of file diff --git a/upgrade.yml b/upgrade.yml index 80d455a..5d597bb 100644 --- a/upgrade.yml +++ b/upgrade.yml @@ -1,3 +1,57 @@ +- hosts: master + tasks: + - name: apt-get update + apt: + update_cache: yes + autoclean: yes + autoremove: yes + + - name: Upgrade kubeadm + apt: + name: "{{ item }}" + state: latest + with_items: + - kubeadm + + - name: Determine latest stable version of Kubernetes + shell: curl -sSL https://dl.k8s.io/release/stable.txt + register: stable_ver + + - name: Upgrade cluster with kubeadm + shell: "kubeadm upgrade apply -y {{ stable_ver.stdout }}" + async: 300 + poll: 5 + + - name: Cordon Hosts + shell: "kubectl cordon {{ item }}" + with_items: + - "{{ groups['all'] }}" + tags: cordon + + - name: Drain Hosts + shell: "kubectl drain {{ item }} --ignore-daemonsets" + with_items: + - "{{ groups['all'] }}" + ignore_errors: yes + tags: drain + - hosts: all - roles: - - upgrade \ No newline at end of file + tasks: + - name: Upgrade Y'all + apt: + name: "{{ item }}" + state: latest + with_items: + - kubelet + - kubectl + tags: + - kubelet + - kubectl + +- hosts: master + tasks: + - name: Uncordon Hosts + shell: "kubectl uncordon {{ item }}" + with_items: + - "{{ groups['all'] }}" + tags: uncordon \ No newline at end of file