Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ func NewConfig(options *options.CompletedOptions) (*Config, error) {
// create clients
rules := clientcmd.NewDefaultClientConfigLoadingRules()
rules.ExplicitPath = options.KubeConfig
var overrides *clientcmd.ConfigOverrides
if options.Context != "" {
overrides = &clientcmd.ConfigOverrides{
CurrentContext: options.Context,
}
}
var err error
config.ClientConfig, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, nil).ClientConfig()
config.ClientConfig, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, overrides).ClientConfig()
if err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions backend/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Options struct {

type ExtraOptions struct {
KubeConfig string
Context string

Provider string

Expand Down Expand Up @@ -152,6 +153,7 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) {
options.ProviderKcp.AddFlags(fs)

fs.StringVar(&options.KubeConfig, "kubeconfig", options.KubeConfig, "path to a kubeconfig. Only required if out-of-cluster")
fs.StringVar(&options.Context, "context", options.Context, "The name of the kubeconfig context to use.")
fs.StringVar(&options.NamespacePrefix, "namespace-prefix", options.NamespacePrefix, "The prefix to use for cluster namespaces")
fs.StringVar(&options.PrettyName, "pretty-name", options.PrettyName, "Pretty name for the backend")
fs.StringVar(&options.ConsumerScope, "consumer-scope", options.ConsumerScope, "How consumers access the service provider cluster. In Kubernetes, \"namespaced\" allows namespace isolation. In kcp, \"cluster\" allows workspace isolation, and with that allows cluster-scoped resources to bind and it is generally more performant.")
Expand Down
8 changes: 7 additions & 1 deletion pkg/konnector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ func NewConfig(options *options.CompletedOptions) (*Config, error) {
// create clients
rules := clientcmd.NewDefaultClientConfigLoadingRules()
rules.ExplicitPath = options.KubeConfigPath
var overrides *clientcmd.ConfigOverrides
if options.Context != "" {
overrides = &clientcmd.ConfigOverrides{
CurrentContext: options.Context,
}
}
var err error
config.ClientConfig, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, nil).ClientConfig()
config.ClientConfig, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, overrides).ClientConfig()
if err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/konnector/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Options struct {

type ExtraOptions struct {
KubeConfigPath string
Context string

LeaseLockName string
LeaseLockNamespace string
Expand Down Expand Up @@ -80,6 +81,7 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) {
logsv1.AddFlags(options.Logs, fs)

fs.StringVar(&options.KubeConfigPath, "kubeconfig", options.KubeConfigPath, "Kubeconfig file for the local cluster.")
fs.StringVar(&options.Context, "context", options.Context, "The name of the kubeconfig context to use.")
fs.StringVar(&options.LeaseLockName, "lease-name", options.LeaseLockName, "Name of lease lock")
fs.StringVar(&options.LeaseLockNamespace, "lease-namespace", options.LeaseLockNamespace, "Name of lease lock namespace")
fs.StringVar(&options.ServerAddr, "server-address", options.ServerAddr, "Address for server")
Expand Down