Saturday, January 12, 2019

Setting up RKE Cluster


Centos 7.5
Docker 17.03
Kubernetes 1.11

Preparation
===========

1. Download latest RKE binary in https://github.com/rancher/rke/releases/.

2. Create separate partition for docker data.
pvcreate /dev/sdb
vgcreate docker_vg /dev/sdb
lvcreate -n docker_lv -l 100%FREE docker_vg
mkfs.xfs /dev/mapper/docker_vg-docker_lv
echo "/dev/mapper/docker_vg-docker_lv  /var/lib/docker  xfs  defaults  0 0" >> /etc/fstab
mkdir -p /var/lib/docker
mount -a
3. Install docker-ce 17.03.
curl https://releases.rancher.com/install-docker/17.03.sh | sh
systemctl enable --now dockervm.
4. Disable swappiness.
echo "vm.swappiness = 0" >> /etc/sysctl.conf
sysctl -p
5. Disable Network Manager.
systemctl disable --now NetworkManager
6. Allow the following ports in the firewall.
cat << EOF > ports.txt
6443/tcp
2376/tcp
2379/tcp
2380/tcp
8472/tcp
10250/tcp
80/tcp
443/tcp
30000-32767/tcp
EOF
for port in $(cat ports.txt); do firewall-cmd --add-port=$port --permanent; done
7. Load needed kernel modules.
cat << EOF > modules.txt
br_netfilter
ip6_udp_tunnel
ip_set
ip_set_hash_ip
ip_set_hash_net
iptable_filter
iptable_nat
iptable_mangle
iptable_raw
nf_conntrack_netlink
nf_conntrack
nf_conntrack_ipv4
nf_defrag_ipv4
nf_nat
nf_nat_ipv4
nf_nat_masquerade_ipv4
nfnetlink
udp_tunnel
veth
vxlan
x_tables
xt_addrtype
xt_conntrack
xt_comment
xt_mark
xt_multiport
xt_nat
xt_recent
xt_set
xt_statistic
xt_tcpudp
EOF
for module in $(cat modules.txt); do modprobe $module; done
8. Add the following line in /usr/lib/systemd/system/docker.service.
[...]
KillMode=process
MountFlags=shared
[...]
systemctl daemon-reload
ssytemctl restart docker
9. Allow SSH tunelling and forwarding. Update sshd_config.
[...]
AllowTcpForwarding yes
PermitTunnel yes
[...]
systemctl restart sshd
10. Get kubectl.
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl
mv kubectl /usr/local/bin/
Bootstrap the cluster
=====================

1. Generate RKE config. This will allow you to answer a series of
questions regarding the cluster. It will generate "cluster.yml" to
be used on the next step.
rke config
2. Bootstrap cluster.
rke up

No comments:

Post a Comment