内容简介:[初始化配置节点][动态添加节点]k8s设计出于性能的考虑,不使用swap 分区, “swapoff -a” or “echo “vm.swappiness = 0″>> /etc/sysctl.conf”
集群
[初始化配置节点]
- master1 157.230.148.56
- node1 157.230.145.228
[动态添加节点]
- node2 157.230.176.176
注意
k8s设计出于性能的考虑,不使用swap 分区, “swapoff -a” or “echo “vm.swappiness = 0″>> /etc/sysctl.conf”
安装依赖环境
apt install python-pip -y apt install git -y pip install ansible pip install netaddr pip install Jinja2
配置密钥互通
# 一、node A(master):
ssh-keygen -t rsa cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 二、node B:
# 上传密钥到node B # scp ~/.ssh/id_rsa.pub root@node B:/root/.ssh cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 三、ssh互通测试
ssh root@node B
kubernetes集群配置
# 一、下载kubernetes
git clone https://github.com/kubernetes-sigs/kubespray cd kubespray pip install -r requirements.txt cp -r inventory/sample inventory/cppla
# 二、初始化inventory文件
declare -a IPS=(157.230.148.56 157.230.145.228) CONFIG_FILE=inventory/cppla/hosts.ini python3 contrib/inventory_builder/inventory.py ${IPS[@]}
# 三、调整集群配置cppla/hosts.ini
[all] node1 ansible_host=157.230.148.56 ip=157.230.148.56 node2 ansible_host=157.230.145.228 ip=157.230.145.228 [kube-master] node1 [etcd] node1 [kube-node] node2 [k8s-cluster:children] kube-master kube-node [calico-rr]
启动kubernetes集群
ansible-playbook -i inventory/cppla/hosts.ini cluster.yml
动态添加kubernetes节点
# 一、新节点添加密钥互通
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 二、调整集群配置cppla/hosts.ini
[all] node1 ansible_host=157.230.148.56 ip=157.230.148.56 node2 ansible_host=157.230.145.228 ip=157.230.145.228 node3 ansible_host=157.230.176.176 ip=157.230.176.176 [kube-master] node1 [etcd] node1 [kube-node] node2 node3 [k8s-cluster:children] kube-master kube-node [calico-rr]
# 三、执行命令
ansible-playbook -i inventory/cppla/hosts.ini scale.yml
验证kubernetes集群是否成功
# kubectl get node NAME STATUS ROLES AGE VERSION node1 Ready master 32m v1.13.2 node2 Ready node 32m v1.13.2 node3 Ready node 65s v1.13.2
以上测试on DigitalOcean Cloud Computing , time:20190121, by:cpp.la
以上所述就是小编给大家介绍的《cppla带你玩k8s之一(快速配置kubernets集群)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 配置Hadoop集群JobHistoryServer
- Apache配置——支持JBoss集群
- 配置Hadoop集群客户端
- Consul 集群部署 + ACL 配置
- SLife 1.0 加入集群的配置和 Docker 化部署配置
- Mariadb之半同步复制集群配置
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Elements of Programming
Alexander A. Stepanov、Paul McJones / Addison-Wesley Professional / 2009-6-19 / USD 39.99
Elements of Programming provides a different understanding of programming than is presented elsewhere. Its major premise is that practical programming, like other areas of science and engineering, mus......一起来看看 《Elements of Programming》 这本书的介绍吧!