1、安装docker,参考 https://docs.docker.com/install/linux/docker-ee/centos/
配置:编辑或创建 /etc/docker/daemon.json
添加 "registry-mirrors": ["https://dockerhub.azk8s.cn","https://reg-mirror.qiniu.com"]
systemctl start docker #启动
systemctl enable docker #开机自启
2、防火墙关闭
systemctl status firewalld.service
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
3、swap 关闭
swapoff -a 临时关闭
用vi修改/etc/fstab文件,在swap分区这行前加 # 禁用掉,保存退出
4、配置k8s使用repo,使用阿里云镜像仓库
cat <<EOF > /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
SELinux是一种基于 域-类型 模型(domain-type)的强制访问控制(MAC)安全系统,需修改器配置
setenforce 0 关闭selinux
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
5、配置k8s操作网络许可配置
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
如果是测试机器的,这里可以重启一下机器
6、安装组件(注版本需要配套使用,高版本可能拉取不到相关容器镜像)
yum clean all
yum makecache
yum install kubernetes-cni-0.6.0 kubelet-1.13.4 kubeadm-1.13.4 kubectl-1.13.4
7、查看所需的镜像
kubeadm config images list
k8s.gcr.io/kube-apiserver:v1.13.4
k8s.gcr.io/kube-controller-manager:v1.13.4
k8s.gcr.io/kube-scheduler:v1.13.4
k8s.gcr.io/kube-proxy:v1.13.4
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.2.24
k8s.gcr.io/coredns:1.2.6
除了这些还有一个 quay.io/coreos/flannel:v0.11.0-amd64,kubernetes-cni网络插件所需要的一个容器镜像
文档:https://github.com/coreos/flannel/tree/master/Documentation
不然会报错误 Unable to update cni config: No networks found in /etc/cni/net.d
Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
8、拉取相关容器镜像,
docker pull mirrorgooglecontainers/kube-apiserver:v1.13.4
docker pull mirrorgooglecontainers/kube-controller-manager:v1.13.4
docker pull mirrorgooglecontainers/kube-scheduler:v1.13.4
docker pull mirrorgooglecontainers/kube-proxy:v1.13.4
docker pull mirrorgooglecontainers/pause:3.1
docker pull mirrorgooglecontainers/etcd:3.2.24
docker pull coredns/coredns:1.2.6
docker pull jmgao1983/flannel:v0.11.0-amd64
docker tag mirrorgooglecontainers/kube-apiserver:v1.13.4 k8s.gcr.io/kube-apiserver:v1.13.4
docker tag mirrorgooglecontainers/kube-controller-manager:v1.13.4 k8s.gcr.io/kube-controller-manager:v1.13.4
docker tag mirrorgooglecontainers/kube-scheduler:v1.13.4 k8s.gcr.io/kube-scheduler:v1.13.4
docker tag mirrorgooglecontainers/kube-proxy:v1.13.4 k8s.gcr.io/kube-proxy:v1.13.4
docker tag mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag mirrorgooglecontainers/etcd:3.2.24 k8s.gcr.io/etcd:3.2.24
docker tag coredns/coredns:1.2.6 k8s.gcr.io/coredns:1.2.6
docker tag jmgao1983/flannel:v0.11.0-amd64 quay.io/coreos/flannel:v0.11.0-amd64
9、kubeadm初始化
kubeadm init kubernetes-version=v1.13.4 --pod-network-cidr=10.244.0.0/16
# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-86c58d9df4-p7clm 1/1 Running 0 3h39m
kube-system coredns-86c58d9df4-qdwvk 1/1 Running 0 3h39m
kube-system etcd-master.k8s 1/1 Running 0 3h39m
kube-system kube-apiserver-master.k8s 1/1 Running 0 3h39m
kube-system kube-controller-manager-master.k8s 1/1 Running 0 3h39m
kube-system kube-flannel-ds-amd64-rtrrq 1/1 Running 0 152m
kube-system kube-proxy-dcxz2 1/1 Running 0 3h39m
kube-system kube-scheduler-master.k8s 1/1 Running 0 3h39m
10、
有疑问加站长微信联系(非本文作者))