Skip to content
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 the system certificate store if no certificates are specified. #1261

Merged
merged 2 commits into from
Apr 18, 2023

Conversation

marcusbooyah
Copy link
Contributor

This is a fix for #621.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 11, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: marcusbooyah / name: Marcus Bowyer (f2be6f6)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 11, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 11, 2023
@tg123
Copy link
Member

tg123 commented Apr 11, 2023

i would say this is not included in kubectl

@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2023

Codecov Report

❗ No coverage uploaded for pull request base (master@2af57ca). Click here to learn what that means.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##             master    #1261   +/-   ##
=========================================
  Coverage          ?   69.96%           
=========================================
  Files             ?       95           
  Lines             ?     2690           
  Branches          ?        0           
=========================================
  Hits              ?     1882           
  Misses            ?      808           
  Partials          ?        0           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@marcusbooyah
Copy link
Contributor Author

@tg123 an alternative would be to not set the ServerCertificateCustomValidationCallback at all.

kubectl doesn't require a CA to be set when TLS verification is disabled. It would make sense for this client to be the same. The current behavior is causing issues for us because we're using Let's Encrypt certificates for our API Server.

@tg123
Copy link
Member

tg123 commented Apr 12, 2023

do you mean SkipTlsVerify=false and let sdk use cert store if cacert == null

@marcusbooyah
Copy link
Contributor Author

do you mean SkipTlsVerify=false and let sdk use cert store if cacert == null

That's what this PR does

@tg123
Copy link
Member

tg123 commented Apr 12, 2023

do you mean SkipTlsVerify=false and let sdk use cert store if cacert == null

That's what this PR does

why not put your letsencrypt ca into kubeconfig

@marcusbooyah
Copy link
Contributor Author

I can do that. But since kubectl works without it I'm a bit confused as to why this client requires it. I think it would be better to have this client match kubectl behavior.

@jefflill
Copy link

This PR seems like a bit of a no-brainer. Having KubernetesClient be consistent with kubectl is a good idea and it would be nice if future developers didn't need to debug and then workaround things like this.

@tg123
Copy link
Member

tg123 commented Apr 13, 2023

totally agree the sdk should have same behavior as kubectl,
let me double check what is the default behavior if no ca is set in kubectl

and btw I believe

 to not set the ServerCertificateCustomValidationCallback at all.

is better

@marcusbooyah
Copy link
Contributor Author

@tg123 same, I updated the PR.

@tg123
Copy link
Member

tg123 commented Apr 14, 2023

Thanks, I double confirmed you are right, should set callback to null in order to use system default.

here is how kubectlRset rootCA
https://github.com/kubernetes/client-go/blob/704cac462081473b521f15547302f001f78ef2e4/transport/transport.go#L98

// RootCAs defines the set of root certificate authorities
	// that clients use when verifying server certificates.
	// If RootCAs is nil, TLS uses the host's root CA set.
	RootCAs *[x509](https://pkg.go.dev/crypto/x509).[CertPool](https://pkg.go.dev/crypto/x509#CertPool)

@tg123
Copy link
Member

tg123 commented Apr 14, 2023

/LGTM

cc @brendanburns
do you think we need to upgrade the ver for this?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2023
@brendandburns
Copy link
Contributor

/lgtm
/approve

No, I don't think this is a breaking change, I think it is more of a bug-fix. (honestly I doubt anyone will notice as few people use well-known CAs for the kube apiservers)

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, marcusbooyah

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 18, 2023
@k8s-ci-robot k8s-ci-robot merged commit 729b10c into kubernetes-client:master Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

6 participants