K8s
kubeadm部署集群
k8s001
k8s002
k8s003
1.修改hosts
echo "192.168.201.135 k8s01">>/etc/hosts
echo "192.168.201.136 k8s02">>/etc/hosts
echo "192.168.201.137 k8s03">>/etc/hosts
2关闭防火墙
查看防火墙状态
firewall-cmd --state
- 1
停止firewall
systemctl stop firewalld.service
- 1
禁止firewall开机启动
systemctl disable firewalld.service
不能清除规则(-F)cdh中需要清除
iptables -L ()
3 禁用selinux
setenforce 0
cat /etc/selinux/config
selinux =disabled
4 Swapoff -a
5解决路由异常
echo "
net.bridge.bridge-nf-call-ip6tables = 1
" >> /etc/sysctl.d/k8s.conf
echo "
net.bridge.bridge-nf-call-iptables = 1
" >> /etc/sysctl.d/k8s.conf
echo "vm.swappiness=0"
>> /etc/sysctl.d/k8s.conf
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf
6安装docker Docker
yum install -y docker
systemctl enbale docker && systemctl start docker
7安装kubelet(底层) kubeadm(管理) kubectl(工作内容)
cat <<EOF >
/
etc
/
yum.repos.d
/
kubernetes.repo
[kubernetes]
name
=
Kubernetes
baseurl
=
http:
/
/
mirrors.aliyun.com
/
kubernetes
/
yum
/
repos
/
kubernetes
-
el7
-
x86_64
enabled
=
1
gpgcheck
=
0
repo_gpgcheck
=
0
gpgkey
=
http:
/
/
mirrors.aliyun.com
/
kubernetes
/
yum
/
doc
/
yum
-
key.gpg
http:
/
/
mirrors.aliyun.com
/
kubernetes
/
yum
/
doc
/
rpm
-
package
-
key.gpg
EOF
1.14.1坑
要求0.6.0 阿里云是0.6.0-0 强行指定
yum install -y kubelet-1.13.2 kubeadm-1.13.2 kubectl-1.13.2 kubernetes-cni-0.6.0-0
systemctl enable kubelet(开机自启动)
yum remove -y kubelet kubeadm kubectl
8image 手动执行
images=(kube-apiserver:v1.13.2 kube-controller-manager:v1.13.2 kube-scheduler:v1.13.2 kube-proxy:v1.13.2 pause:3.1 etcd:3.2.24 coredns:1.2.6)
for imageName in ${images[@]} ; do
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/${imageName}
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/${imageName} k8s.gcr.io/${imageName}
done
for imageName in ${images[@]} ; do
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/${imageName}
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/${imageName} k8s.gcr.io/${imageName}
done
初始化
kubeadm init --kubernetes-version=v1.13.2 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
kubeadmn reset
9
设置普通账户权限:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
root 用户,则可以运行:
export KUBECONFIG=/etc/kubernetes/admin.conf
https://my.oschina.net/Kanonpy/blog/3006129
自己做了一层网路
10 用kubeadm部署node,把其加入master
用上面kubeadm init 安装完成后给的命令即可:
kubeadm join 192.168.1.120:6443 --token xmjnn0.39xbep2zpyh0rjam --discovery-token-ca-cert-hash sha256:9c2dc63bab2a1392e
11 kubeadm get nodes
12安装dashboard(额外安装)
https://blog.csdn.net/bbwangj/article/details/82024485
上一篇: k8s和docker的关系