Skip to content

Conversation

qiujian16
Copy link

Change to user default loading rules that will automatically load config in KUBECONFIG environment variable.

fix #4081

@qiujian16 qiujian16 requested a review from a team March 9, 2018 09:26
@istio-merge-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
We suggest the following additional approver: costinm

Assign the PR to them by writing /assign @costinm in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@@ -70,14 +70,25 @@ func ResolveConfig(kubeconfig string) (string, error) {

// CreateInterface is a helper function to create Kubernetes interface
func CreateInterface(kubeconfig string) (*rest.Config, kubernetes.Interface, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by both the pilot server and istioctl. I believe that the issue you are trying to fix is from istioctl. I don't think pilot is ready to support this yet.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baodongli I do not think there is difference between pilot server and istioctl...if pilot server does not specify kubeconfig, in cluster config will be used. This is to ensure that the kubeconfig loaded by istioctl is the same as what is loaded by kubernetes client.

config, err := clientcmd.BuildConfigFromFlags("", kube)
if err != nil {
return nil, nil, err
kubeconfigenv := os.Getenv("KUBECONFIG")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this to a helper function name as ResolveMultiPathConfig or some others

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if kubeconfig != "" || kubeconfigenv != "" {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.ExplicitPath = kubeconfig
config, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new test for this in controller_test.go?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@codecov
Copy link

codecov bot commented Mar 12, 2018

Codecov Report

Merging #4138 into master will decrease coverage by 1%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #4138    +/-   ##
=======================================
- Coverage      71%     71%   -<1%     
=======================================
  Files         324     317     -7     
  Lines       29547   28882   -665     
=======================================
- Hits        20763   20218   -545     
+ Misses       7531    7443    -88     
+ Partials     1253    1221    -32
Impacted Files Coverage Δ
mixer/adapter/solarwinds/log_handler.go 50% <0%> (-7%) ⬇️
pilot/pkg/kube/inject/webhook.go 77% <0%> (-4%) ⬇️
mixer/adapter/redisquota/redisquota.go 86% <0%> (-3%) ⬇️
mixer/adapter/opa/opa.go 79% <0%> (-3%) ⬇️
mixer/adapter/list/list.go 100% <0%> (ø) ⬇️
mixer/adapter/list/ipList.go 100% <0%> (ø) ⬆️
mixer/adapter/memquota/keys.go 100% <0%> (ø) ⬆️
mixer/adapter/memquota/dedup.go 100% <0%> (ø) ⬆️
mixer/adapter/solarwinds/solarwinds.go 0% <0%> (ø) ⬆️
mixer/adapter/dogstatsd/dogstatsd.go 100% <0%> (ø) ⬆️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8eb6288...08b784c. Read the comment docs.

if err != nil {
return nil, nil, err
// switch to use in-cluster config
if config == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put the in-cluster logic to LoadConfigFromMultiPath?

@@ -0,0 +1,74 @@
// Copyright 2017 Istio Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to create a new test file.

@gyliu513
Copy link
Member

/ok-to-test

@qiujian16
Copy link
Author

/retest

@istio-merge-robot istio-merge-robot added the needs-rebase Indicates a PR needs to be rebased before being merged label Apr 12, 2018
@istio-merge-robot
Copy link

@qiujian16 PR needs rebase

@stale
Copy link

stale bot commented Jun 23, 2018

This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale label Jun 23, 2018
@stale
Copy link

stale bot commented Jul 7, 2018

This pull request has been automatically closed because it has not had activity in the last month. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR needs to be rebased before being merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KUBECONFIG Env Variable Multiple Paths
6 participants