mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 20:50:24 +00:00
remove some options from mega-struct
This commit is contained in:
@@ -55,22 +55,48 @@ func newStorageFactory() genericapiserver.StorageFactory {
|
||||
return storageFactory
|
||||
}
|
||||
|
||||
func NewServerRunOptions() *genericoptions.ServerRunOptions {
|
||||
serverOptions := genericoptions.NewServerRunOptions().WithEtcdOptions().WithSecureServingOptions().WithInsecureServingOptions()
|
||||
serverOptions.InsecureServing.BindPort = InsecurePort
|
||||
return serverOptions
|
||||
type ServerRunOptions struct {
|
||||
GenericServerRunOptions *genericoptions.ServerRunOptions
|
||||
Etcd *genericoptions.EtcdOptions
|
||||
SecureServing *genericoptions.SecureServingOptions
|
||||
InsecureServing *genericoptions.ServingOptions
|
||||
}
|
||||
|
||||
func Run(serverOptions *genericoptions.ServerRunOptions, stopCh <-chan struct{}) error {
|
||||
func NewServerRunOptions() *ServerRunOptions {
|
||||
s := ServerRunOptions{
|
||||
GenericServerRunOptions: genericoptions.NewServerRunOptions(),
|
||||
Etcd: genericoptions.NewEtcdOptions(),
|
||||
SecureServing: genericoptions.NewSecureServingOptions(),
|
||||
InsecureServing: genericoptions.NewInsecureServingOptions(),
|
||||
}
|
||||
s.InsecureServing.BindPort = InsecurePort
|
||||
s.SecureServing.ServingOptions.BindPort = SecurePort
|
||||
|
||||
return &s
|
||||
}
|
||||
|
||||
func (serverOptions *ServerRunOptions) Run(stopCh <-chan struct{}) error {
|
||||
// Set ServiceClusterIPRange
|
||||
_, serviceClusterIPRange, _ := net.ParseCIDR("10.0.0.0/24")
|
||||
serverOptions.ServiceClusterIPRange = *serviceClusterIPRange
|
||||
serverOptions.GenericServerRunOptions.ServiceClusterIPRange = *serviceClusterIPRange
|
||||
serverOptions.Etcd.StorageConfig.ServerList = []string{"http://127.0.0.1:2379"}
|
||||
genericvalidation.ValidateRunOptions(serverOptions)
|
||||
|
||||
genericvalidation.ValidateRunOptions(serverOptions.GenericServerRunOptions)
|
||||
if errs := serverOptions.Etcd.Validate(); len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
config := genericapiserver.NewConfig().ApplyOptions(serverOptions).Complete()
|
||||
if errs := serverOptions.SecureServing.Validate(); len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
if errs := serverOptions.InsecureServing.Validate("insecure-port"); len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
config := genericapiserver.NewConfig().
|
||||
ApplyOptions(serverOptions.GenericServerRunOptions).
|
||||
ApplySecureServingOptions(serverOptions.SecureServing).
|
||||
ApplyInsecureServingOptions(serverOptions.InsecureServing).
|
||||
Complete()
|
||||
if err := config.MaybeGenerateServingCerts(); err != nil {
|
||||
// this wasn't treated as fatal for this process before
|
||||
fmt.Printf("Error creating cert: %v", err)
|
||||
|
@@ -30,10 +30,14 @@ func main() {
|
||||
|
||||
// Parse command line flags.
|
||||
serverRunOptions.AddUniversalFlags(pflag.CommandLine)
|
||||
serverRunOptions.AddEtcdStorageFlags(pflag.CommandLine)
|
||||
serverRunOptions.Etcd.AddFlags(pflag.CommandLine)
|
||||
serverRunOptions.SecureServing.AddFlags(pflag.CommandLine)
|
||||
serverRunOptions.SecureServing.AddDeprecatedFlags(pflag.CommandLine)
|
||||
serverRunOptions.InsecureServing.AddFlags(pflag.CommandLine)
|
||||
serverRunOptions.InsecureServing.AddDeprecatedFlags(pflag.CommandLine)
|
||||
flag.InitFlags()
|
||||
|
||||
if err := apiserver.Run(serverRunOptions, wait.NeverStop); err != nil {
|
||||
if err := serverRunOptions.Run(wait.NeverStop); err != nil {
|
||||
glog.Fatalf("Error in bringing up the server: %v", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user