mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #51412 from luxas/kubeadm_feature_gates
Automatic merge from submit-queue kubeadm: Rename FeatureFlags to FeatureGates **What this PR does / why we need it**: Automatic rename from `FeatureFlags` to `FeatureGates`, as I noticed that's the real name for this feature. This is for consistency in the API and generally in the code. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` @kubernetes/sig-cluster-lifecycle-pr-reviews @fabriziopandini @jamiehannaford
This commit is contained in:
commit
64e03165bf
@ -42,7 +42,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
|||||||
obj.ImageRepository = "foo"
|
obj.ImageRepository = "foo"
|
||||||
obj.CIImageRepository = ""
|
obj.CIImageRepository = ""
|
||||||
obj.UnifiedControlPlaneImage = "foo"
|
obj.UnifiedControlPlaneImage = "foo"
|
||||||
obj.FeatureFlags = map[string]bool{}
|
obj.FeatureGates = map[string]bool{}
|
||||||
},
|
},
|
||||||
func(obj *kubeadm.NodeConfiguration, c fuzz.Continue) {
|
func(obj *kubeadm.NodeConfiguration, c fuzz.Continue) {
|
||||||
c.FuzzNoCustom(obj)
|
c.FuzzNoCustom(obj)
|
||||||
|
@ -57,8 +57,8 @@ type MasterConfiguration struct {
|
|||||||
// UnifiedControlPlaneImage specifies if a specific container image should be used for all control plane components
|
// UnifiedControlPlaneImage specifies if a specific container image should be used for all control plane components
|
||||||
UnifiedControlPlaneImage string
|
UnifiedControlPlaneImage string
|
||||||
|
|
||||||
// FeatureFlags enabled by the user
|
// FeatureGates enabled by the user
|
||||||
FeatureFlags map[string]bool
|
FeatureGates map[string]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
|
@ -52,8 +52,8 @@ type MasterConfiguration struct {
|
|||||||
// UnifiedControlPlaneImage specifies if a specific container image should be used for all control plane components
|
// UnifiedControlPlaneImage specifies if a specific container image should be used for all control plane components
|
||||||
UnifiedControlPlaneImage string `json:"unifiedControlPlaneImage"`
|
UnifiedControlPlaneImage string `json:"unifiedControlPlaneImage"`
|
||||||
|
|
||||||
// FeatureFlags enabled by the user
|
// FeatureGates enabled by the user
|
||||||
FeatureFlags map[string]bool `json:"featureFlags"`
|
FeatureGates map[string]bool `json:"featureGates"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
|
@ -128,7 +128,7 @@ func autoConvert_v1alpha1_MasterConfiguration_To_kubeadm_MasterConfiguration(in
|
|||||||
out.CertificatesDir = in.CertificatesDir
|
out.CertificatesDir = in.CertificatesDir
|
||||||
out.ImageRepository = in.ImageRepository
|
out.ImageRepository = in.ImageRepository
|
||||||
out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage
|
out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage
|
||||||
out.FeatureFlags = *(*map[string]bool)(unsafe.Pointer(&in.FeatureFlags))
|
out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ func autoConvert_kubeadm_MasterConfiguration_To_v1alpha1_MasterConfiguration(in
|
|||||||
out.ImageRepository = in.ImageRepository
|
out.ImageRepository = in.ImageRepository
|
||||||
// INFO: in.CIImageRepository opted out of conversion generation
|
// INFO: in.CIImageRepository opted out of conversion generation
|
||||||
out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage
|
out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage
|
||||||
out.FeatureFlags = *(*map[string]bool)(unsafe.Pointer(&in.FeatureFlags))
|
out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ func (in *MasterConfiguration) DeepCopyInto(out *MasterConfiguration) {
|
|||||||
*out = make([]string, len(*in))
|
*out = make([]string, len(*in))
|
||||||
copy(*out, *in)
|
copy(*out, *in)
|
||||||
}
|
}
|
||||||
if in.FeatureFlags != nil {
|
if in.FeatureGates != nil {
|
||||||
in, out := &in.FeatureFlags, &out.FeatureFlags
|
in, out := &in.FeatureGates, &out.FeatureGates
|
||||||
*out = make(map[string]bool, len(*in))
|
*out = make(map[string]bool, len(*in))
|
||||||
for key, val := range *in {
|
for key, val := range *in {
|
||||||
(*out)[key] = val
|
(*out)[key] = val
|
||||||
|
@ -68,7 +68,7 @@ func ValidateMasterConfiguration(c *kubeadm.MasterConfiguration) field.ErrorList
|
|||||||
allErrs = append(allErrs, ValidateAbsolutePath(c.CertificatesDir, field.NewPath("certificates-dir"))...)
|
allErrs = append(allErrs, ValidateAbsolutePath(c.CertificatesDir, field.NewPath("certificates-dir"))...)
|
||||||
allErrs = append(allErrs, ValidateNodeName(c.NodeName, field.NewPath("node-name"))...)
|
allErrs = append(allErrs, ValidateNodeName(c.NodeName, field.NewPath("node-name"))...)
|
||||||
allErrs = append(allErrs, ValidateToken(c.Token, field.NewPath("token"))...)
|
allErrs = append(allErrs, ValidateToken(c.Token, field.NewPath("token"))...)
|
||||||
allErrs = append(allErrs, ValidateFeatureFlags(c.FeatureFlags, field.NewPath("feature-flags"))...)
|
allErrs = append(allErrs, ValidateFeatureGates(c.FeatureGates, field.NewPath("feature-gates"))...)
|
||||||
allErrs = append(allErrs, ValidateAPIEndpoint(c, field.NewPath("api-endpoint"))...)
|
allErrs = append(allErrs, ValidateAPIEndpoint(c, field.NewPath("api-endpoint"))...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
@ -297,14 +297,14 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateFeatureFlags(featureFlags map[string]bool, fldPath *field.Path) field.ErrorList {
|
func ValidateFeatureGates(featureGates map[string]bool, fldPath *field.Path) field.ErrorList {
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
validFeatures := features.Keys(features.InitFeatureGates)
|
validFeatures := features.Keys(features.InitFeatureGates)
|
||||||
|
|
||||||
// check valid feature names are provided
|
// check valid feature names are provided
|
||||||
for k := range featureFlags {
|
for k := range featureGates {
|
||||||
if !features.Supports(features.InitFeatureGates, k) {
|
if !features.Supports(features.InitFeatureGates, k) {
|
||||||
allErrs = append(allErrs, field.Invalid(fldPath, featureFlags,
|
allErrs = append(allErrs, field.Invalid(fldPath, featureGates,
|
||||||
fmt.Sprintf("%s is not a valid feature name. Valid features are: %s", k, validFeatures)))
|
fmt.Sprintf("%s is not a valid feature name. Valid features are: %s", k, validFeatures)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,10 +436,10 @@ func TestValidateMixedArguments(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateFeatureFlags(t *testing.T) {
|
func TestValidateFeatureGates(t *testing.T) {
|
||||||
type featureFlag map[string]bool
|
type featureFlag map[string]bool
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
featureFlags featureFlag
|
featureGates featureFlag
|
||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{featureFlag{"SelfHosting": true}, true},
|
{featureFlag{"SelfHosting": true}, true},
|
||||||
@ -449,10 +449,10 @@ func TestValidateFeatureFlags(t *testing.T) {
|
|||||||
{featureFlag{"Foo": true}, false},
|
{featureFlag{"Foo": true}, false},
|
||||||
}
|
}
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
actual := ValidateFeatureFlags(rt.featureFlags, nil)
|
actual := ValidateFeatureGates(rt.featureGates, nil)
|
||||||
if (len(actual) == 0) != rt.expected {
|
if (len(actual) == 0) != rt.expected {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"failed featureFlags:\n\texpected: %t\n\t actual: %t",
|
"failed featureGates:\n\texpected: %t\n\t actual: %t",
|
||||||
rt.expected,
|
rt.expected,
|
||||||
(len(actual) == 0),
|
(len(actual) == 0),
|
||||||
)
|
)
|
||||||
|
@ -145,8 +145,8 @@ func (in *MasterConfiguration) DeepCopyInto(out *MasterConfiguration) {
|
|||||||
*out = make([]string, len(*in))
|
*out = make([]string, len(*in))
|
||||||
copy(*out, *in)
|
copy(*out, *in)
|
||||||
}
|
}
|
||||||
if in.FeatureFlags != nil {
|
if in.FeatureGates != nil {
|
||||||
in, out := &in.FeatureFlags, &out.FeatureFlags
|
in, out := &in.FeatureGates, &out.FeatureGates
|
||||||
*out = make(map[string]bool, len(*in))
|
*out = make(map[string]bool, len(*in))
|
||||||
for key, val := range *in {
|
for key, val := range *in {
|
||||||
(*out)[key] = val
|
(*out)[key] = val
|
||||||
|
@ -130,7 +130,7 @@ func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.C
|
|||||||
cfg := &kubeadmapiext.MasterConfiguration{}
|
cfg := &kubeadmapiext.MasterConfiguration{}
|
||||||
api.Scheme.Default(cfg)
|
api.Scheme.Default(cfg)
|
||||||
|
|
||||||
var featureFlagsString string
|
var featureGatesString string
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "from-flags",
|
Use: "from-flags",
|
||||||
@ -144,7 +144,7 @@ func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.C
|
|||||||
`), metav1.NamespaceSystem, constants.MasterConfigurationConfigMap),
|
`), metav1.NamespaceSystem, constants.MasterConfigurationConfigMap),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
if cfg.FeatureFlags, err = features.NewFeatureGate(&features.InitFeatureGates, featureFlagsString); err != nil {
|
if cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString); err != nil {
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.C
|
|||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
AddInitConfigFlags(cmd.PersistentFlags(), cfg, &featureFlagsString)
|
AddInitConfigFlags(cmd.PersistentFlags(), cfg, &featureGatesString)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,14 +92,14 @@ func NewCmdInit(out io.Writer) *cobra.Command {
|
|||||||
var skipPreFlight bool
|
var skipPreFlight bool
|
||||||
var skipTokenPrint bool
|
var skipTokenPrint bool
|
||||||
var dryRun bool
|
var dryRun bool
|
||||||
var featureFlagsString string
|
var featureGatesString string
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "init",
|
Use: "init",
|
||||||
Short: "Run this in order to set up the Kubernetes master",
|
Short: "Run this in order to set up the Kubernetes master",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
if cfg.FeatureFlags, err = features.NewFeatureGate(&features.InitFeatureGates, featureFlagsString); err != nil {
|
if cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString); err != nil {
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,14 +120,14 @@ func NewCmdInit(out io.Writer) *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInitConfigFlags(cmd.PersistentFlags(), cfg, &featureFlagsString)
|
AddInitConfigFlags(cmd.PersistentFlags(), cfg, &featureGatesString)
|
||||||
AddInitOtherFlags(cmd.PersistentFlags(), &cfgPath, &skipPreFlight, &skipTokenPrint, &dryRun)
|
AddInitOtherFlags(cmd.PersistentFlags(), &cfgPath, &skipPreFlight, &skipTokenPrint, &dryRun)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddInitConfigFlags adds init flags bound to the config to the specified flagset
|
// AddInitConfigFlags adds init flags bound to the config to the specified flagset
|
||||||
func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiext.MasterConfiguration, featureFlagsString *string) {
|
func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiext.MasterConfiguration, featureGatesString *string) {
|
||||||
flagSet.StringVar(
|
flagSet.StringVar(
|
||||||
&cfg.API.AdvertiseAddress, "apiserver-advertise-address", cfg.API.AdvertiseAddress,
|
&cfg.API.AdvertiseAddress, "apiserver-advertise-address", cfg.API.AdvertiseAddress,
|
||||||
"The IP address the API Server will advertise it's listening on. 0.0.0.0 means the default network interface's address.",
|
"The IP address the API Server will advertise it's listening on. 0.0.0.0 means the default network interface's address.",
|
||||||
@ -172,7 +172,7 @@ func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiext.MasterConfigur
|
|||||||
&cfg.TokenTTL, "token-ttl", cfg.TokenTTL,
|
&cfg.TokenTTL, "token-ttl", cfg.TokenTTL,
|
||||||
"The duration before the bootstrap token is automatically deleted. 0 means 'never expires'.",
|
"The duration before the bootstrap token is automatically deleted. 0 means 'never expires'.",
|
||||||
)
|
)
|
||||||
flagSet.StringVar(featureFlagsString, "feature-gates", *featureFlagsString, "A set of key=value pairs that describe feature gates for various features. "+
|
flagSet.StringVar(featureGatesString, "feature-gates", *featureGatesString, "A set of key=value pairs that describe feature gates for various features. "+
|
||||||
"Options are:\n"+strings.Join(features.KnownFeatures(&features.InitFeatureGates), "\n"))
|
"Options are:\n"+strings.Join(features.KnownFeatures(&features.InitFeatureGates), "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ func (i *Init) Run(out io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PHASE 7: Make the control plane self-hosted if feature gate is enabled
|
// PHASE 7: Make the control plane self-hosted if feature gate is enabled
|
||||||
if features.Enabled(i.cfg.FeatureFlags, features.SelfHosting) {
|
if features.Enabled(i.cfg.FeatureGates, features.SelfHosting) {
|
||||||
// Temporary control plane is up, now we create our self hosted control
|
// Temporary control plane is up, now we create our self hosted control
|
||||||
// plane components and remove the static manifests:
|
// plane components and remove the static manifests:
|
||||||
fmt.Println("[self-hosted] Creating self-hosted control plane...")
|
fmt.Println("[self-hosted] Creating self-hosted control plane...")
|
||||||
|
@ -56,7 +56,7 @@ func getSelfhostingSubCommand() *cobra.Command {
|
|||||||
// Default values for the cobra help text
|
// Default values for the cobra help text
|
||||||
api.Scheme.Default(cfg)
|
api.Scheme.Default(cfg)
|
||||||
|
|
||||||
var cfgPath, kubeConfigFile, featureFlagsString string
|
var cfgPath, kubeConfigFile, featureGatesString string
|
||||||
|
|
||||||
// Creates the UX Command
|
// Creates the UX Command
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
@ -65,7 +65,7 @@ func getSelfhostingSubCommand() *cobra.Command {
|
|||||||
Short: "Converts a Static Pod-hosted control plane into a self-hosted one.",
|
Short: "Converts a Static Pod-hosted control plane into a self-hosted one.",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
if cfg.FeatureFlags, err = features.NewFeatureGate(&features.InitFeatureGates, featureFlagsString); err != nil {
|
if cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString); err != nil {
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ func getSelfhostingSubCommand() *cobra.Command {
|
|||||||
// flags bound to the configuration object
|
// flags bound to the configuration object
|
||||||
cmd.Flags().StringVar(&cfg.CertificatesDir, "cert-dir", cfg.CertificatesDir, `The path where certificates are stored`)
|
cmd.Flags().StringVar(&cfg.CertificatesDir, "cert-dir", cfg.CertificatesDir, `The path where certificates are stored`)
|
||||||
cmd.Flags().StringVar(&cfgPath, "config", cfgPath, "Path to kubeadm config file (WARNING: Usage of a configuration file is experimental)")
|
cmd.Flags().StringVar(&cfgPath, "config", cfgPath, "Path to kubeadm config file (WARNING: Usage of a configuration file is experimental)")
|
||||||
cmd.Flags().StringVar(&featureFlagsString, "feature-gates", featureFlagsString, "A set of key=value pairs that describe feature gates for various features."+
|
cmd.Flags().StringVar(&featureGatesString, "feature-gates", featureGatesString, "A set of key=value pairs that describe feature gates for various features."+
|
||||||
"Options are:\n"+strings.Join(features.KnownFeatures(&features.InitFeatureGates), "\n"))
|
"Options are:\n"+strings.Join(features.KnownFeatures(&features.InitFeatureGates), "\n"))
|
||||||
|
|
||||||
// flags that are not bound to the configuration object
|
// flags that are not bound to the configuration object
|
||||||
|
@ -55,7 +55,7 @@ func TestPrintConfiguration(t *testing.T) {
|
|||||||
extraArgs: null
|
extraArgs: null
|
||||||
image: ""
|
image: ""
|
||||||
keyFile: ""
|
keyFile: ""
|
||||||
featureFlags: null
|
featureGates: null
|
||||||
imageRepository: ""
|
imageRepository: ""
|
||||||
kubernetesVersion: v1.7.1
|
kubernetesVersion: v1.7.1
|
||||||
networking:
|
networking:
|
||||||
@ -94,7 +94,7 @@ func TestPrintConfiguration(t *testing.T) {
|
|||||||
extraArgs: null
|
extraArgs: null
|
||||||
image: ""
|
image: ""
|
||||||
keyFile: ""
|
keyFile: ""
|
||||||
featureFlags: null
|
featureGates: null
|
||||||
imageRepository: ""
|
imageRepository: ""
|
||||||
kubernetesVersion: v1.7.1
|
kubernetesVersion: v1.7.1
|
||||||
networking:
|
networking:
|
||||||
|
@ -63,7 +63,7 @@ func CreateSelfHostedControlPlane(manifestsDir, kubeConfigDir string, cfg *kubea
|
|||||||
mutators := getDefaultMutators()
|
mutators := getDefaultMutators()
|
||||||
|
|
||||||
// Some extra work to be done if we should store the control plane certificates in Secrets
|
// Some extra work to be done if we should store the control plane certificates in Secrets
|
||||||
if features.Enabled(cfg.FeatureFlags, features.StoreCertsInSecrets) {
|
if features.Enabled(cfg.FeatureGates, features.StoreCertsInSecrets) {
|
||||||
|
|
||||||
// Upload the certificates and kubeconfig files from disk to the cluster as Secrets
|
// Upload the certificates and kubeconfig files from disk to the cluster as Secrets
|
||||||
if err := uploadTLSSecrets(client, cfg.CertificatesDir); err != nil {
|
if err := uploadTLSSecrets(client, cfg.CertificatesDir); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user