mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #101923 from neolit123/1.22-kubeadm-add-skip-phases-v1beta3
kubeadm: add support for skipping phases in v1beta3
This commit is contained in:
commit
bf2ece7ada
@ -56,6 +56,7 @@ func fuzzInitConfiguration(obj *kubeadm.InitConfiguration, c fuzz.Continue) {
|
||||
TTL: &metav1.Duration{Duration: 1234},
|
||||
},
|
||||
}
|
||||
obj.SkipPhases = nil
|
||||
}
|
||||
|
||||
func fuzzNodeRegistration(obj *kubeadm.NodeRegistrationOptions, c fuzz.Continue) {
|
||||
@ -116,6 +117,7 @@ func fuzzJoinConfiguration(obj *kubeadm.JoinConfiguration, c fuzz.Continue) {
|
||||
TLSBootstrapToken: "qux",
|
||||
Timeout: &metav1.Duration{Duration: 1234},
|
||||
}
|
||||
obj.SkipPhases = nil
|
||||
}
|
||||
|
||||
func fuzzJoinControlPlane(obj *kubeadm.JoinControlPlane, c fuzz.Continue) {
|
||||
|
@ -57,6 +57,11 @@ type InitConfiguration struct {
|
||||
// CertificateKey sets the key with which certificates and keys are encrypted prior to being uploaded in
|
||||
// a secret in the cluster during the uploadcerts init phase.
|
||||
CertificateKey string
|
||||
|
||||
// SkipPhases is a list of phases to skip during command execution.
|
||||
// The list of phases can be obtained with the "kubeadm init --help" command.
|
||||
// The flag "--skip-phases" takes precedence over this field.
|
||||
SkipPhases []string
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@ -313,6 +318,11 @@ type JoinConfiguration struct {
|
||||
// ControlPlane defines the additional control plane instance to be deployed on the joining node.
|
||||
// If nil, no additional control plane instance will be deployed.
|
||||
ControlPlane *JoinControlPlane
|
||||
|
||||
// SkipPhases is a list of phases to skip during command execution.
|
||||
// The list of phases can be obtained with the "kubeadm join --help" command.
|
||||
// The flag "--skip-phases" takes precedence over this field.
|
||||
SkipPhases []string
|
||||
}
|
||||
|
||||
// JoinControlPlane contains elements describing an additional control plane instance to be deployed on the joining node.
|
||||
|
@ -38,3 +38,8 @@ func Convert_v1beta2_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConf
|
||||
func Convert_v1beta2_ClusterConfiguration_To_kubeadm_ClusterConfiguration(in *ClusterConfiguration, out *kubeadm.ClusterConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_v1beta2_ClusterConfiguration_To_kubeadm_ClusterConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
// Convert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration is required since v1beta2 does not have SkipPhases in JoinConfiguration
|
||||
func Convert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration(in, out, s)
|
||||
}
|
||||
|
@ -177,11 +177,6 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*kubeadm.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration(a.(*kubeadm.JoinConfiguration), b.(*JoinConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*JoinControlPlane)(nil), (*kubeadm.JoinControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta2_JoinControlPlane_To_kubeadm_JoinControlPlane(a.(*JoinControlPlane), b.(*kubeadm.JoinControlPlane), scope)
|
||||
}); err != nil {
|
||||
@ -227,6 +222,11 @@ func RegisterConversions(s *runtime.Scheme) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*kubeadm.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration(a.(*kubeadm.JoinConfiguration), b.(*JoinConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*ClusterConfiguration)(nil), (*kubeadm.ClusterConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta2_ClusterConfiguration_To_kubeadm_ClusterConfiguration(a.(*ClusterConfiguration), b.(*kubeadm.ClusterConfiguration), scope)
|
||||
}); err != nil {
|
||||
@ -646,6 +646,7 @@ func autoConvert_kubeadm_InitConfiguration_To_v1beta2_InitConfiguration(in *kube
|
||||
return err
|
||||
}
|
||||
out.CertificateKey = in.CertificateKey
|
||||
// WARNING: in.SkipPhases requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -675,14 +676,10 @@ func autoConvert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration(in *kube
|
||||
return err
|
||||
}
|
||||
out.ControlPlane = (*JoinControlPlane)(unsafe.Pointer(in.ControlPlane))
|
||||
// WARNING: in.SkipPhases requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration is an autogenerated conversion function.
|
||||
func Convert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_kubeadm_JoinConfiguration_To_v1beta2_JoinConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1beta2_JoinControlPlane_To_kubeadm_JoinControlPlane(in *JoinControlPlane, out *kubeadm.JoinControlPlane, s conversion.Scope) error {
|
||||
if err := Convert_v1beta2_APIEndpoint_To_kubeadm_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil {
|
||||
return err
|
||||
|
@ -29,6 +29,8 @@ limitations under the License.
|
||||
// DNS server type by kubeadm.
|
||||
// - Include "datapolicy" tags on the fields that hold secrets.
|
||||
// This would result in the field values to be omitted when API structures are printed with klog.
|
||||
// - Add "InitConfiguration.SkipPhases", "JoinConfiguration.SkipPhases" to allow skipping
|
||||
// a list of phases during kubeadm init/join command execution.
|
||||
//
|
||||
// Migration from old kubeadm config versions
|
||||
//
|
||||
@ -177,6 +179,8 @@ limitations under the License.
|
||||
// advertiseAddress: "10.100.0.1"
|
||||
// bindPort: 6443
|
||||
// certificateKey: "e6a2eb8581237ab72a4f494f30285ec12a9694d750b9785706a83bfcbbbd2204"
|
||||
// skipPhases:
|
||||
// - addon/kube-proxy
|
||||
// ---
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: ClusterConfiguration
|
||||
|
@ -50,6 +50,12 @@ type InitConfiguration struct {
|
||||
// CertificateKey sets the key with which certificates and keys are encrypted prior to being uploaded in
|
||||
// a secret in the cluster during the uploadcerts init phase.
|
||||
CertificateKey string `json:"certificateKey,omitempty"`
|
||||
|
||||
// SkipPhases is a list of phases to skip during command execution.
|
||||
// The list of phases can be obtained with the "kubeadm init --help" command.
|
||||
// The flag "--skip-phases" takes precedence over this field.
|
||||
// +optional
|
||||
SkipPhases []string `json:"skipPhases,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
@ -290,6 +296,12 @@ type JoinConfiguration struct {
|
||||
// ControlPlane defines the additional control plane instance to be deployed on the joining node.
|
||||
// If nil, no additional control plane instance will be deployed.
|
||||
ControlPlane *JoinControlPlane `json:"controlPlane,omitempty"`
|
||||
|
||||
// SkipPhases is a list of phases to skip during command execution.
|
||||
// The list of phases can be obtained with the "kubeadm join --help" command.
|
||||
// The flag "--skip-phases" takes precedence over this field.
|
||||
// +optional
|
||||
SkipPhases []string `json:"skipPhases,omitempty"`
|
||||
}
|
||||
|
||||
// JoinControlPlane contains elements describing an additional control plane instance to be deployed on the joining node.
|
||||
|
@ -626,6 +626,7 @@ func autoConvert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in *Init
|
||||
return err
|
||||
}
|
||||
out.CertificateKey = in.CertificateKey
|
||||
out.SkipPhases = *(*[]string)(unsafe.Pointer(&in.SkipPhases))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -639,6 +640,7 @@ func autoConvert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in *kube
|
||||
return err
|
||||
}
|
||||
out.CertificateKey = in.CertificateKey
|
||||
out.SkipPhases = *(*[]string)(unsafe.Pointer(&in.SkipPhases))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -651,6 +653,7 @@ func autoConvert_v1beta3_JoinConfiguration_To_kubeadm_JoinConfiguration(in *Join
|
||||
return err
|
||||
}
|
||||
out.ControlPlane = (*kubeadm.JoinControlPlane)(unsafe.Pointer(in.ControlPlane))
|
||||
out.SkipPhases = *(*[]string)(unsafe.Pointer(&in.SkipPhases))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -668,6 +671,7 @@ func autoConvert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in *kube
|
||||
return err
|
||||
}
|
||||
out.ControlPlane = (*JoinControlPlane)(unsafe.Pointer(in.ControlPlane))
|
||||
out.SkipPhases = *(*[]string)(unsafe.Pointer(&in.SkipPhases))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -368,6 +368,11 @@ func (in *InitConfiguration) DeepCopyInto(out *InitConfiguration) {
|
||||
}
|
||||
in.NodeRegistration.DeepCopyInto(&out.NodeRegistration)
|
||||
out.LocalAPIEndpoint = in.LocalAPIEndpoint
|
||||
if in.SkipPhases != nil {
|
||||
in, out := &in.SkipPhases, &out.SkipPhases
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -400,6 +405,11 @@ func (in *JoinConfiguration) DeepCopyInto(out *JoinConfiguration) {
|
||||
*out = new(JoinControlPlane)
|
||||
**out = **in
|
||||
}
|
||||
if in.SkipPhases != nil {
|
||||
in, out := &in.SkipPhases, &out.SkipPhases
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -398,6 +398,11 @@ func (in *InitConfiguration) DeepCopyInto(out *InitConfiguration) {
|
||||
}
|
||||
in.NodeRegistration.DeepCopyInto(&out.NodeRegistration)
|
||||
out.LocalAPIEndpoint = in.LocalAPIEndpoint
|
||||
if in.SkipPhases != nil {
|
||||
in, out := &in.SkipPhases, &out.SkipPhases
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -430,6 +435,11 @@ func (in *JoinConfiguration) DeepCopyInto(out *JoinConfiguration) {
|
||||
*out = new(JoinControlPlane)
|
||||
**out = **in
|
||||
}
|
||||
if in.SkipPhases != nil {
|
||||
in, out := &in.SkipPhases, &out.SkipPhases
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,15 @@ func newCmdInit(out io.Writer, initOptions *initOptions) *cobra.Command {
|
||||
// sets the data builder function, that will be used by the runner
|
||||
// both when running the entire workflow or single phases
|
||||
initRunner.SetDataInitializer(func(cmd *cobra.Command, args []string) (workflow.RunData, error) {
|
||||
return newInitData(cmd, args, initOptions, out)
|
||||
data, err := newInitData(cmd, args, initOptions, out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// If the flag for skipping phases was empty, use the values from config
|
||||
if len(initRunner.Options.SkipPhases) == 0 {
|
||||
initRunner.Options.SkipPhases = data.cfg.SkipPhases
|
||||
}
|
||||
return data, nil
|
||||
})
|
||||
|
||||
// binds the Runner to kubeadm init command by altering
|
||||
|
@ -213,7 +213,15 @@ func newCmdJoin(out io.Writer, joinOptions *joinOptions) *cobra.Command {
|
||||
// sets the data builder function, that will be used by the runner
|
||||
// both when running the entire workflow or single phases
|
||||
joinRunner.SetDataInitializer(func(cmd *cobra.Command, args []string) (workflow.RunData, error) {
|
||||
return newJoinData(cmd, args, joinOptions, out, kubeadmconstants.GetAdminKubeConfigPath())
|
||||
data, err := newJoinData(cmd, args, joinOptions, out, kubeadmconstants.GetAdminKubeConfigPath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// If the flag for skipping phases was empty, use the values from config
|
||||
if len(joinRunner.Options.SkipPhases) == 0 {
|
||||
joinRunner.Options.SkipPhases = data.cfg.SkipPhases
|
||||
}
|
||||
return data, nil
|
||||
})
|
||||
|
||||
// binds the Runner to kubeadm join command by altering
|
||||
|
Loading…
Reference in New Issue
Block a user