安装Kubernetes

详情参考:https://www.kubesphere.io/zh/docs/v4.1/03-installation-and-upgrade/02-install-kubesphere/02-install-kubernetes-and-kubesphere/

  • 安装依赖项
    
    - 下载kubekey   
    
        ```shell
            export KKZONE=cn
            curl -sfL https://get-kk.kubesphere.io | sh -
            sudo chmod +x kk
            
        ```
    
    - 创建集群   
        配置文件参考:https://github.com/kubesphere/kubekey/blob/master/docs/config-example.md
        ```yaml
                
            apiVersion: kubekey.kubesphere.io/v1alpha2
            kind: Cluster
            metadata:
              name: sample
            spec:
              hosts:
              - {name: node1, address: 192.168.6.74, internalAddress: 192.168.6.74, user: root, password: "Redsun888@"}
              - {name: node2, address: 192.168.6.57, internalAddress: 192.168.6.57, user: root, password: "Redsun888@"}
              roleGroups:
                etcd:
                - node1
                control-plane:
                - node1
                worker:
                - node1
                - node2
              controlPlaneEndpoint:
                ## Internal loadbalancer for apiservers
                # internalLoadbalancer: haproxy
            
                domain: lb.kubesphere.local
                address: ""
                port: 6443
              kubernetes:
                version: v1.23.17
                clusterName: cluster.local
                autoRenewCerts: true
                containerManager: docker
              etcd:
                type: kubekey
              network:
                plugin: calico
                kubePodsCIDR: 10.233.64.0/18
                kubeServiceCIDR: 10.233.0.0/18
                ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni
                multusCNI:
                  enabled: false
              registry:
                privateRegistry: ""
                namespaceOverride: ""
                registryMirrors: []
                insecureRegistries: []
              addons: []
        ```
        
         ```
            ./kk create config --with-kubernetes <Kubernetes version>
            ./kk create cluster -f node-k8s.yaml
            开始下载依赖的二进制、镜像和组件,都保存在当前目录的kubekey下面.
            时间较长,完成以后,执行 kubectl get pod -A 查看是否安装成功。
        ```
    
    - 新增节点
       编辑配置文件,将新的节点写入到配置文件中,并确定是worker还是master等。
       然后执行新增命令
    ./kk add nodes -f multi-node-k8s.yaml ```