-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use specific client set for operations #105
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,8 +66,10 @@ type VolumeOpts struct { | |
|
||
// ClientSets is a collection of clientSets needed | ||
type ClientSets struct { | ||
KubeClient *kubernetes.Clientset | ||
LitmusClient *clientV1alpha1.Clientset | ||
KubeClient *kubernetes.Clientset | ||
LitmusClient *clientV1alpha1.Clientset | ||
KubeClientExperiment *kubernetes.Clientset | ||
LitmusClientExperiment *clientV1alpha1.Clientset | ||
} | ||
|
||
// Recorder is collection of resources needed to record events for chaos-runner | ||
|
@@ -95,40 +97,67 @@ const ( | |
|
||
// GenerateClientSetFromKubeConfig will generation both ClientSets (k8s, and Litmus) | ||
func (clientSets *ClientSets) GenerateClientSetFromKubeConfig() error { | ||
config, err := getKubeConfig() | ||
configExperiment, configLitmus, err := getKubeConfig() | ||
if err != nil { | ||
return err | ||
} | ||
k8sClientSet, err := k8s.GenerateK8sClientSet(config) | ||
|
||
k8sClientSetLitmus, err := k8s.GenerateK8sClientSet(configLitmus) | ||
if err != nil { | ||
return err | ||
} | ||
litmusClientSet, err := litmus.GenerateLitmusClientSet(config) | ||
litmusClientSetLitmus, err := litmus.GenerateLitmusClientSet(configLitmus) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
k8sClientSetExperiment, err := k8s.GenerateK8sClientSet(configExperiment) | ||
if err != nil { | ||
return err | ||
} | ||
clientSets.KubeClient = k8sClientSet | ||
clientSets.LitmusClient = litmusClientSet | ||
litmusClientSetExperiment, err := litmus.GenerateLitmusClientSet(configExperiment) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
clientSets.KubeClient = k8sClientSetLitmus | ||
clientSets.LitmusClient = litmusClientSetLitmus | ||
clientSets.KubeClientExperiment = k8sClientSetExperiment | ||
clientSets.LitmusClientExperiment = litmusClientSetExperiment | ||
|
||
return nil | ||
} | ||
|
||
// Generate | ||
|
||
// getKubeConfig setup the config for access cluster resource | ||
func getKubeConfig() (*rest.Config, error) { | ||
func getKubeConfig() (*rest.Config, *rest.Config, error) { | ||
kubeconfig := flag.String("kubeconfig", "", "absolute path to the kubeconfig file") | ||
litmuskubeconfig := flag.String("litmuskubeconfig", "", "absolute path to the kubeconfig file") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose we can also distinguish the usage/help message to specify: litmuskubeconfig - "absolute path to the kubeconfig file of target cluster where experiment job is launched" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ref: #105 (comment) |
||
flag.Parse() | ||
// Use in-cluster config if kubeconfig path is specified | ||
if *litmuskubeconfig == "" { | ||
configLitmus, err := rest.InClusterConfig() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this not be configExperiment ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually no, whatever is specified by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok got it. Could we name this better. Can we say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do. |
||
if err != nil { | ||
return nil, configLitmus, err | ||
} | ||
} | ||
configLitmus, err := clientcmd.BuildConfigFromFlags("", *litmuskubeconfig) | ||
if err != nil { | ||
return nil, configLitmus, err | ||
} | ||
|
||
// Use in-cluster config if kubeconfig path is specified | ||
if *kubeconfig == "" { | ||
config, err := rest.InClusterConfig() | ||
configExperiment, err := rest.InClusterConfig() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this, the configLitmus? |
||
if err != nil { | ||
return config, err | ||
return configExperiment, configLitmus, err | ||
} | ||
} | ||
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) | ||
configExperiment, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) | ||
if err != nil { | ||
return config, err | ||
return configExperiment, configLitmus, err | ||
} | ||
return config, err | ||
|
||
return configExperiment, configLitmus, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just trying to understand which config is used for which purpose.
right? if this is the case, would you like to use the
clients.KubeClientExperiment
to get the chaosresult verdict here?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I was thinking having the chausresult used by kubeconfig. Do you think it should be used by litmuskubeconfig?