rewrite downloading system packages of different OSes

pull/1282/head
gjmzj 2023-05-06 19:37:43 +08:00
parent 215667cdc9
commit 1d309caa2a
5 changed files with 127 additions and 9 deletions

View File

@ -0,0 +1,67 @@
# 操作系统说明
目前发现部分使用新内核的linux发行版k8s 安装使用 cgroup v2版本时有时候安装会失败需要删除/清理集群后重新安装。已报告可能发生于 Alma Linux 9, Rocky Linux 9, Fedora 37建议如下步骤处理
- 1.确认系统使用的cgroup v2版本
```
stat -fc %T /sys/fs/cgroup/
cgroup2fs
```
- 2.初次安装时kubelet可能启动失败日志报错类似err="openat2 /sys/fs/cgroup/kubepods.slice/cpu.weight: no such file or directory"
- 3.建议删除集群然后重新安装,一般能够成功
```
# 删除集群
dk ezctl destroy xxxx
# 重启
reboot
# 启动后重新安装
dk ezctl setup xxxx all
```
## Debian
- Debian 11默认可能没有安装iptables使用kubeasz 安装前需要执行:
``` bash
apt update
apt install iptables -y
```
## Alibaba
- Alibaba Linux 3.2104 LTS安装前需要设置如下
``` bash
# 修改使用dnf包管理
sed -i 's/package/dnf/g' /etc/kubeasz/roles/prepare/tasks/redhat.yml
# 指定python版本xxxx为集群名
source ~/.bashrc
dk ezctl setup xxxx all -e ansible_python_interpreter=/usr/bin/python3
```
## Anolis
- Anolis OS 8.x RHCK需要指定python版本
- Anolis OS 8.x ANCK需要指定python版本
``` bash
source ~/.bashrc
dk ezctl setup xxxx all -e ansible_python_interpreter=/usr/bin/python3
```
## openSUSE
- openSUSE Leap 15.4需要安装iptables和指定python版本
``` bash
zypper install iptables
ln -s /usr/sbin/iptables /sbin/iptables
source ~/.bashrc
dk ezctl setup xxxx all -e ansible_python_interpreter=/usr/bin/python3
```

40
ezdown
View File

@ -13,11 +13,11 @@ set -o pipefail
#set -o xtrace
# default settings, can be overridden by cmd line options, see usage
DOCKER_VER=20.10.22
DOCKER_VER=20.10.24
KUBEASZ_VER=3.5.3
K8S_BIN_VER=v1.26.4
EXT_BIN_VER=1.7.1
SYS_PKG_VER=0.5.2
SYS_PKG_VER=1.0.0
HARBOR_VER=v2.6.4
REGISTRY_MIRROR=CN
@ -47,7 +47,7 @@ function usage() {
option:
-C stop&clean all local containers
-D download default binaries/images into "$BASE"
-P download system packages for offline installing
-P <OS> download system packages of the OS (ubuntu_22,debian_11,...)
-R download Registry(harbor) offline installer
-S start kubeasz in a container
-X download extra images
@ -56,11 +56,35 @@ function usage() {
-e <ver> set kubeasz-ext-bin version, default "$EXT_BIN_VER"
-k <ver> set kubeasz-k8s-bin version, default "$K8S_BIN_VER"
-m <str> set docker registry mirrors, default "CN"(used in Mainland,China)
-p <ver> set kubeasz-sys-pkg version, default "$SYS_PKG_VER"
-z <ver> set kubeasz version, default "$KUBEASZ_VER"
EOF
}
function usage-down-sys-pkg(){
echo -e "\033[33mUsage:\033[0m ezdown -P <OS>"
cat <<EOF
available OSes:
almalinux_8 to down package for AlmaLinux 8
almalinux_9 to down package for AlmaLinux 9
centos_7 to down package for CentOS 7
debian_10 to down package for Debian 10
debian_11 to down package for Debian 11
fedora_34 to down package for Fedora 34
fedora_35 to down package for Fedora 35
fedora_36 to down package for Fedora 36
fedora_37 to down package for Fedora 37
opensuse_leap_15 to down package for openSUSE Leap 15
rocky_8 to down package for Rocky Linux 8
rocky_9 to down package for Rocky Linux 9
ubuntu_16 to down package for Ubuntu 16.04
ubuntu_18 to down package for Ubuntu 18.04
ubuntu_20 to down package for Ubuntu 20.04
ubuntu_22 to down package for Ubuntu 22.04
examples:
./ezdown -P ubuntu_22
EOF
}
function logger() {
TIMESTAMP=$(date +'%Y-%m-%d %H:%M:%S')
case "$1" in
@ -588,7 +612,7 @@ function main() {
[[ "$#" -eq 0 ]] && { usage >&2; exit 1; }
ACTION=""
while getopts "CDPRSXa:d:e:k:m:p:z:" OPTION; do
while getopts "CDP:RSXa:d:e:k:m:z:" OPTION; do
case "$OPTION" in
C)
ACTION="clean_container"
@ -598,6 +622,9 @@ function main() {
;;
P)
ACTION="get_sys_pkg"
[[ $OPTARG =~ (ubuntu_[0-9]+|centos_[0-9]+|debian_[0-9]+|fedora_[0-9]+|almalinux_[0-9]+|opensuse_leap_[0-9]+|rocky_[0-9]+) ]] || \
{ usage-down-sys-pkg; exit 1; }
SYS_PKG_VER="${SYS_PKG_VER}_$OPTARG"
;;
R)
ACTION="get_harbor_offline_pkg"
@ -623,9 +650,6 @@ function main() {
m)
REGISTRY_MIRROR="$OPTARG"
;;
p)
SYS_PKG_VER="$OPTARG"
;;
z)
KUBEASZ_VER="$OPTARG"
;;

View File

@ -2,7 +2,13 @@
when: 'ansible_distribution_file_variety in ["Debian"]'
- import_tasks: redhat.yml
when: 'ansible_distribution_file_variety in ["RedHat"]'
when: 'ansible_distribution_file_variety in ["RedHat"]'
- import_tasks: suse.yml
when: 'ansible_distribution_file_variety in ["SUSE"]'
- import_tasks: redhat.yml
when: 'ansible_distribution in ["Anolis OS"]'
# 公共系统参数设置
- import_tasks: common.yml

View File

@ -43,6 +43,7 @@
state: present
regexp: 'ModLoad imjournal'
line: '#$ModLoad imjournal # provides access to the systemd journal'
ignore_errors: true
- name: 禁止rsyslog获取journald日志2
lineinfile:
@ -50,6 +51,8 @@
state: present
regexp: 'IMJournalStateFile'
line: '#$IMJournalStateFile imjournal.state'
ignore_errors: true
- name: 重启rsyslog服务
service: name=rsyslog state=restarted
ignore_errors: true

View File

@ -0,0 +1,18 @@
- name: 安装基础软件包
package:
name:
- bash-completion # bash命令补全工具需要重新登录服务器生效
- conntrack-tools # ipvs 模式需要
- ipset # ipvs 模式需要
- ipvsadm # ipvs 模式需要
- libseccomp2 # 安装containerd需要
- nfs-client # 挂载nfs 共享文件需要 (创建基于 nfs的PV 需要)
- psmisc # 安装psmisc 才能使用命令killallkeepalive的监测脚本需要
- rsync # 文件同步工具,分发证书等配置文件需要
- socat # 用于port forwarding
state: present
when: 'INSTALL_SOURCE != "offline"'
# 离线安装基础软件包
- import_tasks: offline.yml
when: 'INSTALL_SOURCE == "offline"'