K8s: resolve crash due to looking up aggregation config when running in a K8s environment (#82125)

K8s: apply authn options only in dev mode - resolves crash due to looking up aggregation config
This commit is contained in:
Charandas
2024-02-07 16:43:07 -08:00
committed by GitHub
parent 1ecf9faded
commit 117a4b4b0a

View File

@@ -55,8 +55,12 @@ func (o *Options) Validate() []error {
return errs
}
if errs := o.RecommendedOptions.Authentication.Validate(); len(errs) != 0 {
return errs
if o.ExtraOptions.DevMode {
// NOTE: Only consider authn for dev mode - resolves the failure due to missing extension apiserver auth-config
// in parent k8s
if errs := o.RecommendedOptions.Authentication.Validate(); len(errs) != 0 {
return errs
}
}
if o.StorageOptions.StorageType == StorageTypeEtcd {
@@ -83,8 +87,12 @@ func (o *Options) ApplyTo(serverConfig *genericapiserver.RecommendedConfig) erro
return err
}
if err := o.RecommendedOptions.Authentication.ApplyTo(&serverConfig.Authentication, serverConfig.SecureServing, serverConfig.OpenAPIConfig); err != nil {
return err
if o.ExtraOptions.DevMode {
// NOTE: Only consider authn for dev mode - resolves the failure due to missing extension apiserver auth-config
// in parent k8s
if err := o.RecommendedOptions.Authentication.ApplyTo(&serverConfig.Authentication, serverConfig.SecureServing, serverConfig.OpenAPIConfig); err != nil {
return err
}
}
if !o.ExtraOptions.DevMode {