Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
k8s upgrade role init
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Short <[email protected]>
  • Loading branch information
chris-short committed Mar 13, 2018
1 parent e0165ba commit 98b28d8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
71 changes: 71 additions & 0 deletions roles/upgrade/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# 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
1 change: 1 addition & 0 deletions roles/upgrade/templates/kubernetes.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb http://apt.kubernetes.io/ kubernetes-xenial main
3 changes: 3 additions & 0 deletions upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- hosts: all
roles:
- upgrade

0 comments on commit 98b28d8

Please sign in to comment.