使用脚本安装 K8s 和 KubeCube(已废弃)
- 1: 在已有k8s集群中部署KubeCube
- 2: 添加计算集群
- 3: 添加节点
- 4: 多节点高可用部署
1 - 在已有k8s集群中部署KubeCube
v1.4.x
在 Kubernetes 集群中部署 KubeCube
开始安装
在 Linux 机器上执行部署脚本
KUBECUBE_VERSION=v1.4
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install k8s
INSTALL_KUBERNETES="false"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="docker"
等待部署完成
KubeCube 部署完成后,请根据提示信息登陆 console 管理页面
使用 admin 账户登陆 console
⚠️请在登陆后修改 admin 用户的密码
v1.2.x
在 Kubernetes 集群中部署 KubeCube
开始安装
在 Linux 机器上执行部署脚本
KUBECUBE_VERSION=v1.2
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install k8s
INSTALL_KUBERNETES="false"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
等待部署完成
KubeCube 部署完成后,请根据提示信息登陆 console 管理页面
使用 admin 账户登陆 console
⚠️请在登陆后修改 admin 用户的密码
v1.1.x
在 Kubernetes 集群中部署 KubeCube
开始安装
在 Linux 机器上执行部署脚本
KUBECUBE_VERSION=v1.1
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
INSTALL_KUBECUBE_MEMBER=“false”
MASTER_IP="${node ip}"
${node ip} 表示你运行脚本所在 node 机器的 ip,该 node 需要可操作 kubectl
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install k8s
INSTALL_KUBERNETES="false"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
等待部署完成
KubeCube 部署完成后,请根据提示信息登陆 console 管理页面
使用 admin 账户登陆 console
⚠️请在登陆后修改 admin 用户的密码
v1.0.x
在 Kubernetes 集群中部署 KubeCube
⚠️修改 Kubernetes API-Server 配置
必要性
KubeCube 对多集群提供统一的认证和鉴权服务,需要使用 k8s api-server 的 auth-webhook 能力来做拓展。
KubeCube 提供对 k8s-apiserver 日志进行审计的能力,这需要为 k8s api-server 指定审计服务后端。
修改操作
如果您的 k8s api-server 服务是以 deployment 形式运行的,请直接修改 deployment ;如果您的 k8s api-server 服务是以 static pod 形式运行的,您需要修改对应的 manifest 文件,它的文件路径通常为 /etc/kubernetes/manifests/kube-apiserver.yaml
,修改内容如下:
apiVersion: v1
kind: Pod
metadata:
name: kube-apiserver
namespace: kube-system
spec:
containers:
- command:
- kube-apiserver
- --audit-log-format=json
- --audit-log-maxage=10
- --audit-log-maxbackup=10
- --audit-log-maxsize=100
- --audit-log-path=/var/log/audit
- --audit-policy-file=/etc/cube/audit/audit-policy.yaml
- --audit-webhook-config-file=/etc/cube/audit/audit-webhook.config
- --authentication-token-webhook-config-file=/etc/cube/warden/webhook.config
name: kube-apiserver
volumeMounts:
- mountPath: /var/log/audit
name: audit-log
- mountPath: /etc/cube
name: cube
readOnly: true
volumes:
- hostPath:
path: /var/log/audit
type: DirectoryOrCreate
name: audit-log
- hostPath:
path: /etc/cube
type: DirectoryOrCreate
name: cube
开始安装
在 Linux 机器上执行部署脚本
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
INSTALL_KUBECUBE_MEMBER=“false”
MASTER_IP="${node ip}"
${node ip} 表示你运行脚本所在 node 机器的 ip,该 node 需要可操作 kubectl
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# if install k8s
INSTALL_KUBERNETES="false"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="x.x.x.x"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
等待部署完成
KubeCube 部署完成后,请根据提示信息登陆 console 管理页面
使用 admin 账户登陆 console
⚠️请在登陆后修改 admin 用户的密码
2 - 添加计算集群
KubeCube 可以添加其它集群作为计算集群,前提是,计算集群能够访问管控集群的 k8s api-server 和 KubeCube,默认情况下 KubeCube 使用 NodePort 对外暴露服务,用户可自行使用 ingress 进行暴露
v1.4.x
方式一:部署新集群并添加
在 linux 机器上,需要构建 Kubernetes 集群并安装 KubeCube 依赖项
开始安装
KUBECUBE_VERSION=v1.4
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
INSTALL_KUBECUBE_PIVOT=“false”
INSTALL_KUBECUBE_MEMBER=“true”
INSTALL_KUBERNETES=“true”
MEMBER_CLUSTER_NAME=“member-1”
MASTER_IP="${node ip}"
KUBECUBE_HOST="${pivot node ip}"
MEMBER_CLUSTER_NAME 表示计算集群的名字,注意,不能与已有的计算集群名称同名, ${node ip} 表示你运行脚本所在 node 机器的 ip,该 node 需要可操作 kubectl, ${pivot node ip} 表示管控集群 node 机器的 ip,用于向 KubeCube 注册集群
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="true"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST="y.y.y.y"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME="member-1"
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="docker"
方式二:纳管已有集群
添加已有集群只需从 console 页面导入集群信息即可
在 console 页面中导入集群信息
在 console 中确认新集群
v1.2.x
方式一:部署新集群并添加
在 linux 机器上,需要构建 Kubernetes 集群并安装 KubeCube 依赖项
开始安装
KUBECUBE_VERSION=v1.2
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
INSTALL_KUBECUBE_PIVOT=“false”
INSTALL_KUBECUBE_MEMBER=“true”
INSTALL_KUBERNETES=“true”
MEMBER_CLUSTER_NAME=“member-1”
MASTER_IP="${node ip}"
KUBECUBE_HOST="${pivot node ip}"
MEMBER_CLUSTER_NAME 表示计算集群的名字,注意,不能与已有的计算集群名称同名, ${node ip} 表示你运行脚本所在 node 机器的 ip,该 node 需要可操作 kubectl, ${pivot node ip} 表示管控集群 node 机器的 ip,用于向 KubeCube 注册集群
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="true"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST="y.y.y.y"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME="member-1"
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
方式二:纳管已有集群
添加已有集群只需从 console 页面导入集群信息即可
在 console 页面中导入集群信息
在 console 中确认新集群
v1.1.x
方式一:部署新集群并添加
在 linux 机器上,需要构建 Kubernetes 集群并安装 KubeCube 依赖项
开始安装
KUBECUBE_VERSION=v1.1
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
INSTALL_KUBECUBE_PIVOT=“false”
INSTALL_KUBECUBE_MEMBER=“true”
INSTALL_KUBERNETES=“true”
MEMBER_CLUSTER_NAME=“member-1”
MASTER_IP="${node ip}"
KUBECUBE_HOST="${pivot node ip}"
MEMBER_CLUSTER_NAME 表示计算集群的名字,注意,不能与已有的计算集群名称同名, ${node ip} 表示你运行脚本所在 node 机器的 ip,该 node 需要可操作 kubectl, ${pivot node ip} 表示管控集群 node 机器的 ip,用于向 KubeCube 注册集群
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="true"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST="y.y.y.y"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME="member-1"
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
方式二:纳管已有集群
添加已有集群只需从 console 页面导入集群信息即可
在 console 页面中导入集群信息
在 console 中确认新集群
v1.0.x
方式一:部署新集群并添加
在 linux 机器上,需要构建 Kubernetes 集群并安装 KubeCube 依赖项
开始安装
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置安装脚本参数
该安装模式下,需要修改以下参数:
INSTALL_KUBECUBE_PIVOT=“false”
INSTALL_KUBECUBE_MEMBER=“true”
INSTALL_KUBERNETES=“true”
MEMBER_CLUSTER_NAME=“member-1”
MASTER_IP="${node ip}"
KUBECUBE_HOST="${pivot node ip}"
MEMBER_CLUSTER_NAME 表示计算集群的名字,注意,不能与已有的计算集群名称同名 ${node ip} 表示你运行脚本所在 node 机器的 ip,该 node 需要可操作 kubectl ${pivot node ip} 表示管控集群 node 机器的 ip,用于向 KubeCube 注册集群
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="true"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME="member-1"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="x.x.x.x"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST="y.y.y.y"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
方式二:纳管已有集群
添加已有集群需要从 console 页面获取添加集群的定制脚本
在 console 页面中获取添加集群的脚本
使用脚本添加集群
在集群的 node 机器上,使用从 console 中下载的脚本,该机器需要能够执行 kubectl
/bin/bash add_cluster.sh
等待集群添加完成
在 console 中确认新集群
3 - 添加节点
KubeCube 提供为已有集群添加节点的能力,同时也支持使用 kubeadm 的原生方式添加节点
⚠️ 注意通过 KubeCube 的脚本添加节点时,node 机器需要能够通过 ssh 访问 master 机器,支持公钥和密码两种 ssh 方式,执行脚本前可以在 node 上 ssh 到 master 测试连通性
v1.4.x
向集群添加工作节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.4
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入集群
- MASTER_IP 为 master 节点 ip
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="docker"
向集群的 control-plane 添加 master 节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.4
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入 control-plane
- MASTER_IP 需要填已有的 master 节点 ip
- NODE_MODE 当该模式为 node-join-control-plane 时,需要指定 master 节点们的 CONTROL_PLANE_ENDPOINT(vip)
- CONTROL_PLANE_ENDPOINT 为高可用 vip
- 可以根据需要选择适合自己的 ssh 方式
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP="y.y.y.y"
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
v1.2.x
向集群添加工作节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.2
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入集群
- MASTER_IP 为 master 节点 ip
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
向集群的 control-plane 添加 master 节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.2
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入 control-plane
- MASTER_IP 需要填已有的 master 节点 ip
- NODE_MODE 当该模式为 node-join-control-plane 时,需要指定 master 节点们的 CONTROL_PLANE_ENDPOINT(vip)
- CONTROL_PLANE_ENDPOINT 为高可用 vip
- 可以根据需要选择适合自己的 ssh 方式
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP="y.y.y.y"
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
v1.1.x
向集群添加工作节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.1
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
tip: 你可以通过预先下载离线包和镜像来减少部署时间
export PRE_DOWNLOAD="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入集群
- MASTER_IP 为 master 节点 ip
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP="y.y.y.y"
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
向集群的 control-plane 添加 master 节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.1
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入 control-plane
- MASTER_IP 需要填已有的 master 节点 ip
- NODE_MODE 当该模式为 node-join-control-plane 时,需要指定 master 节点们的 CONTROL_PLANE_ENDPOINT(vip)
- CONTROL_PLANE_ENDPOINT 为高可用 vip
- 可以根据需要选择适合自己的 ssh 方式
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP="y.y.y.y"
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
v1.0.x
向集群添加工作节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
tip: 你可以通过预先下载离线包和镜像来减少部署时间
export PRE_DOWNLOAD="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入集群
- MASTER_IP 为 master 节点 ip
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
向集群的 control-plane 添加 master 节点
在新节点上执行部署脚本
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待新节点加入 control-plane
- MASTER_IP 需要填已有的 master 节点 ip
- CONTROL_PLANE_ENDPOINT 为高可用 vip
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-control-plane"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="10.173.32.10" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
4 - 多节点高可用部署
本文提供 Kubernetes 的高可用部署和 KubeCube 的高可用部署方案,VIP 的实现需要用户自行提供
v1.4.x
主机规划
IP 地址 | 主机名 | 角色 |
---|---|---|
10.173.32.2 | lb1 | Keepalived & HAproxy |
10.173.32.3 | lb2 | Keepalived & HAproxy |
10.173.32.4 | master1 | master, etcd |
10.173.32.5 | master2 | master, etcd |
10.173.32.6 | master3 | master, etcd |
10.173.32.7 | worker1 | worker |
10.173.32.8 | worker2 | worker |
10.173.32.9 | worker3 | worker |
10.173.32.10 | vip 地址 |
⚠️master2、master3、worker1、worker2、worker3 需要能够通过密钥或者密码 ssh 访问 master1
部署高可用 Kubernetes
KubeCube 部署脚本提供部署高可用 k8s 的能力,当然,你也可以使用其他工具搭建高可用的 k8s 集群
开始安装
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.4
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 Kubernetes 安装完成,master2 和 master3 加入 control-plane 的方式与之相同
- CONTROL_PLANE_ENDPOINT 为高可用 k8s-apiserver 的 vip,在此我们用任意 master 节点的 ip 代替
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="control-plane-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="10.173.32.4" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
worker1 作为工作节点加入集群
在 worker1 上执行部署脚本
KUBECUBE_VERSION=v1.4
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 worker1 加入集群,worker2 和 worker3 加入集群的方式与之相同
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="docker"
部署高可用 KubeCube
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.4
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 KubeCube 部署完成
- install.conf
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install k8s
INSTALL_KUBERNETES="false"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="docker"
v1.2.x
主机规划
IP 地址 | 主机名 | 角色 |
---|---|---|
10.173.32.2 | lb1 | Keepalived & HAproxy |
10.173.32.3 | lb2 | Keepalived & HAproxy |
10.173.32.4 | master1 | master, etcd |
10.173.32.5 | master2 | master, etcd |
10.173.32.6 | master3 | master, etcd |
10.173.32.7 | worker1 | worker |
10.173.32.8 | worker2 | worker |
10.173.32.9 | worker3 | worker |
10.173.32.10 | vip 地址 |
⚠️master2、master3、worker1、worker2、worker3 需要能够通过密钥或者密码 ssh 访问 master1
部署高可用 Kubernetes
KubeCube 部署脚本提供部署高可用 k8s 的能力,当然,你也可以使用其他工具搭建高可用的 k8s 集群
开始安装
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.2
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 Kubernetes 安装完成,master2 和 master3 加入 control-plane 的方式与之相同
- CONTROL_PLANE_ENDPOINT 为高可用 k8s-apiserver 的 vip,在此我们用任意 master 节点的 ip 代替
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="control-plane-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="10.173.32.4" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
worker1 作为工作节点加入集群
在 worker1 上执行部署脚本
KUBECUBE_VERSION=v1.2
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 worker1 加入集群,worker2 和 worker3 加入集群的方式与之相同
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
部署高可用 KubeCube
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.2
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 KubeCube 部署完成
- install.conf
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install k8s
INSTALL_KUBERNETES="false"
# k8s cni, support now is calico only
CNI="calico"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.19.13, 1.20.9, 1.21.2, 1.22.2, 1.23.5
KUBERNETES_VERSION="1.23.5"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# +optional
# KUBERNETES_BIND_ADDRESS generally is node_ip
# can be set when NODE_MODE="master" ot "control-plane-master"
# default value is $(hostname -I |awk '{print $1}')
KUBERNETES_BIND_ADDRESS="" #{node_ip}
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
#######################################################################
# container runtime config
# if value is docker, then use docker as container runtime
# else if value is containerd, then use containerd as container runtime
#######################################################################
CONTAINER_RUNTIME="containerd"
v1.1.x
主机规划
IP 地址 | 主机名 | 角色 |
---|---|---|
10.173.32.2 | lb1 | Keepalived & HAproxy |
10.173.32.3 | lb2 | Keepalived & HAproxy |
10.173.32.4 | master1 | master, etcd |
10.173.32.5 | master2 | master, etcd |
10.173.32.6 | master3 | master, etcd |
10.173.32.7 | worker1 | worker |
10.173.32.8 | worker2 | worker |
10.173.32.9 | worker3 | worker |
10.173.32.10 | vip 地址 |
⚠️master2、master3、worker1、worker2、worker3 需要能够通过密钥或者密码 ssh 访问 master1
部署高可用 Kubernetes
KubeCube 部署脚本提供部署高可用 k8s 的能力,当然,你也可以使用其他工具搭建高可用的 k8s 集群
开始安装
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.1
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 Kubernetes 安装完成,master2 和 master3 加入 control-plane 的方式与之相同
- CONTROL_PLANE_ENDPOINT 为高可用 k8s-apiserver 的 vip,在此我们用任意 master 节点的 ip 代替
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="control-plane-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="10.173.32.4" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP=""
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
worker1 作为工作节点加入集群
在 worker1 上执行部署脚本
KUBECUBE_VERSION=v1.1
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 worker1 加入集群,worker2 和 worker3 加入集群的方式与之相同
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
部署高可用 KubeCube
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.1
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 KubeCube 部署完成
- install.conf
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install k8s
INSTALL_KUBERNETES="false"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="control-plane-master"
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
# support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
KUBERNETES_VERSION="1.20.9"
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
#######################################################################
# member cluster config
# used when INSTALL_KUBECUBE_MEMBER="true"
#######################################################################
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
#######################################################################
# ssh config
# used when NODE_MODE="node-join-master" or node-join-control-plane
#######################################################################
# +optional
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# the user who can access master node, it can be empty
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
#######################################################################
# offline config
# used when offline install choose, must lift offline pkg first
#######################################################################
OFFLINE_INSTALL="false"
OFFLINE_PKG_PATH=""
- cube.conf
将kubecube_replicas
设置为3,使得 KubeCube 使用 3 副本部署,并且由于podAntiAffinity
# custom values for kubecube
kubecube_replicas=3
kubecube_args_logLevel="info"
v1.0.x
主机规划
IP 地址 | 主机名 | 角色 |
---|---|---|
10.173.32.2 | lb1 | Keepalived & HAproxy |
10.173.32.3 | lb2 | Keepalived & HAproxy |
10.173.32.4 | master1 | master, etcd |
10.173.32.5 | master2 | master, etcd |
10.173.32.6 | master3 | master, etcd |
10.173.32.7 | worker1 | worker |
10.173.32.8 | worker2 | worker |
10.173.32.9 | worker3 | worker |
10.173.32.10 | vip 地址 |
⚠️master2、master3、worker1、worker2、worker3 需要能够通过密钥或者密码 ssh 访问 master1
部署高可用 Kubernetes
开始安装
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 Kubernetes 安装完成
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="control-plane-master"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="10.173.32.10" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
master2 节点加入 control-plane
在 master2 上执行部署脚本
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 master2 加入 control-plane
master3 加入 control-plane 与此类似,仅需修改
LOCAL_IP
为10.173.32.6
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-control-plane"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="10.173.32.10" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
worker1 作为工作节点加入集群
在 worker1 上执行部署脚本
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 worker1 加入集群
worker2 和 worker3 加入集群的方式与之类似,仅需修改
LOCAL_IP
为本机 IP 即可
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="false"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# if install k8s
INSTALL_KUBERNETES="true"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="node-join-master"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
部署高可用 KubeCube
在 master1 上执行部署脚本
KUBECUBE_VERSION=v1.0
export CUSTOMIZE="true";curl -fsSL https://kubecube.nos-eastchina1.126.net/kubecube-installer/${KUBECUBE_VERSION}/entry.sh | bash
设置脚本参数,并按照提示继续运行安装脚本并等待 KubeCube 部署完成
- install.conf
# if install kubecube on pivot cluster
INSTALL_KUBECUBE_PIVOT="true"
# if install kubecube on member cluster
INSTALL_KUBECUBE_MEMBER="false"
# if install k8s
INSTALL_KUBERNETES="false"
# there are four node mode below:
# "master" : node will be installed as a master of cluster
# "node-join-master" : node will be install as a worker of cluster to join master
# "control-plane-master" : node will be installed as a master to control plane of cluster
# "node-join-control-plane" : node will be installed as a master to join control plane
NODE_MODE="control-plane-master"
# +optional
# must be set when INSTALL_KUBECUBE_MEMBER="true"
# this value is the name of member cluster you
# want to take over
MEMBER_CLUSTER_NAME=""
# +optional
# must be set when NODE_MODE="control-plane-master"
# or "node-join-control-plane"
CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
# master ip means master node ip of cluster
MASTER_IP="10.173.32.4"
# +optional
# KUBECUBE_HOST must be set when as a member cluster to
# join pivot cluster, the value is pivot node ip
KUBECUBE_HOST=""
# zone has two choice
# 1. "cn" : in mainland
# 2. "others" : out of mainland
ZONE="cn"
# k8s version you want to install
KUBERNETES_VERSION="1.20.9"
# +optional
# the user who can access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_USER="root"
# +optional
# the port specified to access master node, it can be empty
# when NODE_MODE="master" or "control-plane-master"
SSH_PORT=22
# +optional
# must be empty when ACCESS_PRIVATE_KEY_PATH set
# password for master user to access master node
ACCESS_PASSWORD=""
# +optional
# must be empty when ACCESS_PASSWORD set
# ACCESS_PRIVATE_KEY for master user to access master node
ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
- cube.conf
将kubecube_replicas
设置为3,使得 KubeCube 使用 3 副本部署,并且由于podAntiAffinity
,它们会运行在非controlPlane
的节点上,并且每个节点仅运行单个副本
# custom values for kubecube
kubecube_replicas=3
kubecube_args_logLevel="info"