From 359009bb05fe8fd04ea302331fe227216e451ece Mon Sep 17 00:00:00 2001 From: Takashi Okamoto Date: Mon, 30 Jul 2018 18:55:25 +0900 Subject: [PATCH] Download etcd and hyperkube binary. --- roles/download/defaults/main.yml | 30 ++++++++++++++++++++ roles/download/tasks/main.yml | 1 + roles/etcd/tasks/install_host.yml | 28 +++++++++++------- roles/kubernetes/master/tasks/main.yml | 24 ++++++---------- roles/kubernetes/node/tasks/install_host.yml | 24 +++++++--------- 5 files changed, 67 insertions(+), 40 deletions(-) diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index 97c8d8562..546cdbc63 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -48,8 +48,12 @@ cilium_version: "v1.2.0" # Download URLs kubeadm_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kubeadm_version }}/bin/linux/{{ image_arch }}/kubeadm" vault_download_url: "https://releases.hashicorp.com/vault/{{ vault_version }}/vault_{{ vault_version }}_linux_{{ image_arch }}.zip" +etcd_download_url: "https://github.com/coreos/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-amd64.tar.gz" +hyperkube_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/amd64/hyperkube" # Checksums +etcd_checksum: b729db0732448064271ea6fdcb901773c4fe917763ca07776f22d0e5e0bd4097 +hyperkube_checksum: d727f8cae3fc26b1add9b4ff0d4d9b99605544ff7fb3baeecdca394362adbfb8 kubeadm_checksum: 6b17720a65b8ff46efe92a5544f149c39a221910d89939838d75581d4e6924c0 vault_binary_checksum: 3c4d70ba71619a43229e65c67830e30e050eab7a81ac6b28325ff707e5914188 @@ -173,6 +177,19 @@ downloads: sha256: "{{ etcd_digest_checksum|default(None) }}" groups: - etcd + etcd_file: + enabled: true + file: true + version: "{{ etcd_version }}" + dest: "etcd-{{ etcd_version }}-linux-amd64.tar.gz" + sha256: "{{ etcd_checksum }}" + source_url: "{{ etcd_download_url }}" + url: "{{ etcd_download_url }}" + unarchive: true + owner: "root" + mode: "0755" + groups: + - etcd kubeadm: enabled: "{{ kubeadm_enabled }}" file: true @@ -194,6 +211,19 @@ downloads: sha256: "{{ hyperkube_digest_checksum|default(None) }}" groups: - k8s-cluster + hyperkube_file: + enabled: true + file: true + version: "{{ kube_version }}" + dest: "hyperkube" + sha256: "{{ hyperkube_checksum }}" + source_url: "{{ hyperkube_download_url }}" + url: "{{ hyperkube_download_url }}" + unarchive: false + owner: "root" + mode: "0755" + groups: + - k8s-cluster cilium: enabled: "{{ kube_network_plugin == 'cilium' }}" container: true diff --git a/roles/download/tasks/main.yml b/roles/download/tasks/main.yml index 6a317fd89..190fb737d 100644 --- a/roles/download/tasks/main.yml +++ b/roles/download/tasks/main.yml @@ -11,6 +11,7 @@ when: - not skip_downloads|default(false) - item.value.enabled + - not item.value.container | item.value.container and download_container - name: "Sync container" include_tasks: sync_container.yml diff --git a/roles/etcd/tasks/install_host.yml b/roles/etcd/tasks/install_host.yml index 1d06a7d5a..0dc226e66 100644 --- a/roles/etcd/tasks/install_host.yml +++ b/roles/etcd/tasks/install_host.yml @@ -1,13 +1,21 @@ --- -- name: Install | Copy etcdctl and etcd binary from docker container - command: sh -c "{{ docker_bin_dir }}/docker rm -f etcdctl-binarycopy; - {{ docker_bin_dir }}/docker create --name etcdctl-binarycopy {{ etcd_image_repo }}:{{ etcd_image_tag }} && - {{ docker_bin_dir }}/docker cp etcdctl-binarycopy:/usr/local/bin/etcdctl {{ bin_dir }}/etcdctl && - {{ docker_bin_dir }}/docker cp etcdctl-binarycopy:/usr/local/bin/etcd {{ bin_dir }}/etcd && - {{ docker_bin_dir }}/docker rm -f etcdctl-binarycopy" - register: etcd_task_result - until: etcd_task_result.rc == 0 - retries: 4 - delay: "{{ retry_stagger | random + 3 }}" +- name: install | Copy etcd binary from download dir + shell: | + rsync -piu "{{ local_release_dir }}/etcd-{{ etcd_version }}-linux-amd64/etcd" "{{ bin_dir }}/etcd" + rsync -piu "{{ local_release_dir }}/etcd-{{ etcd_version }}-linux-amd64/etcdctl" "{{ bin_dir }}/etcdctl" changed_when: false when: etcd_cluster_setup + +- name: install | Set etcd binary permissions + file: + path: "{{ bin_dir }}/etcd" + mode: "0755" + state: file + when: etcd_cluster_setup + +- name: install | Set etcdctl binary permissions + file: + path: "{{ bin_dir }}/etcdctl" + mode: "0755" + state: file + when: etcd_cluster_setup \ No newline at end of file diff --git a/roles/kubernetes/master/tasks/main.yml b/roles/kubernetes/master/tasks/main.yml index be2044e31..93da9760b 100644 --- a/roles/kubernetes/master/tasks/main.yml +++ b/roles/kubernetes/master/tasks/main.yml @@ -9,27 +9,19 @@ - import_tasks: encrypt-at-rest.yml when: kube_encrypt_secret_data -- name: Compare host kubectl with hyperkube container - command: "{{ docker_bin_dir }}/docker run --rm -v {{ bin_dir }}:/systembindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /usr/bin/cmp /hyperkube /systembindir/kubectl" - register: kubectl_task_compare_result - until: kubectl_task_compare_result.rc in [0,1,2] - retries: 4 - delay: "{{ retry_stagger | random + 3 }}" +- name: install | Copy kubectl binary from download dir + command: rsync -piu "{{ local_release_dir }}/hyperkube" "{{ bin_dir }}/kubectl" changed_when: false - failed_when: "kubectl_task_compare_result.rc not in [0,1,2]" tags: - hyperkube - kubectl - upgrade -- name: Copy kubectl from hyperkube container - command: "{{ docker_bin_dir }}/docker run --rm -v {{ bin_dir }}:/systembindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/cp -f /hyperkube /systembindir/kubectl" - when: kubectl_task_compare_result.rc != 0 - register: kubectl_task_result - until: kubectl_task_result.rc == 0 - retries: 4 - delay: "{{ retry_stagger | random + 3 }}" - changed_when: false +- name: install | Set kubectl binary permissions + file: + path: "{{ bin_dir }}/kubectl" + mode: "0755" + state: file tags: - hyperkube - kubectl @@ -37,7 +29,7 @@ - name: Install kubectl bash completion shell: "{{ bin_dir }}/kubectl completion bash >/etc/bash_completion.d/kubectl.sh" - when: kubectl_task_compare_result.rc != 0 and ansible_os_family in ["Debian","RedHat"] + when: ansible_os_family in ["Debian","RedHat"] tags: - kubectl diff --git a/roles/kubernetes/node/tasks/install_host.yml b/roles/kubernetes/node/tasks/install_host.yml index 7fcb4a01d..47a53b281 100644 --- a/roles/kubernetes/node/tasks/install_host.yml +++ b/roles/kubernetes/node/tasks/install_host.yml @@ -1,23 +1,19 @@ --- -- name: install | Compare host kubelet with hyperkube container - command: "{{ docker_bin_dir }}/docker run --rm -v {{ bin_dir }}:/systembindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /usr/bin/cmp /hyperkube /systembindir/kubelet" - register: kubelet_task_compare_result - until: kubelet_task_compare_result.rc in [0,1,2] - retries: 4 - delay: "{{ retry_stagger | random + 3 }}" + +- name: install | Copy kubelet binary from download dir + command: rsync -piu "{{ local_release_dir }}/hyperkube" "{{ bin_dir }}/kubelet" changed_when: false - failed_when: "kubelet_task_compare_result.rc not in [0,1,2]" + when: hyperkube_enabled tags: - hyperkube - upgrade -- name: install | Copy kubelet from hyperkube container - command: "{{ docker_bin_dir }}/docker run --rm -v {{ bin_dir }}:/systembindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/cp -f /hyperkube /systembindir/kubelet" - when: kubelet_task_compare_result.rc != 0 - register: kubelet_task_result - until: kubelet_task_result.rc == 0 - retries: 4 - delay: "{{ retry_stagger | random + 3 }}" +- name: install | Set kubelet binary permissions + file: + path: "{{ bin_dir }}/kubelet" + mode: "0755" + state: file + when: hyperkube_enabled tags: - hyperkube - upgrade