Pod

k8s是怎么维持pod的运行的呢?

May 13, 2022
K8s
Pod

k8s是怎么维持pod的运行的呢? # 当接收了yaml配置的信息后,是怎么维持pod根据声明一直运行的呢? 让我们沿着命令执行的过程来一睹为快:kubectl apply -f pod.yaml. 源码位置:cmd/kubectl/kubectl.go -> staging/src/k8s.io/kubectl/pkg/cmd/cmd.go -> staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go 最终的执行方法: func (o *ApplyOptions) Run() error { // 预处理 if o.PreProcessorFn != nil { klog.V(4).Infof("Running apply pre-processor function") if err := o.PreProcessorFn(); err != nil { return err } } // Enforce CLI specified namespace on server request. if o.EnforceNamespace { o.VisitedNamespaces.Insert(o.Namespace) } // Generates the objects using the resource builder if they have not // already been stored by calling "SetObjects()" in the pre-processor. ...