KubeKey底层基于kubeadm快速部署K8S集群

1.安装依赖软件包
apt -y install socat conntrack ebtables ipset
2.设置区域
export KKZONE=cn
3.下载kubekey文件
wget https://github.com/kubesphere/kubekey/releases/download/v3.1.10/kubekey-v3.1.10-linux-amd64.tar.gz
wget http://192.168.21.253/Resources/Kubernetes/Project/kubesphere/kubersphere-on-linux/kube-key-v3.1.10_k8s-v1.28.12/kubekey-v3.1.10-linux-amd64.tar.gz

4.解压软件包
tar xf kubekey-v3.1.10-linux-amd64.tar.gz

5.生成安装配置文件模板
./kk create config --with-kubernetes v1.28.12
6.修改安装配置文件

点击查看代码
cat config-sample.yaml 

apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: k8s66, address: 10.0.0.66, internalAddress: 10.0.0.66, user: root, password: "1"}
  - {name: k8s77, address: 10.0.0.77, internalAddress: 10.0.0.77, user: root, password: "1"}
  - {name: k8s88, address: 10.0.0.88, internalAddress: 10.0.0.88, user: root, password: "1"}
  roleGroups:
    etcd:
    - k8s66
    - k8s77
    - k8s88
    control-plane: 
    - k8s66
    - k8s88
    worker:
    - k8s66
    - k8s77
    - k8s88
  controlPlaneEndpoint:
    ## Internal loadbalancer for apiservers 
    # internalLoadbalancer: haproxy

    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.28.12
    clusterName: cluster.local
    autoRenewCerts: true
    containerManager: containerd
  etcd:
    type: kubekey
  network:
    plugin: calico
    kubePodsCIDR: 10.100.0.0/16
    kubeServiceCIDR: 10.200.0.0/16
    ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni
    multusCNI:
      enabled: false
  registry:
    privateRegistry: ""
    namespaceOverride: ""
    registryMirrors: []
    insecureRegistries: []
  addons: []

7.安装k8s集群
./kk create cluster -f config-sample.yaml

...

15:46:17 CST Pipeline[CreateClusterPipeline] execute successfully
Installation is complete.

Please check the result using the command:
		
	kubectl get pod -A


8.检查集群POD

kubectl get nodes
NAME    STATUS   ROLES                  AGE   VERSION
k8s66   Ready    control-plane,worker   11m   v1.28.12
k8s77   Ready    worker                 10m   v1.28.12
k8s88   Ready    control-plane,worker   10m   v1.28.12

kubectl get pod -A
NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
kube-system   calico-kube-controllers-568d4f5458-64zhn   1/1     Running   0          10m
kube-system   calico-node-7b6cv                          1/1     Running   0          10m
kube-system   calico-node-ch9fk                          1/1     Running   0          10m
kube-system   calico-node-s286v                          1/1     Running   0          10m
kube-system   coredns-57946b76b-6x4zr                    1/1     Running   0          10m
kube-system   coredns-57946b76b-nfhhg                    1/1     Running   0          10m
kube-system   kube-apiserver-k8s66                       1/1     Running   0          10m
kube-system   kube-apiserver-k8s88                       1/1     Running   0          10m
kube-system   kube-controller-manager-k8s66              1/1     Running   0          10m
kube-system   kube-controller-manager-k8s88              1/1     Running   0          10m
kube-system   kube-proxy-8qmks                           1/1     Running   0          10m
kube-system   kube-proxy-h44bt                           1/1     Running   0          10m
kube-system   kube-proxy-q8hf9                           1/1     Running   0          10m
kube-system   kube-scheduler-k8s66                       1/1     Running   0          10m
kube-system   kube-scheduler-k8s88                       1/1     Running   0          10m
kube-system   nodelocaldns-6sqt7                         1/1     Running   0          10m
kube-system   nodelocaldns-q26n2                         1/1     Running   0          10m
kube-system   nodelocaldns-r4srh                         1/1     Running   0          10m
  • kubesphere图形化管理K8S集群

1.安装依赖软件包
apt -y install socat conntrack ebtables ipset
2.下载软件包
wget http://192.168.21.253/Resources/Kubernetes/Project/kubesphere/kubersphere-on-linux/kube-key-v3.1.10_k8s-v1.28.12/oldboyedu-ks-core.tar.gz
tar xf oldboyedu-ks-core.tar.gz
3.基于helm安装kubesphere
helm upgrade --install -n kubesphere-system --create-namespace my-ks-server ./ks-core

点击查看代码
Release "my-ks-server" does not exist. Installing it now.
NAME: my-ks-server
LAST DEPLOYED: Wed Jul 16 16:16:33 2025
NAMESPACE: kubesphere-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for choosing KubeSphere Helm Chart.

Please be patient and wait for several seconds for the KubeSphere deployment to complete.

1. Wait for Deployment Completion

    Confirm that all KubeSphere components are running by executing the following command:

    kubectl get pods -n kubesphere-system
2. Access the KubeSphere Console

    Once the deployment is complete, you can access the KubeSphere console using the following URL:  

    http://10.0.0.66:30880

3. Login to KubeSphere Console

    Use the following credentials to log in:

    Account: admin
    Password: P@88w0rd
4.登录kubesphere http://10.0.0.66:30880 默认的用户名和密码: Account: admin Password: P@88w0rd 5.修改初始密码 推荐密码: "Linux98@2025"
posted @ 2025-07-21 23:31  寻梦行  阅读(76)  评论(0)    收藏  举报