kubeadm安装k8s

*****************

版本号:

docker-ce 3:19.03.14-3.el7
kubernetes 1.19.4

注意:版本号重要,在centos7下安装的,下面是他人的博客

k8s安装
https://www.cnblogs.com/double-dong/p/11483670.html
******************
================
初始化的token只能24小时
解决2种办法 https://www.jianshu.com/p/f4445a072bbe
1,kubeadm token create --print-join-command
2,# 重新生成新的token
kubeadm token create
kubeadm token list
# 获取ca证书sha256编码hash值
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
# 加入集群
kubeadm join masterIP:6443 --token xxxxxxxxxxx --discovery-token-ca-cert-hash sha256:xxxxxx
============
kubeadm重置
https://blog.csdn.net/gs80140/article/details/92798027

swapoff -a # will turn off the swap
kubeadm reset
systemctl daemon-reload
systemctl restart kubelet
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X

===============

关闭swap分区
swapoff -a # 临时关闭
sed -ri 's/.*swap.*/#&/' /etc/fstab
====================
docker的管理改成systemd
[root@localhost manifests]# cat /etc/docker/daemon.json
{
"exec-opts":["native.cgroupdriver=systemd"]
}


===============

报错:在node上      kubectl get nodes

The connection to the server localhost:8080 was refused - did you specify the right host or port?

解决:

https://www.jianshu.com/p/6fa06b9bbf6a

出现这个问题的原因是kubectl命令需要使用kubernetes-admin来运行,解决方法如下,将主节点中的【/etc/kubernetes/admin.conf】文件拷贝到从节点相同目录下,然后配置环境变量:
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile

 

=================

以上安装在master执行join会报错

error:10250端口is used(kublet在使用啊)
哪位大佬可以帮忙看下?辛苦了

 

 

 

k8s结构图

 

 

 

 

概念,pod,service,ingress,deployment,coreDns,flannel,iptables,ipvs

工作原理:service的cluster ip通过iptables的nat规则找到endpoint  pod(kube proxy),但是pod跨物理机需要flannel实现大二层网络

如果服务需要在Internet上访问,service可以通过hostnode(映射物理机的端口)或者用ingress(只是http协议)实现

 

posted @ 2020-11-29 09:46  jianxiaofeng  阅读(133)  评论(0编辑  收藏  举报