### Deploy 3 server and 3 agent nodes with package Source: https://kubeclipper.io/docs/deployment-docs/ha-deploy Deploys a cluster with 3 server and 3 agent nodes, explicitly defining the installation package. ```bash kcctl deploy --pk-file=~/.ssh/id_rsa \ --server SERVER_IPS \ --agent AGENT_IPS \ --pkg https://oss.kubeclipper.io/release/{KC_VERSION}/kc-{GOARCH}.tar.gz ``` -------------------------------- ### Deploy 3 server and 3 agent nodes without explicit package Source: https://kubeclipper.io/docs/deployment-docs/ha-deploy Deploys a cluster with 3 server and 3 agent nodes, defaulting to the version matching the installed kcctl. ```bash kcctl deploy --pk-file=~/.ssh/id_rsa \ --server SERVER_IPS \ --agent AGENT_IPS ``` -------------------------------- ### Deploy 3 server nodes using private key Source: https://kubeclipper.io/docs/deployment-docs/ha-deploy Deploys a 3-server cluster using an SSH private key and a specified installation package URL. ```bash kcctl deploy --pk-file=~/.ssh/id_rsa \ --server SERVER_IPS \ --pkg https://oss.kubeclipper.io/release/{KC_VERSION}/kc-{GOARCH}.tar.gz ``` -------------------------------- ### 查看集群状态 Source: https://kubeclipper.io/docs/getting-started 使用 kcctl get cluster 命令查看集群的当前状态。 ```bash kcctl get cluster -o yaml|grep status -A5 ``` -------------------------------- ### 重新创建 Kubernetes 集群 Source: https://kubeclipper.io/docs/faq/kcctl-create-cluster-error 在推送离线资源包后,再次尝试创建集群。 ```bash kcctl create cluster --name test --master 192.168.10.98 --untaint-master ``` -------------------------------- ### 创建 Kubernetes 集群 Source: https://kubeclipper.io/docs/getting-started 获取节点 IP 并使用 kcctl create cluster 命令创建名为 demo 的集群。 ```bash NODE=$(kcctl get node -o yaml|grep ipv4DefaultIP:|sed 's/ipv4DefaultIP: //') kcctl create cluster --master $NODE --name demo --untaint-master ``` -------------------------------- ### 创建 Kubernetes 集群 Source: https://kubeclipper.io/docs/faq/kcctl-create-cluster-error 登录并尝试创建 Kubernetes 集群,此操作在 v1.2.1 中会触发 CNI 下载错误。 ```bash # 需要先登录 kcctl login --host http://127.0.0.1 --username admin --password Thinkbig1 # 创建集群 kcctl create cluster --name test --master 192.168.10.98 --untaint-master ``` -------------------------------- ### 查看集群 Pods 状态 Source: https://kubeclipper.io/docs/faq/kcctl-create-cluster-error 检查 Kubernetes 集群中 Pods 的运行状态以确认修复结果。 ```bash kubectl get pods -A ``` -------------------------------- ### 推送组件包脚本 push_component.sh Source: https://kubeclipper.io/docs/getting-started/make-offline-package 该脚本用于下载并打包指定组件(k8s、calico、containerd、docker、metallb)的离线包,并推送到 kubeclipper。支持 amd64 和 arm64 架构。 ```bash #!/usr/bin/env bash # usage: ./push_component.sh [component] [version] [arch] # usage: ./push_component.sh k8s v1.23.9 amd64 set -e if type kcctl &>/dev/null; then kcctl version else echo "kcctl command not found, please install it first!" fi PKG_URL_PREFIX="https://oss.kubeclipper.io/packages" fileList=() name=$1 if [[ "${name}" != "k8s" ]] && [[ "${name}" != "calico" ]] && [[ "${name}" != "containerd" ]] && [[ "${name}" != "docker" ]] && [[ "${name}" != "metallb" ]]; then echo "only 'k8s', 'calico','containerd','docker','metallb' packages are supported. default: $name" exit 1 fi version=$2 if [[ -z "${version}" ]]; then echo "Please specify the package version!" exit 1 fi arch=$3 if [[ "${arch}" != "amd64" ]] && [[ "${arch}" != "arm64" ]]; then echo "only 'amd64', 'arm64' architectures are supported. default: $arch" exit 1 fi `` build_dir=${name}/${version}/${arch} pkg_name=${name}-${version}-${arch}.tar.gz pkg_type="k8s" packaging() { case $name in k8s) fileList=( images.tar.gz configs.tar.gz manifest.json ) pkg_type="k8s" ;; calico) fileList=( images.tar.gz manifest.json ) if [[ "$(echo -e "3.26\n${version}" | sort -V | tail -n 1)" == "${version}" ]]; then fileList=( images.tar.gz charts.tgz manifest.json ) fi pkg_type="cni" ;; containerd|docker) fileList=( configs.tar.gz manifest.json ) pkg_type="cri" ;; metallb) fileList=( images.tar.gz manifest.json ) pkg_type="metallb" ;; esac for file in "${fileList[@]}"; do echo "download ${file}..." wget ${PKG_URL_PREFIX}/${build_dir}/${file} -P ${build_dir} done echo "packaging ${pkg_name}..." tar -zcvf ${pkg_name} ${build_dir} echo "packaging ${pkg_name} done" echo "push ${pkg_name} to kc..." kcctl resource push --pkg ${pkg_name} --type ${pkg_type} echo "push ${pkg_name} to kc done" } packaging echo "clean up..." rm -rf ${build_dir} rm -rf ${pkg_name} echo "clean up done" ``` -------------------------------- ### 使用 push_component.sh 推送组件包 Source: https://kubeclipper.io/docs/getting-started/make-offline-package 示例命令展示如何使用 push_component.sh 推送 k8s、calico、containerd、docker 和 metallb 组件包到 kubeclipper。 ```bash chmod +x push_component.sh # 推送 k8s 组件包 ./push_component.sh k8s v1.33.0 amd64 # 推送 calico 组件包 ./push_component.sh calico v3.26.1 amd64 # 推送 containerd 组件包 ./push_component.sh containerd 1.6.4 amd64 # 推送 docker 组件包 ./push_component.sh docker 20.10.20 amd64 # 推送 metallb 组件包 ./push_component.sh metallb v0.13.7 amd64 ``` -------------------------------- ### Set KC_IMAGE_REPO_MIRROR via kc.env File Source: https://kubeclipper.io/docs/tutorials/create-clusters Alternative method to configure the image proxy by creating a configuration file at /etc/kc/kc.env. ```bash # 创建 kc 目录 mkdir -pv /etc/kc # 创建 kc.env 文件并传入环境变量信息 cat < /etc/kc/kc.env KC_IMAGE_REPO_MIRROR="registry.aliyuncs.com/google_containers" EOF ``` -------------------------------- ### 部署 KubeClipper AIO 环境 Source: https://kubeclipper.io/docs/faq/kcctl-create-cluster-error 使用 kcctl deploy 命令部署 AIO 环境。 ```bash # 安装 AIO 环境 kcctl deploy ``` -------------------------------- ### kcctl deploy 命令语法 Source: https://kubeclipper.io/docs/getting-started/aio-env 部署 KubeClipper 时使用的命令语法,需要提供 SSH 访问凭证。 ```bash Kcctl deploy [--user ] [--passwd | --pk-file ] ``` -------------------------------- ### 推送离线资源包 Source: https://kubeclipper.io/docs/faq/kcctl-create-cluster-error 将制作好的离线资源包推送到 KubeClipper 并验证。 ```bash # 推送 kcctl resource push --pkg calico-v3.21.2-amd64.tar.gz --type cni # 验证 kcctl resource list|grep v3.21.2 ``` -------------------------------- ### 查看离线组件包 Source: https://kubeclipper.io/docs/getting-started/make-offline-package 使用 kcctl resource list 命令查看已上传的离线组件包。 ```bash kcctl resource list ``` -------------------------------- ### 使用 kcctl join 添加 agent 节点 Source: https://kubeclipper.io/docs/tutorials/node-management 使用 kcctl join 命令为 KubeClipper 添加 agent 节点,并可为节点指定区域。未指定区域的节点将默认归入 default 区域。 ```bash kcctl join --agent beijing:1.2.3.4 --agent shanghai:2.3.4.5 ``` -------------------------------- ### 配置 OIDC 身份提供商 Source: https://kubeclipper.io/docs/tutorials/access-control 在 /etc/kubeclipper-server/kubeclipepr-server.yaml 文件中的 authentication 下配置 oauthOptions 以启用 OIDC 外部用户登录。 ```yaml oauthOptions: identityProviders: - name: keycloak type: OIDC mappingMethod: auto provider: clientID: kc clientSecret: EErn729BB1bKawdRtnZgrqj9Bx0]mzUs issuer: http://172.20.163.233:7777/auth/realms/kubeclipper scopes: - openid - email redirectURL: http://{kc-console-address}/oatuh2/redirect/{IDP-Name} ``` -------------------------------- ### kcctl deploy 示例 Source: https://kubeclipper.io/docs/getting-started/aio-env 使用私钥或密码进行 KubeClipper 部署的示例。 ```bash # 使用私钥 kcctl deploy --user root --pk-file /root/.ssh/id_rsa # 使用密码 kcctl deploy --user root --passwd password ``` -------------------------------- ### 挂载 NFS 存储目录 Source: https://kubeclipper.io/docs/tutorials/cluster-management 在每个 master 节点上执行此命令,将 NFS 服务器的共享目录挂载到本地路径,以便作为集群备份空间使用。 ```bash mount -t nfs { NFS_IP }:/data/kubeclipper/cluster-backups /opt/kubeclipper/cluster-backups -o proto=tcp -o nolock ``` -------------------------------- ### 登录 KubeClipper Source: https://kubeclipper.io/docs/getting-started 使用默认账号 admin 和密码 Thinkbig1 登录以获取 token,用于后续与 kc-server 交互。 ```bash kcctl login -H http://localhost -u admin -p Thinkbig1 ``` -------------------------------- ### 部署 KubeClipper Source: https://kubeclipper.io/docs/getting-started 使用 kcctl deploy 命令进行安装。支持使用 SSH 密码或私钥进行身份验证。 ```bash kcctl deploy ``` ```bash kcctl deploy --user root --passwd $SSH_PASSWD ``` ```bash kcctl deploy --user root --pk-file $SSH_PRIVATE_KEY ``` -------------------------------- ### Login to KubeClipper via CLI Source: https://kubeclipper.io/docs/deployment-docs/ha-deploy Authenticates the CLI session with the KubeClipper server using the default admin credentials. ```bash kcctl login -H http://SERVER_IP -u admin -p Thinkbig1 ``` -------------------------------- ### Deploy with custom etcd ports Source: https://kubeclipper.io/docs/deployment-docs/ha-deploy Deploys a cluster while explicitly configuring etcd client, peer, and metric ports. ```bash kcctl deploy --pk-file=~/.ssh/id_rsa \ --server SERVER_IPS \ --agent AGENT_IPS \ --etcd-port 12379 --etcd-peer-port 12380 --etcd-metric-port 12381 ```