在已有k8s集群中部署KubeCube

v1.1.x

在 Kubernetes 集群中部署 KubeCube

开始安装

在 Linux 机器上执行部署脚本

  1. KUBECUBE_VERSION=v1.1
  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

  1. # if install kubecube on pivot cluster
  2. INSTALL_KUBECUBE_PIVOT="true"
  3. # if install k8s
  4. INSTALL_KUBERNETES="false"
  5. # there are four node mode below:
  6. # "master" : node will be installed as a master of cluster
  7. # "node-join-master" : node will be install as a worker of cluster to join master
  8. # "control-plane-master" : node will be installed as a master to control plane of cluster
  9. # "node-join-control-plane" : node will be installed as a master to join control plane
  10. NODE_MODE="master"
  11. # zone has two choice
  12. # 1. "cn" : in mainland
  13. # 2. "others" : out of mainland
  14. ZONE="cn"
  15. # k8s version you want to install
  16. # support now is: 1.20.9, 1.19.13, 1.18.20, 1.21.2
  17. KUBERNETES_VERSION="1.20.9"
  18. # +optional
  19. # must be set when NODE_MODE="control-plane-master"
  20. # or "node-join-control-plane"
  21. CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
  22. #######################################################################
  23. # member cluster config
  24. # used when INSTALL_KUBECUBE_MEMBER="true"
  25. #######################################################################
  26. # if install kubecube on member cluster
  27. INSTALL_KUBECUBE_MEMBER="false"
  28. # +optional
  29. # KUBECUBE_HOST must be set when as a member cluster to
  30. # join pivot cluster, the value is pivot node ip
  31. KUBECUBE_HOST=""
  32. # +optional
  33. # must be set when INSTALL_KUBECUBE_MEMBER="true"
  34. # this value is the name of member cluster you
  35. # want to take over
  36. MEMBER_CLUSTER_NAME=""
  37. #######################################################################
  38. # ssh config
  39. # used when NODE_MODE="node-join-master" or node-join-control-plane
  40. #######################################################################
  41. # +optional
  42. # master ip means master node ip of cluster
  43. MASTER_IP=""
  44. # +optional
  45. # the user who can access master node, it can be empty
  46. SSH_USER="root"
  47. # +optional
  48. # the port specified to access master node, it can be empty
  49. SSH_PORT=22
  50. # +optional
  51. # must be empty when ACCESS_PRIVATE_KEY_PATH set
  52. # password for master user to access master node
  53. ACCESS_PASSWORD=""
  54. # +optional
  55. # must be empty when ACCESS_PASSWORD set
  56. # ACCESS_PRIVATE_KEY for master user to access master node
  57. ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"
  58. #######################################################################
  59. # offline config
  60. # used when offline install choose, must lift offline pkg first
  61. #######################################################################
  62. OFFLINE_INSTALL="false"
  63. OFFLINE_PKG_PATH=""

等待部署完成

KubeCube 部署完成后,请根据提示信息登陆 console 管理页面

complete-deploy

使用 admin 账户登陆 console

⚠️请在登陆后修改 admin 用户的密码

login-console

v1.0.x

在 Kubernetes 集群中部署 KubeCube

⚠️修改 Kubernetes API-Server 配置

必要性

  1. KubeCube 对多集群提供统一的认证和鉴权服务,需要使用 k8s api-server 的 auth-webhook 能力来做拓展。

  2. KubeCube 提供对 k8s-apiserver 日志进行审计的能力,这需要为 k8s api-server 指定审计服务后端。

修改操作

如果您的 k8s api-server 服务是以 deployment 形式运行的,请直接修改 deployment ;如果您的 k8s api-server 服务是以 static pod 形式运行的,您需要修改对应的 manifest 文件,它的文件路径通常为 /etc/kubernetes/manifests/kube-apiserver.yaml ,修改内容如下:

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: kube-apiserver
  5. namespace: kube-system
  6. spec:
  7. containers:
  8. - command:
  9. - kube-apiserver
  10. - --audit-log-format=json
  11. - --audit-log-maxage=10
  12. - --audit-log-maxbackup=10
  13. - --audit-log-maxsize=100
  14. - --audit-log-path=/var/log/audit
  15. - --audit-policy-file=/etc/cube/audit/audit-policy.yaml
  16. - --audit-webhook-config-file=/etc/cube/audit/audit-webhook.config
  17. - --authentication-token-webhook-config-file=/etc/cube/warden/webhook.config
  18. name: kube-apiserver
  19. volumeMounts:
  20. - mountPath: /var/log/audit
  21. name: audit-log
  22. - mountPath: /etc/cube
  23. name: cube
  24. readOnly: true
  25. volumes:
  26. - hostPath:
  27. path: /var/log/audit
  28. type: DirectoryOrCreate
  29. name: audit-log
  30. - hostPath:
  31. path: /etc/cube
  32. type: DirectoryOrCreate
  33. name: cube

开始安装

在 Linux 机器上执行部署脚本

  1. KUBECUBE_VERSION=v1.0
  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

  1. # if install kubecube on pivot cluster
  2. INSTALL_KUBECUBE_PIVOT="true"
  3. # if install kubecube on member cluster
  4. INSTALL_KUBECUBE_MEMBER="false"
  5. # if install k8s
  6. INSTALL_KUBERNETES="false"
  7. # there are four node mode below:
  8. # "master" : node will be installed as a master of cluster
  9. # "node-join-master" : node will be install as a worker of cluster to join master
  10. # "control-plane-master" : node will be installed as a master to control plane of cluster
  11. # "node-join-control-plane" : node will be installed as a master to join control plane
  12. NODE_MODE="master"
  13. # +optional
  14. # must be set when INSTALL_KUBECUBE_MEMBER="true"
  15. # this value is the name of member cluster you
  16. # want to take over
  17. MEMBER_CLUSTER_NAME=""
  18. # +optional
  19. # must be set when NODE_MODE="control-plane-master"
  20. # or "node-join-control-plane"
  21. CONTROL_PLANE_ENDPOINT="" #{ip}:{port} , dns
  22. # master ip means master node ip of cluster
  23. MASTER_IP="x.x.x.x"
  24. # +optional
  25. # KUBECUBE_HOST must be set when as a member cluster to
  26. # join pivot cluster, the value is pivot node ip
  27. KUBECUBE_HOST=""
  28. # zone has two choice
  29. # 1. "cn" : in mainland
  30. # 2. "others" : out of mainland
  31. ZONE="cn"
  32. # k8s version you want to install
  33. KUBERNETES_VERSION="1.20.9"
  34. # +optional
  35. # the user who can access master node, it can be empty
  36. # when NODE_MODE="master" or "control-plane-master"
  37. SSH_USER="root"
  38. # +optional
  39. # the port specified to access master node, it can be empty
  40. # when NODE_MODE="master" or "control-plane-master"
  41. SSH_PORT=22
  42. # +optional
  43. # must be empty when ACCESS_PRIVATE_KEY_PATH set
  44. # password for master user to access master node
  45. ACCESS_PASSWORD=""
  46. # +optional
  47. # must be empty when ACCESS_PASSWORD set
  48. # ACCESS_PRIVATE_KEY for master user to access master node
  49. ACCESS_PRIVATE_KEY_PATH="/root/.ssh/id_rsa"

等待部署完成

KubeCube 部署完成后,请根据提示信息登陆 console 管理页面

complete-deploy

使用 admin 账户登陆 console

⚠️请在登陆后修改 admin 用户的密码

login-console

最后修改 December 20, 2021 : release-v1.1.0:install-guide (5f0c959c)