Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: annotate CRI socket on kubelet-finalize phase #85419

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions cmd/kubeadm/app/cmd/phases/init/kubeletfinalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
patchnodephase "k8s.io/kubernetes/cmd/kubeadm/app/phases/patchnode"
)

var (
Expand All @@ -53,6 +54,12 @@ func NewKubeletFinalizePhase() workflow.Phase {
Example: kubeletFinalizePhaseExample,
RunAllSiblings: true,
},
{
Name: "annotate-cri-socket",
Short: "Annotate node with the CRI socket",
InheritFlags: []string{options.NodeName, options.NodeCRISocket, options.CfgPath, options.KubeconfigPath},
Run: runAnnotateCRISocket,
},
{
Name: "experimental-cert-rotation",
Short: "Enable kubelet client certificate rotation",
Expand All @@ -63,6 +70,23 @@ func NewKubeletFinalizePhase() workflow.Phase {
}
}

// runAnnotateCRISocket annotates the current node with the CRI socket location.
func runAnnotateCRISocket(c workflow.RunData) error {
data, ok := c.(InitData)
if !ok {
return errors.New("annotate-cri-socket phase invoked with an invalid data struct")
}
klog.V(1).Infoln("[kubelet-finalize] preserving the crisocket information for the node")
client, err := data.Client()
if err != nil {
return errors.New("failed to create a clientset")
}
if err := patchnodephase.AnnotateCRISocket(client, data.Cfg().NodeRegistration.Name, data.Cfg().NodeRegistration.CRISocket); err != nil {
return errors.Wrap(err, "error uploading crisocket")
}
return nil
}

// runKubeletFinalizeCertRotation detects if the kubelet certificate rotation is enabled
// and updates the kubelet.conf file to point to a rotatable certificate and key for the
// Node user.
Expand Down
5 changes: 0 additions & 5 deletions cmd/kubeadm/app/cmd/phases/init/uploadconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeletphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet"
patchnodephase "k8s.io/kubernetes/cmd/kubeadm/app/phases/patchnode"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig"
)

Expand Down Expand Up @@ -124,10 +123,6 @@ func runUploadKubeletConfig(c workflow.RunData) error {
return errors.Wrap(err, "error creating kubelet configuration ConfigMap")
}

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")
}
return nil
}

Expand Down