二、关键流程代码走读( 三 )


下?整理了这就是 init的核?代码流程阶段,当然在上??志如果你仔细观察前?的标志的话也能看的出来
1
2
3
4
5
6
7 hase
8
9
10 hase
11 se
12 ase
13
下?来?核?代码init所?到的部分
上?第?条?志输出,我们可以根据代码去查看阅读
2.1.3 开始初始化
“[init] Using: v1.21.0”,
也就是第?个当我们执?init的时候,回到我们的主代码init.go当中,我们可以清晰的看到第?个就是来获取集群的版本,上?还包含了cobra的主函数代码段,配置init的?命令,及详细信息说明
2.1.3就绪前检查
紧接着就是进?就绪前的检查,相信?家经常部署的很熟悉这个地?,那么到底检查了哪些?
"[preflight] Running pre-flight checks","[preflight] Pulling images required for setting up a Kubernetes cluster","[preflight] This might take a minute or two, depending on the speed of your internet connection","[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'",
1、在做出变更前运??系列的预检项来验证系统状态 。?些检查项?仅仅触发警告,其它的则会被视为错误并且退出
,除?问题得到解决或者?户指定了 ----= 参数
2、在中实际上调用了(),而中调用了
3、在中包含一堆检查
4、进行一系列的判断之后,其实就是在中添加了一堆对象,每个对象都实现了check的接口,交给真正执行check方法的去执行
5、遍历,执行check()
() 需要传入一个check的切片,而上面的对象每一个都实现了接口,所以可以传入
这里用举例说明
6、在一系列的检查通过后,执行镜像拉取操作
如果在系统上找不到图像,则将提取需要的镜像,另外还增加对、,容器运?时镜像列表做了判断,通过是?于处理容器运?时的CRI接?,判断?的运?时环境,并获取需要的镜像列表
补充一下k8s需要开放的端口
【二、关键流程代码走读】2.1.4 生成证书
?成?个?签名的 CA 证书来为集群中的每?个组件建?身份标识 。?户可以通过将其放? --cert-dir 配置的证书?录中(默认为 /etc//pki) 来提供他们??的 CA 证书以及/或者密钥 。证书将为任何
–-cert extra-sans 参数值提供附加的 SAN 条?,必要时将其?写 。
"[certs] Using certificateDir folder \"/etc/kubernetes/pki\"","[certs] Generating \"ca\" certificate and key","[certs] Generating \"apiserver\" certificate and key","[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svckubernetes.default.svc.cluster.local master] and IPs [10.96.0.1 192.168.30.81]","[certs] Generating \"apiserver-kubelet-client\" certificate and key","[certs] Generating \"front-proxy-ca\" certificate and key","[certs] Generating \"front-proxy-client\" certificate and key","[certs] Generating \"etcd/ca\" certificate and key","[certs] Generating \"etcd/server\" certificate and key","[certs] Generating \"etcd/peer\" certificate and key","[certs] etcd/peer serving cert is signed for DNS names [localhost master] and IPs [192.168.30.81 127.0.0.1 ::1]","[certs] Generating \"etcd/healthcheck-client\" certificate and key","[certs] Generating \"apiserver-etcd-client\" certificate and key","[certs] Generating \"sa\" key and public key"
具体包含下??项,这?我帮你解释?下,重要的?件是做什么的
上?的操作其中代码中主要做了上??成证书的操作,其中证书存储在中/etc//pki?录下
具体写?的?录则是通过实现的
另外
"[certs] apiserver serving cert is signed for DNS names [kubernetes kubernetes.default kubernetes.default.svckubernetes.default.svc.cluster.local master] and IPs [10.96.0.1 192.168.30.81]","[certs] etcd/server serving cert is signed for DNS names [localhost master] and IPs [192.168.30.81 127.0.0.1 ::1]"