一、Mac 下使用虚拟机安装 Kubernetes

电脑 8 核 16 G

1. 安装 VMware

2. 安装 Centos

3. 配置阿里云

        a. cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

        b. wget -O /etc/yum.repos.d/CentOS-Base.repo  http://mirrors.aliyun.com/repo/Centos-7.repo

        c. yum makecache

        d. yum update

        e. yum clean all

4. 配置静态网络(可省略)

        a. cat /Library/Preferences/VMware Fusion/vmnet8/nat.conf

                i. 获取 IPADDR

                ii. 获取 NETMASK

        b. /qLibrary/Preferences/VMware Fusion/vmnet8/dhcpd.conf    

                i. 获取GATEWAY

        c. vi /etc/sysconfig/network-scripts/ifcfg-ens33

                i. BOOTPROTO=static(ip地址设置为静态的)

                ii. IPADDR=上面mac中找到的ip范围中设置一个

                iii. NETMASK=255.255.255.0(也是从上面得到)

                iv. GATEWAY=设置上面mac中看到的gatway地址,即router路由地址(192.168.181.2)

                v. ONBOOT=yes

                vi. DNS1=x.x.x.x(在mac,网络,高级里面的选项卡能够找到

        d. systemctl restart network.service

5. 安装 docker 15

        a. mkdir /etc/yum.repos.d/bak

        b. cp /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

        c. wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo

        d. yum clean all && yum makecache

        e. yum install -y docker-ce-18.06.1.ce-3.el7

        f. systemctl enable docker && systemctl start docker

        g. docker version

6. 安装 kubernetes

        a. 配置国内Kubernetes源

                cat < /etc/yum.repos.d/kubernetes.repo

                [kubernetes]

                name=Kubernetes

                baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/

                enabled=1

                gpgcheck=1

                repo_gpgcheck=1

                gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

                EOF

        b. yum install -y kubelet-1.15.0 kubeadm-1.15.0 kubectl-1.15.1

7. 部署 Kubernetes

        a. systemctl stop firewalld & systemctl disable firewalld 关闭防火墙

        b. swapoff -a

        c. setenforce 0 关闭 Selinux

        d. 修改/etc/sysconfig/selinux文件 SELINUX=disabled

        e. 创建/etc/sysctl.d/k8s.conf

                net.bridge.bridge-nf-call-iptables = 1

                net.bridge.bridge-nf-call-ip6tables = 1

        f. sysctl --system

        g. 进入 /home/你的文件夹

        h. kubeadm config print init-defaults > kubeadm.conf

                i. sed -i "s/advertiseAddress: .*/advertiseAddress: 你的 IP/g" kubeadm.conf

                j. sed -i "s/podSubnet: .*/podSubnet: \"192.168.0.0\/16\"/g" kubeadm.conf

                k. sed -i "s/imageRepository: .*/imageRepository: registry.aliyuncs.com\/google_containers/g" kubeadm.conf

                l. sed -i "s/kubernetesVersion: .*/kubernetesVersion: v1.17.3/g" kubeadm.conf

                m. kubeadm config images pull --config kubeadm.conf (拉去镜像)

                n. kubeadm init --config kubeadm.conf 初始化

                o. 命令照搬

                        mkdir -p $HOME/.kube

                        sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

                        sudo chown $(id -u):$(id -g) $HOME/.kube/config

8. 安装网络插件

        a. wget https://docs.projectcalico.org/v3.8/manifests/calico.yaml

        b. kubectl apply -f calico.yaml

        c. 查看安装情况:kubectl get pods --all-namespaces

9. kubectl taint nodes --all node-role.kubernetes.io/master-

10. 拍摄快照

你可能感兴趣的:(一、Mac 下使用虚拟机安装 Kubernetes)