mirror of https://github.com/k3s-io/k3s
kubeadm-annotate-cri
parent
4c72cfa135
commit
44e49f00bc
|
@ -38,6 +38,7 @@ go_library(
|
|||
"//cmd/kubeadm/app/phases/kubeconfig:go_default_library",
|
||||
"//cmd/kubeadm/app/phases/kubelet:go_default_library",
|
||||
"//cmd/kubeadm/app/phases/markmaster:go_default_library",
|
||||
"//cmd/kubeadm/app/phases/patchnode:go_default_library",
|
||||
"//cmd/kubeadm/app/phases/selfhosting:go_default_library",
|
||||
"//cmd/kubeadm/app/phases/upgrade:go_default_library",
|
||||
"//cmd/kubeadm/app/phases/uploadconfig:go_default_library",
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||
"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/preflight"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
|
||||
|
@ -61,6 +62,14 @@ var (
|
|||
kubeadm alpha phase kubelet config upload --config kubeadm.yaml
|
||||
`)
|
||||
|
||||
kubeletConfigAnnotateCRILongDesc = normalizer.LongDesc(`
|
||||
Adds an annotation to the current node with the CRI socket specified in the kubeadm InitConfiguration object.
|
||||
` + cmdutil.AlphaDisclaimer)
|
||||
|
||||
kubeletConfigAnnotateCRIExample = normalizer.Examples(`
|
||||
kubeadm alpha phase kubelet config annotate-cri --config kubeadm.yaml
|
||||
`)
|
||||
|
||||
kubeletConfigDownloadLongDesc = normalizer.LongDesc(`
|
||||
Downloads the kubelet configuration from a ConfigMap of the form "kubelet-config-1.X" in the cluster,
|
||||
where X is the minor version of the kubelet. Either kubeadm autodetects the kubelet version by exec-ing
|
||||
|
@ -177,6 +186,7 @@ func NewCmdKubeletConfig() *cobra.Command {
|
|||
}
|
||||
|
||||
cmd.AddCommand(NewCmdKubeletConfigUpload())
|
||||
cmd.AddCommand(NewCmdKubeletAnnotateCRI())
|
||||
cmd.AddCommand(NewCmdKubeletConfigDownload())
|
||||
cmd.AddCommand(NewCmdKubeletConfigWriteToDisk())
|
||||
cmd.AddCommand(NewCmdKubeletConfigEnableDynamic())
|
||||
|
@ -222,6 +232,45 @@ func NewCmdKubeletConfigUpload() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// NewCmdKubeletAnnotateCRI calls cobra.Command for annotating the node with the given crisocket
|
||||
func NewCmdKubeletAnnotateCRI() *cobra.Command {
|
||||
cfg := &kubeadmapiv1alpha3.InitConfiguration{}
|
||||
var cfgPath string
|
||||
kubeConfigFile := constants.GetAdminKubeConfigPath()
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "annotate-cri",
|
||||
Short: "annotates the node with the given crisocket",
|
||||
Long: kubeletConfigAnnotateCRILongDesc,
|
||||
Example: kubeletConfigAnnotateCRIExample,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(cfgPath) == 0 {
|
||||
kubeadmutil.CheckErr(fmt.Errorf("The --config argument is required"))
|
||||
}
|
||||
|
||||
// KubernetesVersion is not used, but we set it explicitly to avoid the lookup
|
||||
// of the version from the internet when executing ConfigFileAndDefaultsToInternalConfig
|
||||
err := SetKubernetesVersion(nil, cfg)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
// This call returns the ready-to-use configuration based on the configuration file
|
||||
internalcfg, err := configutil.ConfigFileAndDefaultsToInternalConfig(cfgPath, cfg)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
kubeConfigFile = cmdutil.FindExistingKubeConfig(kubeConfigFile)
|
||||
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile)
|
||||
kubeadmutil.CheckErr(err)
|
||||
|
||||
err = patchnodephase.AnnotateCRISocket(client, internalcfg.NodeRegistration.Name, internalcfg.NodeRegistration.CRISocket)
|
||||
kubeadmutil.CheckErr(err)
|
||||
},
|
||||
}
|
||||
|
||||
options.AddKubeConfigFlag(cmd.Flags(), &kubeConfigFile)
|
||||
options.AddConfigFlag(cmd.Flags(), &cfgPath)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// NewCmdKubeletConfigDownload calls cobra.Command for downloading the kubelet configuration from the kubelet-config-1.X ConfigMap in the cluster
|
||||
func NewCmdKubeletConfigDownload() *cobra.Command {
|
||||
var kubeletVersionStr string
|
||||
|
|
|
@ -47,6 +47,7 @@ docs/admin/kubeadm_alpha_phase_kubeconfig_scheduler.md
|
|||
docs/admin/kubeadm_alpha_phase_kubeconfig_user.md
|
||||
docs/admin/kubeadm_alpha_phase_kubelet.md
|
||||
docs/admin/kubeadm_alpha_phase_kubelet_config.md
|
||||
docs/admin/kubeadm_alpha_phase_kubelet_config_annotate-cri.md
|
||||
docs/admin/kubeadm_alpha_phase_kubelet_config_download.md
|
||||
docs/admin/kubeadm_alpha_phase_kubelet_config_enable-dynamic.md
|
||||
docs/admin/kubeadm_alpha_phase_kubelet_config_upload.md
|
||||
|
@ -130,6 +131,7 @@ docs/man/man1/kubeadm-alpha-phase-kubeconfig-kubelet.1
|
|||
docs/man/man1/kubeadm-alpha-phase-kubeconfig-scheduler.1
|
||||
docs/man/man1/kubeadm-alpha-phase-kubeconfig-user.1
|
||||
docs/man/man1/kubeadm-alpha-phase-kubeconfig.1
|
||||
docs/man/man1/kubeadm-alpha-phase-kubelet-config-annotate-cri.1
|
||||
docs/man/man1/kubeadm-alpha-phase-kubelet-config-download.1
|
||||
docs/man/man1/kubeadm-alpha-phase-kubelet-config-enable-dynamic.1
|
||||
docs/man/man1/kubeadm-alpha-phase-kubelet-config-upload.1
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
This file is autogenerated, but we've stopped checking such files into the
|
||||
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
|
||||
populate this file.
|
|
@ -0,0 +1,3 @@
|
|||
This file is autogenerated, but we've stopped checking such files into the
|
||||
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
|
||||
populate this file.
|
Loading…
Reference in New Issue