owned this note
owned this note
Published
Linked with GitHub
#### Summarize
Override the `ContainerRuntimeEndpoint` field in `kubelet-config.yml` with `kubelet-instace-config.yml`
Add the `kubelet-instace-config.yml` configuration file, which uses the data structure of the kubelet config
#### Effects on kubeadm
kubeadm init:
* If the `-cri-socket` args is specified, the `-cri-socket` args is preferred and the `kubelet-instace-config.yml` configuration file is generated based on the `-cri-socket` args, but it is not uploaded to the global configuration, if the `-cri-socket` args is not specified, the container runtime ennpoint is automatically detect and the configuration file is uploaded to the global configuration.
* No longer need to add the `kubeadm.alpha.kubernetes.io/cri-socket` annotation. cmd/kubeadm/app/cmd/phases/init/uploadconfig.go:131
```diff=131
- klog.V(1).Infoln("[upload-config] Preserving the CRISocket information for the control-plane node")
- if err := patchnodephase.AnnotateCRISocket(client, cfg.NodeRegistration.Name, cfg.NodeRegistration.CRISocket); err != nil {
- return errors.Wrap(err, "Error writing Crisocket information for the control-plane node")
- }
```
* There is no need to write the `container-runtime-endpoint` to kubeadm-flags.env. cmd/kubeadm/app/phases/kubelet/flags.go:79
```diff=79
- kubeletFlags = append(kubeletFlags, kubeadmapi.Arg{Name: "container-runtime-endpoint", Value: opts.nodeRegOpts.CRISocket})
```
kubeadm join:
* If the `-cri-socket` args is specified, the `-cri-socket` args is used in preference to the `-cri-socket` args, and the `kubelet-instace-config.yml` configuration file is generated based on `-cri-socket`, overriding the kubelet configuration downloaded from the global configuration; if the `-cri- socket` args is not specified, the kubelet configuration downloaded from the global configuration will be used.
cmd/kubeadm/app/cmd/phases/join/kubelet.go:179
```diff=184
if data.SkipCRIDetect() {
// Remove the ContainerRuntimeEndpoint field from kubelet's config
rmoveContainerRuntimeEndpointFromKubelet()
// Write the instance configuration for the kubelet (using the bootstrap token credentials) to disk so the kubelet can start
if err := kubeletphase.WriteInstanceConfigToDisk(&initCfg.ClusterConfiguration, data.KubeletDir(), data.PatchesDir(), data.OutputWriter()); err != nil {
return err
}
}
```
* No longer need to add the `kubeadm.alpha.kubernetes.io/cri-socket` annotation: cmd/kubeadm/app/cmd/phases/join/kubelet.go:227
```diff=227
- klog.V(1).Infoln("[kubelet-start] preserving the crisocket information for the node")
- if err := patchnodephase.AnnotateCRISocket(client, cfg.NodeRegistration.Name, cfg.NodeRegistration.CRISocket); err != nil {
- return errors.Wrap(err, "error uploading crisocket")
- }
```
kubeadm reset:
* There is no need to do anything, as `kubelet-instace-config.yml` will be cleaned up with the deletion of ``/var/lib/kubelet`
kubeadm upgrade:
* In v1.30-1.31, when kubeadm upgrade apply, we will read the cri annotaion (if there is no annotaion, we will detect it automatically) and patch it to the global configuration. The kubeadm upgrade node is similar in that it never changes the global configuration.
* In v1.32, kubeadm upgrade apply will no longer read cri.