Skip to content

Commit

Permalink
UPSTREAM: <carry>: allows for switching KS to talk to Kube API over l…
Browse files Browse the repository at this point in the history
…ocalhost

This commit fixes some compilation issues.
  • Loading branch information
bertinatto committed Apr 11, 2023
1 parent 168b365 commit ec2e361
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/kube-controller-manager/app/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func SetUpCustomRoundTrippersForOpenShift(controllerManagerOptions *options.Kube
return nil
}

config, err := clientcmd.BuildConfigFromFlags(controllerManagerOptions.Master, controllerManagerOptions.Kubeconfig)
config, err := clientcmd.BuildConfigFromFlags(controllerManagerOptions.Master, controllerManagerOptions.Generic.ClientConnection.Kubeconfig)
if err != nil {
return err
}
Expand Down
10 changes: 7 additions & 3 deletions cmd/kube-scheduler/app/options/patch.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package options

import kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
import (
"k8s.io/klog/v2"

func LoadKubeSchedulerConfiguration(file string) (*kubeschedulerconfig.KubeSchedulerConfiguration, error) {
return loadConfigFromFile(file)
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
)

func LoadKubeSchedulerConfiguration(logger klog.Logger, file string) (*kubeschedulerconfig.KubeSchedulerConfiguration, error) {
return loadConfigFromFile(logger, file)
}
6 changes: 4 additions & 2 deletions cmd/kube-scheduler/app/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package app
import (
"time"

"k8s.io/klog/v2"

"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/component-base/metrics/legacyregistry"
Expand All @@ -12,7 +14,7 @@ import (
"github.com/openshift/library-go/pkg/monitor/health"
)

func setUpPreferredHostForOpenShift(kubeSchedulerOptions *options.Options) error {
func setUpPreferredHostForOpenShift(logger klog.Logger, kubeSchedulerOptions *options.Options) error {
if !kubeSchedulerOptions.OpenShiftContext.UnsupportedKubeAPIOverPreferredHost {
return nil
}
Expand All @@ -24,7 +26,7 @@ func setUpPreferredHostForOpenShift(kubeSchedulerOptions *options.Options) error
// if there was no kubeconfig specified we won't be able to get cluster info.
// in that case try to load the configuration and read kubeconfig directly from it if it was provided.
if len(kubeSchedulerOptions.ConfigFile) > 0 {
cfg, err := options.LoadKubeSchedulerConfiguration(kubeSchedulerOptions.ConfigFile)
cfg, err := options.LoadKubeSchedulerConfiguration(logger, kubeSchedulerOptions.ConfigFile)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/kube-scheduler/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func runCommand(cmd *cobra.Command, opts *options.Options, registryOptions ...Op
cancel()
}()

if err := setUpPreferredHostForOpenShift(opts); err != nil {
logger := klog.FromContext(ctx)
if err := setUpPreferredHostForOpenShift(logger, opts); err != nil {
return err
}

Expand Down

0 comments on commit ec2e361

Please sign in to comment.