mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 20:50:24 +00:00
Stratify certificate loading and self-sign cert generation
This removes all dependencies on Config during cert generation, only operating on ServerRunOptions. This way we get rid of the repeated call of Config.Complete and cleanly stratify the GenericApiServer bootstrapping.
This commit is contained in:
committed by
Dr. Stefan Schimanski
parent
7d1a7eae50
commit
5b1d45bc15
@@ -36,6 +36,8 @@ import (
|
||||
|
||||
// Install the testgroup API
|
||||
_ "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/test_apis/testgroup/install"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -93,20 +95,21 @@ func (serverOptions *ServerRunOptions) Run(stopCh <-chan struct{}) error {
|
||||
if errs := serverOptions.InsecureServing.Validate("insecure-port"); len(errs) > 0 {
|
||||
return utilerrors.NewAggregate(errs)
|
||||
}
|
||||
if err := serverOptions.SecureServing.MaybeDefaultWithSelfSignedCerts(serverOptions.GenericServerRunOptions.AdvertiseAddress.String()); err != nil {
|
||||
glog.Fatalf("Error creating self-signed certificates: %v", err)
|
||||
}
|
||||
|
||||
config := genericapiserver.NewConfig().
|
||||
config, err := genericapiserver.NewConfig().
|
||||
ApplyOptions(serverOptions.GenericServerRunOptions).
|
||||
ApplySecureServingOptions(serverOptions.SecureServing).
|
||||
ApplyInsecureServingOptions(serverOptions.InsecureServing).
|
||||
ApplyAuthenticationOptions(serverOptions.Authentication).
|
||||
Complete()
|
||||
if err := config.MaybeGenerateServingCerts(); err != nil {
|
||||
// this wasn't treated as fatal for this process before
|
||||
fmt.Printf("Error creating cert: %v", err)
|
||||
ApplySecureServingOptions(serverOptions.SecureServing)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to configure https: %s", err)
|
||||
}
|
||||
|
||||
config.Authorizer = authorizer.NewAlwaysAllowAuthorizer()
|
||||
s, err := config.New()
|
||||
s, err := config.Complete().New()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error in bringing up the server: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user