-
Notifications
You must be signed in to change notification settings - Fork 1.2k
🐛 Fix testing kube-apiserver serving certificate using wrong SANs #3284
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
🐛 Fix testing kube-apiserver serving certificate using wrong SANs #3284
Conversation
Signed-off-by: solidDoWant <[email protected]>
Welcome @solidDoWant! |
Hi @solidDoWant. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
/ok-to-test |
Signed-off-by: solidDoWant <[email protected]>
Thx! /lgtm |
LGTM label has been added. Git tree hash: e82d5ffa6cb6e3300e28cb0b08b6122a7ba1e5ae
|
It("should have the host in the certificate altnames", func() { | ||
cert := getCertificate() | ||
|
||
Expect(cert.Subject.CommonName).To(Equal("localhost")) |
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.
I might be missing it, but where do we test that there is actually a SAN injected? The tests here all seem to only check for localhost
being there
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.
The following two Expect
statements verify that the DNS SAN extension contains localhost
, and that the IP SAN extension contains 127.0.0.1
and 1.2.3.4
.
There isn't really an easy way to verify that the DNS SAN extension will contain an additional entry if SecureServing.Address
is a hostname instead of an IP address. This is because the current logic (that is outside the scope of this PR) for determining SAN extension values depends on the test host's DNS resolver. If I were to add say example.com
, then the underlying business logic would perform a DNS lookup for example.com
, who's value would be host-dependent. The localhost
value only works here because localhost
typically resolves to 127.0.0.1
via the hosts
file.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, solidDoWant 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 |
When configuring the kube-apiserver for a test by setting a serving address, the certificate generated for the API server does not include the serving value. In other words, if a test environment is configured like this:
Then when
testEnv.Start()
is called, the healthcheck will fail because the producedapiserver.crt
serving certificate is only valid for localhost, and addresses that localhost resolves to.This fixes the issue by providing the SecureServing and InsecureServing listening address to the cert generator function.