所有服务都作为pod运行
安装docker
在阿里云上找docker-ce.repo放到
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
再查找k8s的rpm包,在https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/复制路径创建repo文件
vim /etc/yum.repos.d/kubernetes
[kub]
name=kubers
baseurl="https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/"
gpgcheck=0
enabled=1
key文件在doc目录下https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
wget https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
wget https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
用import导入检查的key
rpm --import rpm-package-key.gpg
rpm --import yum-key.gpg
加载yum文件,yum repolist
将两个配置文件传送给两台node节点
master:
1.安装包
yum install docker-ce kubelet kubeadm kubectl
docker-ce :18.06的包
kubectl : server命令行客户端
2.启动docker
3.跳过被墙配置
vim /etc/docker/daemon.json
{ "registry-mirrors":["https://hub-mirror.c.163.com"] }
4.重启服务
systemctl daemon-reload
systemctl enable docker
会提示报错,因为配置文件没有完全修改完成
查看配置文件
docker info
cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
cat /proc/sys/net/bridge/bridge-nf-call-iptables
两个文件的值都为1正确
5.初始化环境
忽略swap表
vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
#如果swap是on的话,不让它报错
下载所需要的docker源
docker pull mirrorgooglecontainers/kube-apiserver:v1.14.2
docker pull mirrorgooglecontainers/kube-controller-manager:v1.14.2
docker pull mirrorgooglecontainers/kube-scheduler:v1.14.2
docker pull mirrorgooglecontainers/kube-proxy:v1.14.2
docker pull mirrorgooglecontainers/pause:3.1:
docker pull mirrorgooglecontainers/etcd:3.3.10
docker pull coredns/coredns:1.3.1
修改tag标签
docker tag mirrorgooglecontainers/kube-apiserver:v1.14.2 k8s.gcr.io/kube-apiserver:v1.14.2
docker tag mirrorgooglecontainers/kube-controller-manager:v1.14.2 k8s.gcr.io/kube-controller-manager:v1.14.2
docker tag mirrorgooglecontainers/kube-scheduler:v1.14.2 k8s.gcr.io/kube-scheduler:v1.14.2
docker tag mirrorgooglecontainers/kube-proxy:v1.14.2 k8s.gcr.io/kube-proxy:v1.14.2
docker tag mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag mirrorgooglecontainers/etcd:3.3.10 k8s.gcr.io/etcd:3.3.10
docker tag coredns/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
删除多余的镜像
docker rmi mirrorgooglecontainers/etcd:3.3.10
docker rmi mirrorgooglecontainers/kube-apiserver:v1.14.2
docker rmi mirrorgooglecontainers/kube-controller-manager:v1.14.2
docker rmi mirrorgooglecontainers/kube-scheduler:v1.14.2
docker rmi mirrorgooglecontainers/kube-proxy:v1.14.2
docker rmi coredns/coredns:1.3.1
docker rmi mirrorgooglecontainers/pause:3.1
初始化安装
kubeadm init --kubernetes-version=v1.14.2
根据提示做下面操作
mkdir -p $home/.kube
cp -i /etc/kubernetes/admin.conf $home/.kube/config
kubeadm join行要保存好 以后会用到,查询麻烦
kubectl get cs
显示组件状态信息正常显示健康即可
kubectl get nodes
显示节点信息
部署网络插件falnnel
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl get pods -n kube-system
查看pod资源,有则完成,同时docker images会有镜像
kubectl get us
查看名称空间
重启和设置开机自启动docker和kubectl
node节点:(1.2部署步骤相同)
wget https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
rpm --import rpm-package-key.gpg
yum -y install docker-ce kubelet kubeadm
复制 master上的
/usr/lib/systemd/system/docker.server 到本机同样的位置
/etc/sysconfig/kubelet 到本机同样的位置
重启docker和kubectl
执行上面刚才保存的那个命令 加上
–ignore-preflight-errors=Swap
node节点上会下载三个镜像
kube-proxy
flannel
pause
这时主节点
kubectl get nodes
node01 status为Ready
roles 为 none
kubectl get pods -n kube-system
kube-proxy和flannel会在主节点和node节点上运行
以上结果验证完成则节点部署完成