Skip to content

Set 'Domain' in kcert - #13569

Merged
knative-prow[bot] merged 5 commits into
knative:mainfrom
KauzClay:ck-populate-domain-in-kcert
Jan 19, 2023
Merged

knative-prow[bot] merged 5 commits into
knative:mainfrom
KauzClay:ck-populate-domain-in-kcert

Conversation

@KauzClay

@KauzClay KauzClay commented Jan 3, 2023 •

Copy link
Copy Markdown
Contributor

Part of Fix for knative-extensions/net-certmanager#214

Proposed Changes

  • Following on from add new field 'Domain' to kcert spec networking#747
  • Populate the KCert resource domain field with the appropriate domain
  • This will be used in a following PR to knative-sandbox/net-certmanager
  • TODO: What should be done about the domains for a domain mapping? Use the domainmapping name

Release Note

Work around for cert-manager not allowing us to create certs for 64+ bytes name ksvc

@knative-prow

knative-prow Bot commented Jan 3, 2023

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/API API objects and controllers labels Jan 3, 2023
@knative-prow
knative-prow Bot requested review from ZhiminXiang and psschwei January 3, 2023 22:58
@knative-prow knative-prow Bot added area/networking size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 3, 2023
@KauzClay
KauzClay force-pushed the ck-populate-domain-in-kcert branch 2 times, most recently from 919f5ab to 056a85d Compare January 5, 2023 16:24
@KauzClay KauzClay changed the title wip: set domain in kcert wip: set 'Domain' in kcert Jan 6, 2023
@KauzClay

Copy link
Copy Markdown
Contributor Author

/assign @evankanderson

@evankanderson evankanderson left a comment

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.

One comment, but this looks reasonable for now.

(I'm wondering about creating multiple Certificate resources on L82 of route/resources/certificate.go, but do not fix that in this PR.)

certName := kmeta.ChildName(dm.GetName(), "")
return routeresources.MakeCertificate(
dm, serving.DomainMappingUIDLabelKey, dm.Name, certName, certClass)
dm, serving.DomainMappingUIDLabelKey, dm.Name, certName, certClass, "domain.mapping")

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.

I think this needs to be a valid domain that can answer a challenge, so it should probably be dm.Name here.

@KauzClay
KauzClay force-pushed the ck-populate-domain-in-kcert branch from 056a85d to d08bbab Compare January 12, 2023 22:59
@KauzClay KauzClay changed the title wip: set 'Domain' in kcert Set 'Domain' in kcert Jan 12, 2023
@KauzClay
KauzClay marked this pull request as ready for review January 12, 2023 23:02
@knative-prow knative-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 12, 2023
@knative-prow
knative-prow Bot requested a review from vagababov January 12, 2023 23:02
@KauzClay
KauzClay force-pushed the ck-populate-domain-in-kcert branch from d08bbab to 7d656aa Compare January 12, 2023 23:03
* for domain mappings, use the name as the domain
@KauzClay
KauzClay force-pushed the ck-populate-domain-in-kcert branch from 7d656aa to 71cc5e9 Compare January 13, 2023 18:25
@KauzClay
KauzClay marked this pull request as draft January 13, 2023 20:54
@knative-prow knative-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 13, 2023
* since the tests specify a domain in the config, the certs created will use the domain
@knative-prow knative-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 13, 2023
@KauzClay
KauzClay marked this pull request as ready for review January 13, 2023 21:57
@knative-prow knative-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 13, 2023
@knative-prow
knative-prow Bot requested a review from nader-ziada January 13, 2023 21:57
@codecov

codecov Bot commented Jan 13, 2023 •

Copy link
Copy Markdown

Codecov Report

Base: 86.44% // Head: 86.45% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (3375f37) compared to base (76005a0).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13569      +/-   ##
==========================================
+ Coverage   86.44%   86.45%   +0.01%     
==========================================
  Files         196      196              
  Lines       14600    14606       +6     
==========================================
+ Hits        12621    12628       +7     
  Misses       1678     1678              
+ Partials      301      300       -1     
Impacted Files Coverage Δ
.../reconciler/domainmapping/resources/certificate.go 100.00% <100.00%> (ø)
pkg/reconciler/route/resources/certificate.go 100.00% <100.00%> (ø)
pkg/reconciler/route/route.go 80.30% <100.00%> (+0.24%) ⬆️
pkg/autoscaler/statserver/server.go 75.91% <0.00%> (-1.46%) ⬇️
pkg/reconciler/configuration/configuration.go 84.36% <0.00%> (+1.42%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@evankanderson

Copy link
Copy Markdown
Member

/retest

@KauzClay

Copy link
Copy Markdown
Contributor Author

/test istio-latest-no-mesh-tls

@dprotaso

Copy link
Copy Markdown
Member

I think the istio-latest-no-mesh-tls failure is legit: https://prow.knative.dev/pr-history/?org=knative&repo=serving&pr=13569

@evankanderson evankanderson left a comment

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.

Agree that the Istio error flagged looks legitimate.

// annotations from the owner, as well as the namespaces. If owner
// does not have a certClass, use the provided `certClass` parameter.
func MakeCertificate(owner kmeta.OwnerRefableAccessor, ownerLabelKey string, dnsName string, certName string, certClass string) *networkingv1alpha1.Certificate {
func MakeCertificate(owner kmeta.OwnerRefableAccessor, ownerLabelKey string, dnsName string, certName string, certClass string, domain string) *networkingv1alpha1.Certificate {

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.

I'll admit I'm slightly concerned with this collection of string arguments -- it would be nice if there was a way to use the type system to avoid (for example) confusing dnsName and certName.

However, that's a problem with the existing interface, and I'd avoid trying to fix it in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmmm okay. This would a separate PR that could come after this one?

And are you imagining like a custom type for each string entry? Or that the MakeCertificate function would accept an object (perhaps even a CertificateSpec) instead of all those strings?

@@ -58,7 +59,7 @@ func MakeCertificate(owner kmeta.OwnerRefableAccessor, ownerLabelKey string, dns
// domainTagMap is an one-to-one mapping between domain and tag, for major domain (tag-less),
// the value is an empty string

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.

Add documentation for domain here, since it's not clear how it relates to domainTagMap?

@@ -34,7 +34,7 @@ import (
// MakeCertificate creates a Certificate, inheriting the certClass
// annotations from the owner, as well as the namespaces. If owner
// does not have a certClass, use the provided `certClass` parameter.

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.

Add a docstring about the domain parameter, particularly since it differs from the dnsName parameter in a possibly-subtle way?

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.

(you might want to call this baseDomain?)

certName := kmeta.ChildName(dm.GetName(), "")
return routeresources.MakeCertificate(
dm, serving.DomainMappingUIDLabelKey, dm.Name, certName, certClass)
dm, serving.DomainMappingUIDLabelKey, dm.Name, certName, certClass, dm.Name)

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.

Hmm -- maybe this should be empty-string for the domain-mapping use case (indicating that there isn't a base domain, and we should be using this exact name)?

@KauzClay
KauzClay force-pushed the ck-populate-domain-in-kcert branch from fa49ff2 to ae1a85b Compare January 17, 2023 22:19
@KauzClay
KauzClay force-pushed the ck-populate-domain-in-kcert branch from ae1a85b to 3375f37 Compare January 17, 2023 22:23
@KauzClay

Copy link
Copy Markdown
Contributor Author

@evankanderson would you mind expanding more on what you're thinking regarding this when you get the chance?

(I'm wondering about creating multiple Certificate resources on L82 of route/resources/certificate.go, but do not fix that in this PR.)

I'm happy to start up followup PRs from this one

@KauzClay

KauzClay commented Jan 18, 2023 •

Copy link
Copy Markdown
Contributor Author

@evankanderson @dprotaso I was looking into why the istio tls tests were failing when you use dm.Name as the domain.

On my dev cluster, I see this error in the domain mapping controller logs:

{"severity":"ERROR","timestamp":"2023-01-18T16:39:17.769364418Z","logger":"domainmapping","caller":"controller/controller.go:566","message":"Reconcile error","commit":"3375f37-dirty","knative.dev/controller":"knative.dev.serving.pkg.reconciler.domainmapping.Reconciler","knative.dev/kind":"serving.knative.dev.DomainMapping","knative.dev/traceid":"33574aec-a3c7-4ec7-970f-4a4a4b1bac81","knative.dev/key":"default/hello.clay.tanzu.biz","duration":"8.971078ms","error":"failed to create Certificate: admission webhook \"validation.webhook.serving.knative.dev\" denied the request: validation failed: invalid value: domain: spec.domain must be a suffix of at least one entry in dnsNames","stacktrace":"knative.dev/pkg/controller.(*Impl).handleErr\n\tknative.dev/[email protected]/controller/controller.go:566\nknative.dev/pkg/controller.(*Impl).processNextWorkItem\n\tknative.dev/[email protected]/controller/controller.go:543\nknative.dev/pkg/controller.(*Impl).RunContext.func3\n\tknative.dev/[email protected]/controller/controller.go:491"}

which is because of this validation that I added in the previous MR:
https://github.com/knative/networking/blob/dd05ffd178f45d1502741a41a5a80d78e43cd224/pkg/apis/networking/v1alpha1/certificate_validation.go#L49-L62

I think it is okay to not include a domain for a domainmapping, but I'm curious what you think. Should the validation change instead?

@dprotaso

dprotaso commented Jan 18, 2023 •

Copy link
Copy Markdown
Member

Let's update networking and fix the validation. We'll have to cherry pick this to the release-1.9 branch as it's been cut today.

@KauzClay

Copy link
Copy Markdown
Contributor Author

Okay, I've made a change for the validation: knative/networking#754

@dprotaso

dprotaso commented Jan 19, 2023 •

Copy link
Copy Markdown
Member

The networking change has merged into serving HEAD

/retest

@dprotaso

Copy link
Copy Markdown
Member

Going to merge this but we can do a follow up where DomainMapping includes the domain just to be complete.
/lgtm
/approve

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 19, 2023
@knative-prow

knative-prow Bot commented Jan 19, 2023

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, KauzClay

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

The pull request process is described 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

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 19, 2023
@dprotaso

Copy link
Copy Markdown
Member

/hold need to check something

@knative-prow knative-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2023
@dprotaso

dprotaso commented Jan 19, 2023 •

Copy link
Copy Markdown
Member

/hold cancel

All good - wanted to confirm that the Domain attribute isn't passed to Let's Encrypt in the commonName (based on knative-extensions/net-certmanager#214 (comment))

But it's manipulated in the implementations here: https://github.com/knative-sandbox/net-certmanager/pull/472/files#diff-6fcd5c4b2c560dac89c88b31c34e9a25b3edd76f02b94cf53ddcfe483ea4d416R40

@knative-prow knative-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2023
@knative-prow
knative-prow Bot merged commit 94d23ac into knative:main Jan 19, 2023
dprotaso added a commit to dprotaso/serving that referenced this pull request Jan 19, 2023
This is a follow up on
knative#13569
since we've relaxed the validation for certificates
knative/networking#754
knative-prow Bot pushed a commit that referenced this pull request Jan 20, 2023
This is a follow up on
#13569
since we've relaxed the validation for certificates
knative/networking#754
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. area/API API objects and controllers area/networking lgtm 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.

3 participants