Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
[Cherry-pick] fix installation compatibility of ubuntu 20.04 (#5257)
Browse files Browse the repository at this point in the history
  • Loading branch information
hzy46 authored Jan 18, 2021
1 parent 6fab928 commit 1c290c9
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 7 deletions.
5 changes: 5 additions & 0 deletions contrib/kubespray/environment-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
- hosts: all,localhost
gather_facts: false
roles:
- { role: set-python3 }

- hosts: all
gather_facts: false
tasks:
Expand Down
11 changes: 11 additions & 0 deletions contrib/kubespray/pre-installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- hosts: all,localhost
gather_facts: false
roles:
- { role: set-python3 }

- hosts: all
become: true
become_user: root
roles:
- { role: pre-installation }
3 changes: 3 additions & 0 deletions contrib/kubespray/quick-start-kubespray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ ansible all -i ${HOME}/pai-deploy/cluster-cfg/hosts.yml -m ping || exit $?
echo "Performing pre-check..."
ansible-playbook -i ${HOME}/pai-pre-check/pre-check.yml set-host-daemon-port-range.yml -e "@${CLUSTER_CONFIG}" || exit $?

echo "Performing pre-installation..."
ansible-playbook -i ${HOME}/pai-deploy/cluster-cfg/hosts.yml pre-installation.yml || exit $?

echo "Starting kubernetes..."
/bin/bash script/kubernetes-boot.sh || exit $?
Empty file.
21 changes: 21 additions & 0 deletions contrib/kubespray/roles/pre-installation/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# If sshpass is not installed on target machine,
# kubespray 2.11 may have these issues:
# https://github.com/kubernetes-sigs/kubespray/issues/6906
# https://github.com/kubernetes-sigs/kubespray/issues/5693
# This is resolved in PR https://github.com/kubernetes-sigs/kubespray/pull/6907
- name: "Install sshpass"
apt:
name: sshpass
state: present


# workaround for ubuntu 20.04
# This is resolved in https://github.com/kubernetes-sigs/kubespray/pull/6157
- name: "Install Python"
apt:
name: python
state: present
when:
- ansible_distribution_version is version('20.04', '=')

Empty file.
13 changes: 13 additions & 0 deletions contrib/kubespray/roles/set-python3/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# Ubuntu 20.04 doesn't have python2 pre-installed,
# but Ubuntu 16.04, 18.04, and 20.04 all have python3 pre-installed.
# So we use python3 as the default interpreter.
# Also, we use `sudo python3` to execute python on dev box machine.
# It is better to align with it here to prevent `ansible-playbook` from failing into another python.
- name: set ansible_python_interpreter to python3
set_fact:
ansible_python_interpreter: "/usr/bin/python3"

- name: output ansible_python_interpreter
debug:
var: ansible_python_interpreter
7 changes: 7 additions & 0 deletions contrib/kubespray/script/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ sudo apt-get -y install sshpass

echo "Install kubespray's requirements and ansible is included"
sudo python3 -m pip install -r ${HOME}/pai-deploy/kubespray/requirements.txt

# ansible 2.7 doesn't support distribution info collection on Ubuntu 20.04
# Use ansible 2.9.7 as a workaround
# Reference: https://stackoverflow.com/questions/61460151/ansible-not-reporting-distribution-info-on-ubuntu-20-04
# We can upgrade kubespray version to avoid this issue in the future.
sudo python3 -m pip install ansible==2.9.7

5 changes: 4 additions & 1 deletion contrib/kubespray/script/kubernetes-boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

echo "setup k8s cluster"
cd ${HOME}/pai-deploy/kubespray
ansible-playbook -i inventory/pai/hosts.yml cluster.yml --become --become-user=root -e "@inventory/pai/openpai.yml" || exit $?
# Ubuntu 20.04 doesn't have python2 pre-installed,
# but Ubuntu 16.04, 18.04, and 20.04 all have python3 pre-installed.
# So we use python3 as the default interpreter.
ansible-playbook -i inventory/pai/hosts.yml -e "ansible_python_interpreter=/usr/bin/python3" cluster.yml --become --become-user=root -e "@inventory/pai/openpai.yml" || exit $?

sudo mkdir -p ${HOME}/pai-deploy/kube || exit $?
sudo cp -rf ${HOME}/pai-deploy/kubespray/inventory/pai/artifacts/admin.conf ${HOME}/pai-deploy/kube/config || exit $?
Expand Down
5 changes: 5 additions & 0 deletions contrib/kubespray/set-host-daemon-port-range.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
- hosts: all,localhost
gather_facts: false
roles:
- { role: set-python3 }

- hosts: gpu
become: true
become_user: root
Expand Down
5 changes: 5 additions & 0 deletions contrib/kubespray/set-kubectl.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
- hosts: all,localhost
gather_facts: false
roles:
- { role: set-python3 }

- hosts: localhost
gather_facts: false
tasks:
Expand Down
6 changes: 3 additions & 3 deletions docs/manual/cluster-admin/installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We recommend you to use CPU-only machines for dev box and master. The detailed r
</td>
<td>
<ul>
<li>Ubuntu 16.04 (18.04 should work, but not fully tested)</li>
<li>Ubuntu 16.04 (18.04, 20.04 should work, but not fully tested)</li>
<li>SSH service is enabled.</li>
<li>Passwordless ssh to all other machines (master and worker machines).</li>
<li>Docker is installed.</li>
Expand All @@ -52,7 +52,7 @@ We recommend you to use CPU-only machines for dev box and master. The detailed r
</td>
<td>
<ul>
<li>Ubuntu 16.04 (18.04 should work, but not fully tested)</li>
<li>Ubuntu 16.04 (18.04, 20.04 should work, but not fully tested)</li>
<li>SSH service is enabled. </li>
<li>It shares the same username/password with worker machines, and have sudo privilege.</li>
<li>Docker is installed.</li>
Expand Down Expand Up @@ -100,7 +100,7 @@ Please check the following requirements for different types of worker machines:
</td>
<td>
<ul>
<li>Ubuntu 16.04 (18.04 should work, but not fully tested)</li>
<li>Ubuntu 16.04 (18.04, 20.04 should work, but not fully tested)</li>
<li>SSH service is enabled. </li>
<li>It shares the same username/password with all other machines, and have sudo privilege.</li>
<li>Docker is installed.</li>
Expand Down
6 changes: 3 additions & 3 deletions docs_zh_CN/manual/cluster-admin/installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ master机器用于运行核心Kubernetes组件和核心OpenPAI服务。目前,
</td>
<td>
<ul>
<li>Ubuntu 16.04 (18.04应该可用,但没有经过完整测试)</li>
<li>Ubuntu 16.04 (18.04、20.04应该可用,但没有经过完整测试)</li>
<li>SSH服务已开启。</li>
<li>可以免密登录所有master和worker机器。</li>
<li>Docker已被正确安装。</li>
Expand All @@ -52,7 +52,7 @@ master机器用于运行核心Kubernetes组件和核心OpenPAI服务。目前,
</td>
<td>
<ul>
<li>Ubuntu 16.04 (18.04应该可用,但没有经过完整测试)</li>
<li>Ubuntu 16.04 (18.04、20.04应该可用,但没有经过完整测试)</li>
<li>SSH服务已开启。</li>
<li>和所有worker机器有同样的SSH用户名和密码,且该SSH用户有sudo权限。</li>
<li>Docker已被正确安装。</li>
Expand Down Expand Up @@ -100,7 +100,7 @@ hivedscheduler是OpenPAI的默认调度器,它支持虚拟集群划分,拓
</td>
<td>
<ul>
<li>Ubuntu 16.04 (18.04应该可用,但没有经过完整测试)</li>
<li>Ubuntu 16.04 (18.04、20.04应该可用,但没有经过完整测试)</li>
<li>SSH服务已开启。 </li>
<li>所有master和worker机器有同样的SSH用户名和密码,且该SSH用户有sudo权限。</li>
<li>Docker已被正确安装。</li>
Expand Down

0 comments on commit 1c290c9

Please sign in to comment.