k8s 安装配置
节点规划
k8s-m:10.0.0.11
k8s-n1:10.0.0.12
k8s-n2:10.0.0.13
一、所有节点下载安装 docker 环境及依赖:docker-k8s.tar
不要直接安装 docker-ce,会导致版本不兼容问题
tar -zxvf docker-k8s.tar
yum localinstall -y *.rpm
二、主节点下载安装 k8s-master.zip
unzip k8s-master.zip
yum localinstall -y *.rpm
三、其他两个 node 节点下载安装 k8s-node.tar
其实master也可以当作node
tar -zxvf k8s-node.tar
yum install -y *.rpm
四、配置主节点ETCD(类似于 mongodb 的 config-server)统一配置管理(key:value)
可以单独找台机器安装、也支持集群模式
vim /etc/etcd/etcd.conf
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"(etcd的服务)
ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.11:2379"(由于etcd安装在master节点上)
systemctl restart etcd.service
systemctl enable etcd.service
测试一下
etcdctl set name yaok
etcdctl get name
五、配置 master 节点
vim /etc/kubernetes/apiserver
KUBE_API_ADDRESS="0.0.0.0"
KUBE_API_PORT="8080"
KUBE_ETCD_SERVERS="--etcd-servers=http://10.0.0.11:2379"
KUBE_SERVERS_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
vim /etc/kubernetes/config(客户端node需要改,服务端不用改)
systemctl enable kube-apiserver.service
systemctl start kube-apiserver.service
systemctl enable kube-controller-manage.service
systemctl start kube-controller-manage.service
systemctl enable kube-scheduler.service
systemctl start kube-scheduler.service
六、node 节点配置
vim /etc/kubernetes/config
KUBE_MASTER="--name=http://10.0.0.11:8080"
vim /etc/kubernetes/kubelet
KUBELET_ADDRESS="--address=10.0.0.12/13"
KUBELET_HOSTNAME="--hostname-override=10.0.0.12/13"
KUBELET_API_SERVER="--api-servers=http://10.0.0.11:8080"
systemctl enable kubelet.service
systemctl start kubelet.service
systemctl enable kube-proxy.service
systemctl start kube-proxy.service
七、验证节点状态
在master上执行:
kubectl get nodes
八、配置 flannel 网络
所有节点:
yum install flannel -y
sed -i 's#heep://127.0.0.11:2379#g' /etc/sysconfig/flanneld
master 节点:
etcdctl mk /atomic.io/network/config '{"Network":"172.16.0.0/16"}'
etcdctl get /atomic.io/network/config
systemctl enable flanneld.service
systemctl start flanneld.service
service docker restart
systemctl restart kube-aipserver.service
systemctl restart kube-controller-manage.service
systemctl restart kube-scheduler.service
ifconfig -a
node 节点:
systemctl enable flanneld.service
systemctl start flanneld.service
service docker restart
systemctl restart kubelet.service
systemctl restart kube-proxy.service
九、配置 master 为镜像仓库
master 节点:
vim /etc/sysconfig/docker
OPTIONS='--selinux-enable --log-river=journald --signature-verification=false --registry-mirror=https://registry.docker-cn.com --insecure-registry=10.0.0.11:5000'
systemctl restart docker
配置本地 registry
docker tag nginx 10.0.0.11:5000/yaok/nginx:v1
docker run -d -p 5000:5000 --restart=always --name registry -v /opt/myregistry:/var/lib/registry registry
docker push 10.0.0.11:5000/yaok/nginx:v1
node 节点
vim /etc/sysconfig/docker
OPTIONS='--selinux-enable --log-river=journald --signature-verification=false --insecure-registry=10.0.0.11:5000'
systemctl restart docker
docker pull 10.0.0.11:5000/yaok/nginx:v1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论