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

Commit 1c290c9

Browse files
authored
[Cherry-pick] fix installation compatibility of ubuntu 20.04 (#5257)
1 parent 6fab928 commit 1c290c9

File tree

13 files changed

+80
-7
lines changed

13 files changed

+80
-7
lines changed

contrib/kubespray/environment-check.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
- hosts: all,localhost
3+
gather_facts: false
4+
roles:
5+
- { role: set-python3 }
6+
27
- hosts: all
38
gather_facts: false
49
tasks:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- hosts: all,localhost
3+
gather_facts: false
4+
roles:
5+
- { role: set-python3 }
6+
7+
- hosts: all
8+
become: true
9+
become_user: root
10+
roles:
11+
- { role: pre-installation }

contrib/kubespray/quick-start-kubespray.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ ansible all -i ${HOME}/pai-deploy/cluster-cfg/hosts.yml -m ping || exit $?
3535
echo "Performing pre-check..."
3636
ansible-playbook -i ${HOME}/pai-pre-check/pre-check.yml set-host-daemon-port-range.yml -e "@${CLUSTER_CONFIG}" || exit $?
3737

38+
echo "Performing pre-installation..."
39+
ansible-playbook -i ${HOME}/pai-deploy/cluster-cfg/hosts.yml pre-installation.yml || exit $?
40+
3841
echo "Starting kubernetes..."
3942
/bin/bash script/kubernetes-boot.sh || exit $?

contrib/kubespray/roles/pre-installation/defaults/main.yml

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# If sshpass is not installed on target machine,
3+
# kubespray 2.11 may have these issues:
4+
# https://github.com/kubernetes-sigs/kubespray/issues/6906
5+
# https://github.com/kubernetes-sigs/kubespray/issues/5693
6+
# This is resolved in PR https://github.com/kubernetes-sigs/kubespray/pull/6907
7+
- name: "Install sshpass"
8+
apt:
9+
name: sshpass
10+
state: present
11+
12+
13+
# workaround for ubuntu 20.04
14+
# This is resolved in https://github.com/kubernetes-sigs/kubespray/pull/6157
15+
- name: "Install Python"
16+
apt:
17+
name: python
18+
state: present
19+
when:
20+
- ansible_distribution_version is version('20.04', '=')
21+

contrib/kubespray/roles/set-python3/defaults/main.yml

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
# Ubuntu 20.04 doesn't have python2 pre-installed,
3+
# but Ubuntu 16.04, 18.04, and 20.04 all have python3 pre-installed.
4+
# So we use python3 as the default interpreter.
5+
# Also, we use `sudo python3` to execute python on dev box machine.
6+
# It is better to align with it here to prevent `ansible-playbook` from failing into another python.
7+
- name: set ansible_python_interpreter to python3
8+
set_fact:
9+
ansible_python_interpreter: "/usr/bin/python3"
10+
11+
- name: output ansible_python_interpreter
12+
debug:
13+
var: ansible_python_interpreter

contrib/kubespray/script/environment.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ sudo apt-get -y install sshpass
4040

4141
echo "Install kubespray's requirements and ansible is included"
4242
sudo python3 -m pip install -r ${HOME}/pai-deploy/kubespray/requirements.txt
43+
44+
# ansible 2.7 doesn't support distribution info collection on Ubuntu 20.04
45+
# Use ansible 2.9.7 as a workaround
46+
# Reference: https://stackoverflow.com/questions/61460151/ansible-not-reporting-distribution-info-on-ubuntu-20-04
47+
# We can upgrade kubespray version to avoid this issue in the future.
48+
sudo python3 -m pip install ansible==2.9.7
49+

contrib/kubespray/script/kubernetes-boot.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
echo "setup k8s cluster"
44
cd ${HOME}/pai-deploy/kubespray
5-
ansible-playbook -i inventory/pai/hosts.yml cluster.yml --become --become-user=root -e "@inventory/pai/openpai.yml" || exit $?
5+
# Ubuntu 20.04 doesn't have python2 pre-installed,
6+
# but Ubuntu 16.04, 18.04, and 20.04 all have python3 pre-installed.
7+
# So we use python3 as the default interpreter.
8+
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 $?
69

710
sudo mkdir -p ${HOME}/pai-deploy/kube || exit $?
811
sudo cp -rf ${HOME}/pai-deploy/kubespray/inventory/pai/artifacts/admin.conf ${HOME}/pai-deploy/kube/config || exit $?

contrib/kubespray/set-host-daemon-port-range.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
- hosts: all,localhost
3+
gather_facts: false
4+
roles:
5+
- { role: set-python3 }
6+
27
- hosts: gpu
38
become: true
49
become_user: root

0 commit comments

Comments
 (0)