fix: '/usr/bin/python' is not existed in some OS

pull/1166/head
jin.gjm 2022-06-05 19:34:53 +08:00
parent 16b98e41ff
commit b006dcff20
5 changed files with 46 additions and 9 deletions

View File

@ -20,9 +20,21 @@ $ ETCDCTL_API=3 etcdctl --write-out=table snapshot status backup.db
## etcd 集群节点操作
首先确认配置 ssh 免密码登录,然后执行 (假设待操作节点为 192.168.1.11集群名称test-k8s)
执行如下 (假设待操作节点为 192.168.1.11集群名称test-k8s)
- 增加 etcd 节点:
``` bash
# ssh 免密码登录
$ ssh-copy-id 192.168.1.11
# 部分操作系统需要配置python软链接
$ ssh 192.168.1.11 ln -s /usr/bin/python3 /usr/bin/python
# 新增节点
$ ezctl add-etcd test-k8s 192.168.1.11
```
- 增加 etcd 节点:`$ ezctl add-etcd test-k8s 192.168.1.11`
- 删除 etcd 节点:`$ ezctl del-etcd test-k8s 192.168.1.11`
具体操作流程参考 ezctl中 add-etcd/del-etcd 相关函数和playbooks/ 目录的操作剧本

View File

@ -5,7 +5,7 @@
新增`kube_master`节点大致流程为:(参考ezctl 中add-master函数和playbooks/23.addmaster.yml)
- [可选]新节点安装 chrony 时间同步
- 新节点预处理 prepare
- 新节点安装 docker 服务
- 新节点安装 container runtime
- 新节点安装 kube_master 服务
- 新节点安装 kube_node 服务
- 新节点安装网络插件相关
@ -14,9 +14,16 @@
### 操作步骤
首先配置 ssh 免密码登录新增节点,然后执行 (假设待增加节点为 192.168.1.11, 集群名称test-k8s)
执行如下 (假设待增加节点为 192.168.1.11, 集群名称test-k8s)
``` bash
# ssh 免密码登录
$ ssh-copy-id 192.168.1.11
# 部分操作系统需要配置python软链接
$ ssh 192.168.1.11 ln -s /usr/bin/python3 /usr/bin/python
# 新增节点
$ ezctl add-master test-k8s 192.168.1.11
```

View File

@ -10,15 +10,22 @@
新增`kube_node`节点大致流程为:(参考ezctl 里面add-node函数 和 playbooks/22.addnode.yml)
- [可选]新节点安装 chrony 时间同步
- 新节点预处理 prepare
- 新节点安装 docker 服务
- 新节点安装 container runtime
- 新节点安装 kube_node 服务
- 新节点安装网络插件相关
### 操作步骤
首先配置 ssh 免密码登录新增节点,然后执行 (假设待增加节点为 192.168.1.11k8s集群名为 test-k8s)
执行如下 (假设待增加节点为 192.168.1.11k8s集群名为 test-k8s)
``` bash
# ssh 免密码登录
$ ssh-copy-id 192.168.1.11
# 部分操作系统需要配置python软链接
$ ssh 192.168.1.11 ln -s /usr/bin/python3 /usr/bin/python
# 新增节点
$ ezctl add-node test-k8s 192.168.1.11
```
@ -36,9 +43,11 @@ $ kubectl get pod -n kube-system
## 2.增加非标准ssh端口节点
假设待添加节点192.168.2.1ssh 端口 10022配置免密登录 ssh-copy-id -p 10022 192.168.2.1,按提示输入密码,然后执行
假设待添加节点192.168.2.1ssh 端口 10022然后执行
``` bash
$ ssh-copy-id -p 10022 192.168.2.1
$ ssh -p10022 192.168.2.1 ln -s /usr/bin/python3 /usr/bin/python
$ ezctl add-node test-k8s 192.168.2.1 ansible_ssh_port=10022
```

9
ezctl
View File

@ -317,6 +317,9 @@ function add-node() {
# check if the new node already exsited
sed -n '/^\[kube_master/,/^\[harbor/p' "$BASE/clusters/$1/hosts"|grep -E "^$2$|^$2 " && { logger error "node $2 already existed in $BASE/clusters/$1/hosts"; return 2; }
# add '/usr/bin/python' soft link, needed in some OS (ubuntu 16.04+)
[[ ! -e /usr/bin/python && -e /usr/bin/python3 ]] && ssh "$2" ln -s /usr/bin/python3 /usr/bin/python
logger info "add $2 into 'kube_node' group"
NODE_INFO="${@:2}"
sed -i "/\[kube_node/a $NODE_INFO" "$BASE/clusters/$1/hosts"
@ -332,6 +335,9 @@ function add-master() {
# check if the new master already exsited
sed -n '/^\[kube_master/,/^\[kube_node/p' "$BASE/clusters/$1/hosts"|grep -E "^$2$|^$2 " && { logger error "master $2 already existed!"; return 2; }
# add '/usr/bin/python' soft link, needed in some OS (ubuntu 16.04+)
[[ ! -e /usr/bin/python && -e /usr/bin/python3 ]] && ssh "$2" ln -s /usr/bin/python3 /usr/bin/python
logger info "add $2 into 'kube_master' group"
MASTER_INFO="${@:2}"
sed -i "/\[kube_master/a $MASTER_INFO" "$BASE/clusters/$1/hosts"
@ -353,6 +359,9 @@ function add-etcd() {
# check if the new node already exsited
sed -n '/^\[etcd/,/^\[kube_master/p' "$BASE/clusters/$1/hosts"|grep -E "^$2$|^$2 " && { logger error "etcd $2 already existed!"; return 2; }
# add '/usr/bin/python' soft link, needed in some OS (ubuntu 16.04+)
[[ ! -e /usr/bin/python && -e /usr/bin/python3 ]] && ssh "$2" ln -s /usr/bin/python3 /usr/bin/python
logger info "add $2 into 'etcd' group"
ETCD_INFO="${@:2}"
sed -i "/\[etcd/a $ETCD_INFO" "$BASE/clusters/$1/hosts"

View File

@ -42,8 +42,8 @@
template: src=prometheus/values.yaml.j2 dest={{ cluster_dir }}/yml/prom-values.yaml
- name: helm 创建 kube-prometheus-stack {{ prom_chart_ver }}
shell: "{{ base_dir }}/bin/helm install -n {{ prom_namespace }} prometheus \
-f {{ cluster_dir }}/yml/prom-values.yaml \
shell: "{{ base_dir }}/bin/helm upgrade prometheus --install \
-n {{ prom_namespace }} -f {{ cluster_dir }}/yml/prom-values.yaml \
{{ base_dir }}/roles/cluster-addon/files/kube-prometheus-stack-{{ prom_chart_ver }}.tgz"
run_once: true
connection: local