понедельник, 10 июня 2019 г.

Install Kubernetes on CentOS 7

Installation and Setup

Setup the repository
vi /etc/yum.repos.d/kubernetes.repo

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

Turn off swap
swapoff -a
remove any swap entry from /etc/fstab

Set Cgroup driver to Systemd
vi /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}

setenforce 0 
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

Setup Firewall rules

for Firewalld:
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250/tcp 
firewall-cmd --permanent --add-port=10255/tcp 
firewall-cmd --permanent --add-port=30000-32767/tcp 
firewall-cmd --permanent --add-port=6783/tcp 
firewall-cmd --reload 
echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables

for iptables:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10250 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10255 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 6783 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 6443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2379:2380 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 30000:32767 -j ACCEPT

iptables -I INPUT -p tcp -m tcp --dport 10250 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 10255 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 6783 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 6443 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 2379:2380 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 30000:32767 -j ACCEPT
iptables -L|grep dpt

Restart
shutdown -r now

Install Kubeadm
yum -y install kubeadm

Initialize Kubeadm
kubeadm init

Set some settings
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config

Deploy Network
export kubever=$(kubectl version | base64 | tr -d '\n')
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever"

*Get the Join Command in Kubernetes
kubeadm token create --print-join-command

Add workers (execute on worker nodes)
kubeadm join 192.168.1.111:6443 --token 2gn7gp.89keisg0va0b9v23  --discovery-token-ca-cert-hash sha256:772d399b685c9809c5f0ea9b3b38026cbabde2ba69abcbdabc3a3ca15c89
*the command will be different in your case.

TroubleShooting
https://medium.com/@texasdave2/troubleshoot-kubectl-connection-refused-6f5445a396ed


Комментариев нет:

Отправить комментарий