一、kubeadm命令行运行生成kubenetes的逻辑
首先如果有kubeadm命令,不放运行一下下图中的命令。可以看到init的相关执行逻辑。可以看到主要分为以下几个部分。
- preflight,系统前置检查
- certs 各种证书的文件生成
- kubeconfig生成kubeconfig文件,主要是kubenetes的几大组件的配置文件。
- kubelet-start 启动kubelet
- control-plane 生成所有静态pod的manifest文件,这些静态pod组成了kubenetes的控制面板,apiserver,controller,scheduler,生成这个文件后,kubelet会自动依据此文件描述的信息拉起镜像
- etcd 生成etcd的manifest
- upload-config 上传kubeadm和kubelet的配置文件到configmap中
- upload-certs 上传配置证书文件
- mark-control-plane mark一个node作为控制台
- bootstrap-token 生成bootstrap tokens用于把node节点加入到集群。
- kubelet-finalize 更新kubelet的设置
- addon 安装其他的相关组件。主要是网络组件dns和kube-proxy
lbl$ ./kubeadm init --help
Run this command in order to set up the Kubernetes control plane
The "init" command executes the following phases:
```
preflight Run pre-flight checks
certs Certificate generation
/ca Generate the self-signed Kubernetes CA to provision identities for other Kubernetes components
/apiserver Generate the certificate for serving the Kubernetes API
/apiserver-kubelet-client Generate the certificate for the API server to connect to kubelet
/front-proxy-ca Generate the self-signed CA to provision identities for front proxy
/front-proxy-client Generate the certificate for the front proxy client
/etcd-ca Generate the self-signed CA to provision identities for etcd
/etcd-server Generate the certificate for serving etcd
/etcd-peer Generate the certificate for etcd nodes to communicate with each other
/etcd-healthcheck-client Generate the certificate for liveness probes to healthcheck etcd
/apiserver-etcd-client Generate the certificate the apiserver uses to access etcd
/sa Generate a private key for signing service account tokens along with its public key
kubeconfig Generate all kubeconfig files necessary to establish the control plane and the admin kubeconfig file
/admin Generate a kubeconfig file for the admin to use and for kubeadm itself
/kubelet Generate a kubeconfig file for the kubelet to use *only* for cluster bootstrapping purposes
/controller-manager Generate a kubeconfig file for the controller manager to use
/scheduler Generate a kubeconfig file for the scheduler to use
kubelet-start Write kubelet settings and (re)start the kubelet
control-plane Generate all static Pod manifest files necessary to establish the control plane
/apiserver Generates the ku