Skip to content

Commit

Permalink
Install etcdutl file by default (kubernetes-sigs#10385)
Browse files Browse the repository at this point in the history
  • Loading branch information
liupeng0518 authored and guy.gold committed Oct 30, 2023
1 parent 70ef25c commit a2a531d
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 99 deletions.
5 changes: 0 additions & 5 deletions roles/etcd/tasks/install_docker.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---

- name: Install etcdctl from docker
import_tasks: install_etcdctl_docker.yml
when: etcd_cluster_setup

- name: Get currently-deployed etcd version
shell: "{{ docker_bin_dir }}/docker ps --filter='name={{ etcd_member_name }}' --format='{{ '{{ .Image }}' }}'"
register: etcd_current_docker_image
Expand Down
11 changes: 0 additions & 11 deletions roles/etcd/tasks/install_etcdctl_docker.yml

This file was deleted.

12 changes: 1 addition & 11 deletions roles/etcd/tasks/install_host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,12 @@
- etcd_events_cluster_setup
- etcd_version.lstrip('v') not in etcd_current_host_version.stdout | default('')

- name: Install | Download etcd and etcdctl
include_tasks: "../../download/tasks/download_file.yml"
vars:
download: "{{ download_defaults | combine(downloads.etcd) }}"
when: etcd_cluster_setup
tags:
- never
- etcd

- name: Install | Copy etcd and etcdctl binary from download dir
- name: Install | Copy etcd binary from download dir
copy:
src: "{{ local_release_dir }}/etcd-{{ etcd_version }}-linux-{{ host_architecture }}/{{ item }}"
dest: "{{ bin_dir }}/{{ item }}"
mode: 0755
remote_src: yes
with_items:
- etcd
- etcdctl
when: etcd_cluster_setup
11 changes: 11 additions & 0 deletions roles/etcd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@
- master
- network

- name: Install etcdctl and etcdutl binary
import_role:
name: etcdctl_etcdutl
tags:
- etcdctl
- etcdutl
- upgrade
when:
- inventory_hostname in groups['etcd']
- etcd_cluster_setup

- name: Install etcd
include_tasks: "install_{{ etcd_deployment_type }}.yml"
when: is_etcd_master
Expand Down
70 changes: 0 additions & 70 deletions roles/etcdctl/tasks/main.yml

This file was deleted.

45 changes: 45 additions & 0 deletions roles/etcdctl_etcdutl/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
- name: Copy etcdctl and etcdutl binary from docker container
command: sh -c "{{ docker_bin_dir }}/docker rm -f etcdxtl-binarycopy;
{{ docker_bin_dir }}/docker create --name etcdxtl-binarycopy {{ etcd_image_repo }}:{{ etcd_image_tag }} &&
{{ docker_bin_dir }}/docker cp etcdxtl-binarycopy:/usr/local/bin/{{ item }} {{ bin_dir }}/{{ item }} &&
{{ docker_bin_dir }}/docker rm -f etcdxtl-binarycopy"
with_items:
- etcdctl
- etcdutl
register: etcdxtl_install_result
until: etcdxtl_install_result.rc == 0
retries: "{{ etcd_retries }}"
delay: "{{ retry_stagger | random + 3 }}"
changed_when: false
when: container_manager == "docker"

- name: Download etcd binary
include_tasks: "../../download/tasks/download_file.yml"
vars:
download: "{{ download_defaults | combine(downloads.etcd) }}"
when: container_manager in ['crio', 'containerd']

- name: Copy etcd binary
unarchive:
src: "{{ downloads.etcd.dest }}"
dest: "{{ local_release_dir }}/"
remote_src: yes
when: container_manager in ['crio', 'containerd']

- name: Copy etcdctl and etcdutl binary from download dir
copy:
src: "{{ local_release_dir }}/etcd-{{ etcd_version }}-linux-{{ host_architecture }}/{{ item }}"
dest: "{{ bin_dir }}/{{ item }}"
mode: 0755
remote_src: yes
with_items:
- etcdctl
- etcdutl
when: container_manager in ['crio', 'containerd']

- name: Create etcdctl wrapper script
template:
src: etcdctl.sh.j2
dest: "{{ bin_dir }}/etcdctl.sh"
mode: 0755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# example invocation: etcdctl.sh get --keys-only --from-key ""

etcdctl \
{% if etcd_deployment_type == "kubeadm" %}
--cacert {{ kube_cert_dir }}/etcd/ca.crt \
--cert {{ kube_cert_dir }}/etcd/server.crt \
--key {{ kube_cert_dir }}/etcd/server.key "$@"
{% else %}
--cacert {{ etcd_cert_dir }}/etcd/ca.crt \
--cert {{ etcd_cert_dir }}/etcd/server.crt \
--key {{ etcd_cert_dir }}/etcd/server.key "$@"
{% endif %}
7 changes: 5 additions & 2 deletions roles/kubernetes/control-plane/tasks/kubeadm-etcd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
tags:
- network

- name: Ensure etcdctl script is installed
- name: Ensure etcdctl and etcdutl script is installed
import_role:
name: etcdctl
name: etcdctl_etcdutl
when: etcd_deployment_type == "kubeadm"
tags:
- etcdctl
- etcdutl

- name: Set ownership for etcd data directory
file:
Expand Down

0 comments on commit a2a531d

Please sign in to comment.