From 3981b739245b0df51c393a9629cda1a488b69339 Mon Sep 17 00:00:00 2001 From: Smaine Kahlouch Date: Fri, 11 Dec 2015 11:47:51 +0100 Subject: [PATCH] download only required kubernetes binaries --- roles/download/defaults/main.yml | 16 +++++---- roles/download/tasks/kubernetes.yml | 56 +++++++---------------------- 2 files changed, 22 insertions(+), 50 deletions(-) diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index 9a42c2a11..d21b43752 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -1,13 +1,15 @@ --- -etcd_download_url: https://github.com/coreos/etcd/releases/download -flannel_download_url: https://github.com/coreos/flannel/releases/download -kube_download_url: https://github.com/GoogleCloudPlatform/kubernetes/releases/download -calico_download_url: https://github.com/Metaswitch/calico-docker/releases/download - etcd_version: v2.2.2 flannel_version: 0.5.5 kube_version: v1.1.2 -kube_sha1: 69d110d371752c6492d2f8695aa7a47be5b6ed4e +kubectl_checksum: "e0585c6e63f796d87b34cd1f16554892a49421b98a2862a896b2b7ebf1439ace" +kubelet_checksum: "6c029d34888e1ec4b9ab4b500b0712388984340488c5f3c19e2c759d1003cbff" + +calico_version: v0.12.0 + +etcd_download_url: "https://github.com/coreos/etcd/releases/download" +flannel_download_url: "https://github.com/coreos/flannel/releases/download" +kube_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/amd64" +calico_download_url: "https://github.com/Metaswitch/calico-docker/releases/download" -calico_version: v0.11.0 diff --git a/roles/download/tasks/kubernetes.yml b/roles/download/tasks/kubernetes.yml index de6359d14..0985a17d3 100644 --- a/roles/download/tasks/kubernetes.yml +++ b/roles/download/tasks/kubernetes.yml @@ -1,47 +1,17 @@ --- -- name: Create kubernetes release directory +- name: Create kubernetes binary directory local_action: file - path={{ local_release_dir }}/kubernetes + path="{{ local_release_dir }}/kubernetes/bin" state=directory + recurse=yes -- name: Check if kubernetes release archive has been downloaded - local_action: stat - path={{ local_release_dir }}/kubernetes/kubernetes.tar.gz - register: k_tar - -# issues with get_url module and redirects, to be tested again in the near future -- name: Download kubernetes - local_action: shell - curl -o {{ local_release_dir }}/kubernetes/kubernetes.tar.gz -Ls {{ kube_download_url }}/{{ kube_version }}/kubernetes.tar.gz - when: not k_tar.stat.exists or k_tar.stat.checksum != "{{ kube_sha1 }}" - register: dl_kube - -- name: Compare kubernetes archive checksum - local_action: stat - path={{ local_release_dir }}/kubernetes/kubernetes.tar.gz - register: k_tar - failed_when: k_tar.stat.checksum != "{{ kube_sha1 }}" - when: dl_kube|changed - -- name: Extract kubernetes archive - local_action: unarchive - src={{ local_release_dir }}/kubernetes/kubernetes.tar.gz - dest={{ local_release_dir }}/kubernetes copy=no - when: dl_kube|changed - -- name: Extract kubernetes binaries archive - local_action: unarchive - src={{ local_release_dir }}/kubernetes/kubernetes/server/kubernetes-server-linux-amd64.tar.gz - dest={{ local_release_dir }}/kubernetes copy=no - when: dl_kube|changed - -- name: Pick up only kubernetes binaries - local_action: synchronize - src={{ local_release_dir }}/kubernetes/kubernetes/server/bin - dest={{ local_release_dir }}/kubernetes - when: dl_kube|changed - -- name: Delete unused kubernetes files - local_action: file - path={{ local_release_dir }}/kubernetes/kubernetes state=absent - when: dl_kube|changed +- name: Download kubelet and kubectl + local_action: get_url + url="{{ kube_download_url }}/{{ item.name }}" + dest="{{ local_release_dir }}/kubernetes/bin" + sha256sum="{{ item.checksum }}" + with_items: + - name: kubelet + checksum: "{{ kubelet_checksum }}" + - name: kubectl + checksum: "{{ kubectl_checksum }}"