2、Kubeadm 部署安装.pdf
kube-proxy开启ipvs的前置条件

modprobe br_netfilter

cat > /etc/sysconfig/modules/ipvs.modules <#!/bin/bash
modprobe — ip_vs
modprobe — ip_vs_rr
modprobe — ip_vs_wrr
modprobe — ip_vs_sh
modprobe — nf_conntrack_ipv4
EOF

chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4

安装 Docker 软件
官方安装文档: https://docs.docker.com/engine/install/centos/
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
yum install -y yum-utils
yum-config-manager —add-repo https://download.docker.com/linux/centos/docker-ce.repo

创建 /etc/docker 目录
mkdir /etc/docker
# 配置 daemon.
cat > /etc/docker/daemon.json <{
“exec-opts”: [“native.cgroupdriver=systemd”],
“log-driver”: “json-file”,
“log-opts”: {“max-size”: “100m” }
}
EOF

mkdir-p /etc/systemd/system/docker.service.d

yum install docker-ce docker-ce-cli containerd.io
systemctl daemon-reload && systemctl restart docker && systemctl enable docker

安装 Kubeadm (主从都安装)
cat < /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

yum -y install kubeadm-1.15.1 kubectl-1.15.1 kubelet-1.15.1
systemctl enable kubelet.service

离线包体安装
docker load

初始化主节点
kubeadm config print init-defaults > kubeadm-config.yaml
修改以下部分:
localAPIEndpoint:
advertiseAddress: 192.168.66.10
kubernetesVersion: v1.15.1
networking:
podSubnet: “10.244.0.0/16”
serviceSubnet: 10.96.0.0/12
新增以下内容:
—-
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
featureGates:
SupportIPVSProxy
Mode: true

kubeadm init —config=kubeadm-config.yaml —experimental-upload-certs | tee kubeadm-init.log

部署flannel网络
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl create -f kube-flannel.yml
查询状态
kubectl get pod -n kube-system
kubectl get pod -n kube-system -o wide

镜像 flanneld-v0.12.0-amd64.docker 可能下载不下来 需要手动下载
kube-flannel.yml文件时发现quay.io/coreos/flannel:v0.12.0-amd64
quay.io网站目前国内无法访问
下载flannel:v0.12.0-amd64导入到docker中
可以去[https://github.com/coreos/flannel/releases](https://github.com/coreos/flannel/releases)官方仓库下载镜像