-
Notifications
You must be signed in to change notification settings - Fork 813
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
Kubernetes Config Update: Prioritize InClusterConfig function #3584
Conversation
Build Failed 😱 Build Id: 79f320f4-3551-4c3d-8e89-17592630bc46 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: 3b3f4d7c-36a3-4026-9286-5d164fd1131d To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: 399e2dc6-4959-42c4-91da-d069509a856f To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
|
||
// InClusterBuildConfig is a helper function that builds configs by trying the InClusterConfig(). | ||
// If InClusterConfig is unsuccessful, it falls back to BuildConfigFromFlags. | ||
func InClusterBuildConfig(masterURL, kubeconfigPath string) (*restclient.Config, error) { |
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.
func InClusterBuildConfig(masterURL, kubeconfigPath string) (*restclient.Config, error) { | |
func InClusterBuildConfig(kubeconfigPath string) (*restclient.Config, error) { |
Since we never use a masterURL
other than "" ?
Build Succeeded 👏 Build Id: d19c02b8-8e6f-4387-8a4d-e70b001ab137 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: c2c52f0e-d2b3-4301-99ab-c436a68e4cf6 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: 5baea74b-7bf5-4912-9492-1ef422c6e09a The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
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.
Other than a small nit, this LGTM.
@roberthbailey any issues on your end?
pkg/util/runtime/runtime.go
Outdated
// or a kubeconfigPath. These parameters are passed in as command line flags for cluster | ||
// components. If neither masterUrl or kubeconfigPath are passed, | ||
// the function logs a warning and falls back to a default configuration | ||
func BuildCustomConfigFromFlags(masterURL, kubeconfigPath string) (*restclient.Config, error) { |
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.
Small thing, but since this function isn't used anywhere else - any reason not to have the content be inline with InClusterBuildConfig(...)
?
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.
Merged the two functions and removed the masterURL
from the return statement. Now the return statement is:
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfigPath},
&clientcmd.ConfigOverrides{}).ClientConfig()
Would this approach look good?
Build Failed 😱 Build Id: 9b818f54-8bf0-47f9-8725-0c14d1513ec8 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Succeeded 👏 Build Id: 1010687c-89d7-4139-81f8-1af3bf7aecaa The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: 0a658c43-ca58-4d2b-8f31-81aa73184865 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
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.
Approach looks good - just saw one thing that needs tweaking.
cmd/controller/main.go
Outdated
// if the kubeconfig fails BuildConfigFromFlags will try in cluster config | ||
clientConf, err := clientcmd.BuildConfigFromFlags("", ctlConf.KubeConfig) | ||
// if the kubeconfig fails InClusterBuildConfig will try in cluster config | ||
clientConf, err := runtime.InClusterBuildConfig(logger.WithFields(logrus.Fields{}), ctlConf.KubeConfig) |
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.
clientConf, err := runtime.InClusterBuildConfig(logger.WithFields(logrus.Fields{}), ctlConf.KubeConfig) | |
clientConf, err := runtime.InClusterBuildConfig(logger, ctlConf.KubeConfig) |
Should be sufficient, and same for the other instances where there is already a global logger in place.
test/e2e/framework/framework.go
Outdated
@@ -81,7 +81,8 @@ type Framework struct { | |||
} | |||
|
|||
func newFramework(kubeconfig string, qps float32, burst int) (*Framework, error) { | |||
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig) | |||
logger := logrus.New() |
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.
logger := logrus.New() | |
logger = runtime.NewLoggerWithSource("framework") |
Just to be consistent.
test/e2e/framework/framework.go
Outdated
@@ -81,7 +81,8 @@ type Framework struct { | |||
} | |||
|
|||
func newFramework(kubeconfig string, qps float32, burst int) (*Framework, error) { | |||
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig) | |||
logger := logrus.New() | |||
config, err := runtime.InClusterBuildConfig(logger.WithFields(logrus.Fields{}), kubeconfig) |
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.
config, err := runtime.InClusterBuildConfig(logger.WithFields(logrus.Fields{}), kubeconfig) | |
config, err := runtime.InClusterBuildConfig(logger, kubeconfig) |
test/eviction/evictpod.go
Outdated
@@ -49,8 +51,9 @@ func main() { | |||
if *pod == "" { | |||
log.Fatal("--pod must be non-empty") | |||
} | |||
logger := logrus.New() |
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.
logger := logrus.New() | |
logger = runtime.NewLoggerWithSource("main") |
To be consistent. Might even switch out the log.
below to logger
to be nice and clean.
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.
All the changes are in place per your suggestion👍
Build Failed 😱 Build Id: 809bb667-f608-4832-a100-c82ea7d3f4a2 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Succeeded 👏 Build Id: 137b4f01-5272-47aa-aa55-e17ac978d6fb The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
test/eviction/evictpod.go
Outdated
@@ -45,22 +45,23 @@ func main() { | |||
namespace := flag.String("namespace", "default", "Namespace (defaults to `default`)") | |||
pod := flag.String("pod", "", "Pod name (required)") | |||
flag.Parse() | |||
logger := runtime.NewLoggerWithSource("main") |
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.
logger := runtime.NewLoggerWithSource("main") | |
logger := runtime.NewLoggerWithSource("evictpod") |
Minor of minor tweak (since the file is "evictpod" not "main"), but otherwise, this looks good to go for me.
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.
LGTM!
Build Succeeded 👏 Build Id: 1cd9f46f-acb2-4a02-8770-076166695025 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Which issue(s) this PR fixes:
Closes #3582
Special notes for your reviewer: