Skip to content

Support TLS Server Name overrides in kubeconfig file#82056

Closed
surki wants to merge 6 commits intokubernetes:masterfrom
surki:server-name-override-kubeconfig
Closed

Support TLS Server Name overrides in kubeconfig file#82056
surki wants to merge 6 commits intokubernetes:masterfrom
surki:server-name-override-kubeconfig

Conversation

@surki
Copy link
Copy Markdown
Contributor

@surki surki commented Aug 28, 2019

Signed-off-by: Suresh Kumar Ponnusamy [email protected]

What type of PR is this?
/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #80596

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Support TLS Server Name overrides in kubeconfig file

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @surki!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 28, 2019
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @surki. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added area/kubectl sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 28, 2019
@roycaihw
Copy link
Copy Markdown
Member

/cc @lavalamp @liggitt
/sig auth

@k8s-ci-robot k8s-ci-robot added the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Aug 29, 2019
@surki
Copy link
Copy Markdown
Contributor Author

surki commented Sep 4, 2019

@liggitt @lavalamp Can you please take a look at this, your review comments have been addressed? Thanks

@surki
Copy link
Copy Markdown
Contributor Author

surki commented Sep 11, 2019

/assign @smarterclayton

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Sep 25, 2019

/ok-to-test

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Sep 25, 2019

/priority important-longterm

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 25, 2019
surki added 3 commits October 8, 2019 17:23
And update RecommendedClusterOverrideFlags/BindClusterFlags
@surki surki force-pushed the server-name-override-kubeconfig branch from 467069a to 00e5e81 Compare October 8, 2019 11:54
@surki
Copy link
Copy Markdown
Contributor Author

surki commented Oct 8, 2019

/retest

@surki
Copy link
Copy Markdown
Contributor Author

surki commented Oct 9, 2019

@liggitt I rebased the changes to latest master, all tests are passing.
Please let me know if you want me to squash the changes.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Oct 9, 2019

Thought of a couple more issues. You can override the server name on the CLI with --server. For parity, this should also be overrideable.

flagAPIServer = "server"
flagInsecure = "insecure-skip-tls-verify"

// bind cluster flags
if f.APIServer != nil {
overrides.ClusterInfo.Server = *f.APIServer
}
if f.CAFile != nil {
overrides.ClusterInfo.CertificateAuthority = *f.CAFile
}
if f.Insecure != nil {
overrides.ClusterInfo.InsecureSkipTLSVerify = *f.Insecure
}

if f.APIServer != nil {
flags.StringVarP(f.APIServer, flagAPIServer, "s", *f.APIServer, "The address and port of the Kubernetes API server")
}
if f.Insecure != nil {
flags.BoolVar(f.Insecure, flagInsecure, *f.Insecure, "If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure")
}

When overriding the server on the CLI, I would expect the server verify name to be overridden as well. This is similar to how overriding the insecure or CA settings on the CLI overrides all the trust settings (insecure/ca-file/ca-data) together:

// * An override of --insecure-skip-tls-verify=true and no accompanying CA/CA data should clear already-set CA/CA data
// otherwise, a kubeconfig containing a CA reference would return an error that "CA and insecure-skip-tls-verify couldn't both be set".
// * An override of --certificate-authority should also override TLS skip settings and CA data, otherwise existing CA data will take precedence.
caLen := len(config.overrides.ClusterInfo.CertificateAuthority)
caDataLen := len(config.overrides.ClusterInfo.CertificateAuthorityData)
if config.overrides.ClusterInfo.InsecureSkipTLSVerify || caLen > 0 || caDataLen > 0 {
mergedClusterInfo.InsecureSkipTLSVerify = config.overrides.ClusterInfo.InsecureSkipTLSVerify
mergedClusterInfo.CertificateAuthority = config.overrides.ClusterInfo.CertificateAuthority
mergedClusterInfo.CertificateAuthorityData = config.overrides.ClusterInfo.CertificateAuthorityData
}

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: surki
To complete the pull request process, please assign smarterclayton
You can assign the PR to them by writing /assign @smarterclayton in a comment when ready.

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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@surki
Copy link
Copy Markdown
Contributor Author

surki commented Oct 29, 2019

/test pull-kubernetes-integration

@surki
Copy link
Copy Markdown
Contributor Author

surki commented Oct 29, 2019

Thought of a couple more issues. You can override the server name on the CLI with --server. For parity, this should also be overrideable.

@liggitt Done

@surki
Copy link
Copy Markdown
Contributor Author

surki commented Nov 11, 2019

@liggitt Can you PTAL?

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Nov 13, 2019

@liggitt Can you PTAL?

this will slip to 1.18. I can take a look after next week.

@liggitt liggitt added this to the v1.18 milestone Nov 13, 2019
@surki
Copy link
Copy Markdown
Contributor Author

surki commented Dec 17, 2019

@liggitt can you PTAL?

mergedClusterInfo.CertificateAuthorityData = config.overrides.ClusterInfo.CertificateAuthorityData
}

if config.overrides.ClusterInfo.TLSServerName != "" {
Copy link
Copy Markdown
Member

@liggitt liggitt Dec 17, 2019

Choose a reason for hiding this comment

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

Suggested change
if config.overrides.ClusterInfo.TLSServerName != "" {
if config.overrides.ClusterInfo.TLSServerName != "" || config.overrides.ClusterInfo.Server != "" {

since tls server name defaults to server, I would expect setting Server and TLSServerName in the overrides to be paired. for example, if I have a kubeconfig that has this:

tlsServerName: https://example.com
server: https://1.2.3.4

and I override --server https://foo.com, I would expect foo.com to be used to verify the server unless I also override --tls-server-name https://example.com

@@ -121,6 +125,9 @@ func (o *createClusterOptions) modifyCluster(existingCluster clientcmdapi.Cluste
if o.server.Provided() {
modifiedCluster.Server = o.server.Value()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should specifying a server name clear TLSServerName, similar to how insecureSkipTLSVerify and CA interact?

@smourapina
Copy link
Copy Markdown

Hello @liggitt, @surki!
Bug Triage team here for the 1.18 release. This is a friendly reminder that code freeze is scheduled for 5 March. Is this issue still intended for milestone 1.18? Thanks in advance!

@smourapina
Copy link
Copy Markdown

Hello again @liggitt!
Just leaving another friendly ping to remind you that code freeze is coming in about 1 week (5 March). Should this be moved to the next milestone or will it still be finished by then?

@smourapina
Copy link
Copy Markdown

@liggitt, @surki: Bug Triage for 1.18 checking in. We are a few days away from code freeze for release 1.18 (which happens next Thursday, 5 March). As this PR has not been updated recently, should the milestone be adjusted? Thanks!

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Mar 4, 2020

closing in favor of #88769 which resolved the outstanding comments in a second commit

/close

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@liggitt: Closed this PR.

Details

In response to this:

closing in favor of #88769 which resolved the outstanding comments in a second commit

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support TLS Server Name overrides in kubeconfig file

7 participants