0
点赞
收藏
分享

微信扫一扫

rancher部署k8s集群

晗韩不普通 2023-09-16 阅读 59

实验环境

rancher_server  192.168.10.36

rancher_node    192.168.10.6


软件安装

cat /etc/redhat-release && uname -a

CentOS Linux release 7.8.2003 (Core)

Linux centos7-1 3.10.0-1127.el7.x86_64


systemctl stop firewalld && systemctl disable firewalld

echo SELINUX=disabled > /etc/sysconfig/selinux


cp -pv /etc/sysctl.conf /etc/sysctl.conf.bak

echo net.ipv4.tcp_syncookies = 1 >> /etc/sysctl.conf

echo net.ipv4.tcp_tw_reuse = 1 >> /etc/sysctl.conf

echo net.ipv4.tcp_tw_recycle = 1 >> /etc/sysctl.conf

echo net.ipv4.tcp_fin_timeout = 10 >> /etc/sysctl.conf

echo net.ipv4.ip_forward = 1  >> /etc/sysctl.conf

sysctl -p


hostnamectl  set-hostname k8s1  && bash

hostnamectl set-hostname k8s2  &&  bash


echo 192.168.10.36 k8s1  >> /etc/hosts

echo 192.168.10.6 k8s2  >> /etc/hosts


yum install -y ansible

cp -pv /etc/ansible/ansible.cfg /etc/ansible/ansible.cfg.bak

sed -i 's/#log_path/log_path/g' /etc/ansible/ansible.cfg

sed -i 's/#inventory/inventory/g' /etc/ansible/ansible.cfg

sed -i 's/#host_key_checking /host_key_checking/g' /etc/ansible/ansible.cfg

sed -i 's/#remote_user/remote_user/g' /etc/ansible/ansible.cfg


cp -pv /etc/ansible/hosts  /etc/ansible/hosts.bak

cat /etc/ansible/hosts

[rancher]

k8s1  ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=123

k8s2  ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=123


ansible rancher -m copy -a "src=/etc/hosts dest=/etc/hosts"

ansible rancher  -m ping  测试服务连通性


ansible rancher   -m shell -a "modprobe br_netfilter && sh -c 'echo "br_netfilter" > /etc/modules-load.d/br_netfilter.conf' && lsmod | grep br_netfilter"  

ansible rancher -m shell -a "src=/etc/sysctl.conf dest=/etc/sysctl.conf.bak"

echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf

echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf

sysctl -p


ansible rancher -m copy -a "src=/etc/sysctl.conf dest=/etc/sysctl.conf"

ansible rancher -m shell -a "sysctl -p"


















举报

相关推荐

0 条评论