基本信息
!!! warning “”
- 支持导入非 KubeOperator 创建的集群- 导入非 KubeOperator 创建的集群不支持扩缩容、升级、备份等 Day2 操作

!!! warning “获取架构” 选择集群节点的 CPU 架构类型(支持 amd64、arm64 和混合架构三种类型)
!!! warning “获取 Api Server”
```shellcat ~/.kube/config | grep server: | awk '{print $2}'```注意:如果 server IP 为 127.0.0.1,需要将 IP 替换为任意 master 节点 IP
!!! warning “获取 Router” 装有 kube-proxy 的任意 K8s 集群节点的 IP 地址
```shellkubectl -n kube-system get pod -o wide | grep kube-proxy```注意:获取任意节点的 IP 地址
!!! warning “获取 Token”
=== "KubeOperator 创建集群"```shellkubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep ko-admin | awk '{print $1}') | grep token: | awk '{print $2}'```=== "自建集群"!!! warning ""创建 Service Account```yamlapiVersion: v1kind: ServiceAccountmetadata:name: kubeoperator-usernamespace: kube-system```!!! warning ""创建 ClusterRoleBinding```yamlapiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:name: kubeoperator-userroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: cluster-adminsubjects:- kind: ServiceAccountname: kubeoperator-usernamespace: kube-system```!!! warning ""获取 Token```shellkubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep kubeoperator-user | awk '{print $1}') | grep token: | awk '{print $2}'```
非 KubeOperator 创建集群
使用工具
!!! warning “仓库配置”
- 工具中涉及到的镜像来源于 nexus 镜像仓库。在启用工具之前,需要在所有 K8s 集群节点上对 nexus 镜像仓库进行 http 授信。```shellvim /etc/docker/daemon.json``````json{..."insecure-registries" : [ "...", "kubeoperator-ip:8082", "..." ]...}注意:kubeoperator-ip 为 KubeOperator 部署机 IP``````shell# 重新启动 docker 服务使得配置生效systemctl restart docker.service```
KubeOperator 创建集群
获取容器运行时参数
!!! warning “Docker”
```shell# 集群任意节点执行cat /etc/docker/daemon.json``````json{..."bip": "172.17.0.1/16", # Container 子网"data-root": "/var/lib/docker", # Docker 数据路径...}```
!!! warning “Containerd”
```shell# 集群任意节点执行cat /etc/containerd/config.toml``````yaml...root = "/var/lib/containerd" # Containerd 数据路径...```
获取容器网络参数
!!! warning “”
=== "flannel"!!! warning "网络模式"```shell# 集群任意节点执行kubectl -n kube-system get cm kube-flannel-cfg -o yaml``````json{...net-conf.json: |{"Network": "10.0.0.0/14","Backend": {"Type": "vxlan" # 网络模式为 vxlan}}...}```!!! warning "多网络设置"```shell# 集群任意节点执行kubectl -n kube-system get daemonsets.apps kube-flannel-ds -o yaml``````yaml...containers:- args:- --ip-masq- --kube-subnet-mgr- --iface=ens192 # 多网络设置为启用,网卡名称为 ens192...```=== "calico"!!! warning "网络模式"```shell# 集群任意节点执行kubectl -n kube-system get cm calico-config -o yaml``````yaml...containers:- env:- name: CALICO_IPV4POOL_IPIPvalue: "off" # off 代表网络模式为 bgp,Always 代表网络模式为 ipip...```!!! warning "多网络设置"```shell# 集群任意节点执行kubectl -n kube-system get daemonsets.apps calico-node -o yaml``````yaml...containers:- env:- name: DATASTORE_TYPEvalue: kubernetes- name: IP_AUTODETECTION_METHODvalue: interface=ens192 # 多网络设置为网卡,网卡名称为 ens192value: cidr=192.168.64.0/24 # 多网络设置为网段,网段为 192.168.64.0/24...```
