Skip to content

Rancher安装k8s集群 #188

@v5tech

Description

@v5tech

Vagrantfile

Vagrant.configure("2") do |config|
	config.vm.define "centos7" do |node|
	  node.vm.box = "centos/7"
	  node.vm.box_version = "1905.1"
	  node.vm.box_check_update = false

	  node.vm.provision "shell", inline: "echo This box contains CentOS 7 64-bit."
	  node.vm.hostname = "centos"
	  node.vm.network "public_network", ip: "172.30.31.246"
	  
	  node.vm.provider "virtualbox" do |v|
	    v.name = "centos"
	    v.memory = 4096
	    v.cpus = 2
	  end
	end
end

关闭SELinux

# vim /etc/selinux/config

SELINUX=disabled

关闭虚拟内存

# vim /etc/fstab

#/swapfile none swap defaults 0 0

禁用ipv6

# ifconfig -a | grep inet6
	inet6 fe80::211:aff:fe6a:9de4  prefixlen 64  scopeid 0x20
	inet6 ::1  prefixlen 128  scopeid 0x10[host]

# vim /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

# grub2-mkconfig -o /boot/grub2/grub.cfg

# shutdown -r now	

# ip addr show | grep net6

https://www.thegeekdiary.com/centos-rhel-7-how-to-disable-ipv6/

安装docker

# sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
    
# sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

# sudo yum install docker-ce docker-ce-cli containerd.io	

# sudo systemctl start docker && sudo systemctl enable docker

# sudo systemctl status docker

禁用防火墙

# sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service

# sudo systemctl status firewalld.service

设置iptables

# sudo iptables -nL

# sudo iptables -P FORWARD ACCEPT

# sudo iptables -S

ipv4端口转发

# vim /etc/sysctl.conf

net.ipv4.ip_forward=1

docker中开启iptables

# vim /etc/systemd/system/docker.service

[Service]
ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT

安装rancher

# sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher

# sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.2.8 --server https://172.30.31.246 --token vgz22zdgc4g69cn4hqjttr47h8nqbfl7zwhmqhqh6sgmd6k5wkclvl --ca-checksum 09df17c14f54bac1c0c4842784652dfb168b9b741af6db8bfa37d1d6d8a31b7c --address 172.30.31.246 --internal-address 172.30.31.246 --etcd --controlplane --worker

参考文档

https://nll.im/post/hello-k3s.html

https://blog.ilemonrain.com/docker/rancher-with-k3s.html

http://xcx1024.com/ArtInfo/183043.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions