• VMware Fusion部署 k8s cluster集群


    master
    导入ubuntu 镜像,Ubuntu 22.04 LTS iso https://ubuntu.com/download/desktop/thank-you?version=22.04&architecture=amd64

    sudo su
    apt install net-tools vim

    vim /etc/fstab
    #/swapfile none swap sw 0 0

    vim /etc/sysctl.conf

    vm.swappiness = 0
    
    • 1

    sysctl -p
    swapoff -a

    apt-get update
    apt-get install ca-certificates curl gnupg lsb-release
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    echo “deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu
    $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    apt-get update
    apt-get install docker-ce docker-ce-cli containerd.io

     cat <<EOF | sudo tee /etc/docker/daemon.json
     {
       "exec-opts": ["native.cgroupdriver=systemd"],
       "log-driver": "json-file",
       "log-opts": {
         "max-size": "100m"
       },
       "storage-driver": "overlay2"
     }
     EOF
     sudo systemctl enable docker
     sudo systemctl daemon-reload
     sudo systemctl restart docker
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    设置 proxy, 因为之后要用google.
    alias curl=“curl -x *****😗***”
    vim /etc/apt/apt.conf.d/80proxy

    Acquire::http::proxy "http://****";
    Acquire::https::proxy "http://*****";
    
    • 1
    • 2

    sudo apt-get update
    sudo apt-get install -y apt-transport-https ca-certificates curl

    sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg

    echo “deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main” | sudo tee /etc/apt/sources.list.d/kubernetes.list

    sudo apt-get update
    sudo apt-get install -qy kubeadm=1.22.3-00 kubelet=1.22.3-00 kubectl=1.22.3-00
    sudo apt-mark hold kubelet kubeadm kubectl

    保存当前虚机设置,拷贝出另外两个虚机,node-1,node-2

    查看本地fushion 的nat 配置
    cd /Library/Preferences/VMware Fusion

    cat vmnet8/nat.conf

    结果是
    ip = 192.168.187.2
    netmask = 255.255.255.0

    打开虚机master,node-1,node-2.
    配置ipv地址。 请添加图片描述
    三个虚机的address需要不同,其他设为一样。

    修改node-1和node-2的hostname

    sudo su
    vim /etc/hostname
    改为node-1, node-2

    重启三台虚机,使配置生效。

    在master的虚机上执行
    kubeadm init --apiserver-advertise-address 192.168.187.200 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.22.3 --pod-network-cidr 10.244.0.0/16
    结果如下: 拷贝join这条语句
    请添加图片描述
    export KUBECONFIG=/etc/kubernetes/admin.conf

    kubectl get pod --namespace=kube-system

    kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml

    kubectl get pod
    请添加图片描述

    分别切换到node-1, node-2

    执行
    sudo su
    kubeadm join 192.168.187.200:6443 --token lalblo.ojd7xx6byohtxjr7
    –discovery-token-ca-cert-hash sha256:2260781ac868d2dfcf296ef77daba74716ee254c6da48fd2507f0b7de7b4aa23

    然后到master上再次执行 kubectl get node.可以看到多了结点。请添加图片描述

    到此就部署成功了

  • 相关阅读:
    一笑的大型连续剧之第一集
    PhpStudy 2016搭建-DVWA靶场
    【已解决】matrix contains invalid numeric entries,记录bug修改
    github.com不能访问原因不是因为DNS,而是因为故意间歇性抽风,可改用镜像站
    2023年高校大数据实验室建设及大数据实训平台整体解决方案
    Mac自带apache2搭建服务请求localhost报 403 Forbidden
    mysql死锁查看
    Standard part function
    MyBatis框架——Mybatis操作数据库之简单的insert操作的实现
    1869. 哪种连续子字符串更长
  • 原文地址:https://blog.csdn.net/lovely_girl1126/article/details/125438966