Skip to content

Commit

Permalink
Let other nodes get kube binary from master[0] (kubernetes#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
keontang committed Feb 7, 2017
1 parent 8b276fa commit 1168d08
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cluster/caicloud-ansible/roles/flannel/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ flannel_version: 0.5.5

# The default url to download the flannel tar from.
flannel_download_url_base: "http://7xli2p.dl1.z0.glb.clouddn.com"
flannel_download_url: "{{ flannel_download_url_base }}/flannel-{{ flannel_version }}-linux-amd64.tar.gz"
flannel_download_file: "flannel-{{ flannel_version }}-linux-amd64.tar.gz"
flannel_download_url: "{{ flannel_download_url_base }}/{{ flannel_download_file }}"

# The backend that flannel should use.
flannel_backend: "vxlan"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ kube_version: v1.3.3+v0.10.0

# The URL to download Kubernetes binaries from.
kube_download_url_base: "http://7xli2p.dl1.z0.glb.clouddn.com"
kube_download_url: "{{ kube_download_url_base }}/caicloud-kube-{{ kube_version }}.tar.gz"
kube_download_file: "caicloud-kube-{{ kube_version }}.tar.gz"
kube_download_url: "{{ kube_download_url_base }}/{{ kube_download_file }}"

#
# DO NOT CHANGE section
Expand Down
26 changes: 26 additions & 0 deletions cluster/caicloud-ansible/roles/kubernetes-base/files/copy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Copy files from master by scp command in expect script.
#
# Assumed vars:
# REMOTE_FILE_NAME
# REMOTE_USER
# REMOTE_IP
# REMOTE_PASSWORD
# DEST_PATH

expect <<EOF
set timeout -1
spawn scp -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=quiet \
${REMOTE_USER}@${REMOTE_IP}:${REMOTE_FILE_NAME} ${DEST_PATH}
expect {
"*?assword*" {
send -- "${REMOTE_PASSWORD}\r"
exp_continue
}
"?ommand failed" {exit 1}
"lost connection" { exit 1 }
eof {}
}
EOF
19 changes: 14 additions & 5 deletions cluster/caicloud-ansible/roles/kubernetes-base/tasks/qiniu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,25 @@
http_proxy: "{{ http_proxy|default('') }}"
https_proxy: "{{ https_proxy|default('') }}"
no_proxy: "{{ no_proxy|default('') }}"
when: kube_tarball.stat.exists == False
when: kube_tarball.stat.exists == False and inventory_hostname in groups['masters']
register: kube_tarball_download
until: kube_tarball_download|success
retries: 5
delay: 3

- name: Remove existing caicloud-kube
file:
path: /usr/local/caicloud-kube
state: absent
- name: Fetch caicloud kubernetes tar file
script: copy.sh
environment:
REMOTE_FILE_NAME: "{{ kube_current_release_directory }}/{{ kube_download_file }}"
REMOTE_USER: "{{ hostvars[groups['masters'][0]]['ansible_user'] }}"
REMOTE_IP: "{{ hostvars[groups['masters'][0]]['internal_ip'] }}"
REMOTE_PASSWORD: "{{ hostvars[groups['masters'][0]]['ansible_ssh_pass'] }}"
DEST_PATH: "{{ kube_current_release_directory }}"
when: kube_tarball.stat.exists == False and inventory_hostname not in groups['masters']
register: kube_tarball_copy
until: kube_tarball_copy|success
retries: 5
delay: 3

- name: Extract tar file
unarchive:
Expand Down
7 changes: 7 additions & 0 deletions cluster/caicloud-ansible/roles/prologue/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@
- name: CentOS | Be sure libselinux-python are installed
yum: name=libselinux-python
when: ansible_distribution == "CentOS"

# Install expect.
- name: Install expect and rsync
package: name={{ item }} state=present
with_items:
- "expect"
- "rsync"

0 comments on commit 1168d08

Please sign in to comment.