Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/controllers/kube-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type KubeAPIServer struct {
masterURL string
servingCAPath string
advertiseAddress string
kubeconfigPath string
}

func NewKubeAPIServer(cfg *config.Config) *KubeAPIServer {
Expand Down Expand Up @@ -115,6 +116,7 @@ func (s *KubeAPIServer) configure(ctx context.Context, cfg *config.Config) error
s.masterURL = cfg.ApiServer.URL
s.servingCAPath = cryptomaterial.ServiceAccountTokenCABundlePath(certsDir)
s.advertiseAddress = cfg.ApiServer.AdvertiseAddresses[0]
s.kubeconfigPath = cfg.KubeConfigPath(config.KubeAdmin)

namedCerts := []configv1.NamedCertificate{
{
Expand Down Expand Up @@ -182,6 +184,7 @@ func (s *KubeAPIServer) configure(ctx context.Context, cfg *config.Config) error

overrides := &kubecontrolplanev1.KubeAPIServerConfig{
APIServerArguments: map[string]kubecontrolplanev1.Arguments{
"anonymous-auth": {"false"},
"advertise-address": {s.advertiseAddress},
"audit-policy-file": {filepath.Join(config.DataDir, "/resources/kube-apiserver-audit-policies/default.yaml")},
"audit-log-maxage": {strconv.Itoa(cfg.ApiServer.AuditLog.MaxFileAge)},
Expand Down Expand Up @@ -333,15 +336,14 @@ func (s *KubeAPIServer) Run(ctx context.Context, ready chan<- struct{}, stopped
ctx, cancel := context.WithCancel(ctx)
defer cancel()

restConfig, err := clientcmd.BuildConfigFromFlags(s.masterURL, "")
restConfig, err := clientcmd.BuildConfigFromFlags(s.masterURL, s.kubeconfigPath)
if err != nil {
return err
}
if err := rest.SetKubernetesDefaults(restConfig); err != nil {
return err
}
restConfig.NegotiatedSerializer = serializer.NewCodecFactory(runtime.NewScheme())
restConfig.CAFile = s.servingCAPath

restClient, err := rest.UnversionedRESTClientFor(restConfig)
if err != nil {
Expand Down