Repository navigation
Allow disabling of automatic DomainClaim creation - #10537
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10537 +/- ##
=======================================
Coverage 88.10% 88.11%
=======================================
Files 187 187
Lines 8870 8874 +4
=======================================
+ Hits 7815 7819 +4
+ Misses 815 813 -2
- Partials 240 242 +2
Continue to review full report at Codecov.
|
|
/retest |
|
|
||
| dc, err := r.netclient.NetworkingV1alpha1().ClusterDomainClaims().Create(ctx, resources.MakeDomainClaim(dm), metav1.CreateOptions{}) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to create ClusterDomainClaim: %w", err) |
There was a problem hiding this comment.
nit: one of these error has "domain mapping:" prefix while the other doesn't
There was a problem hiding this comment.
also one says "cluster domain claim" while the other uses "ClusterDomainClaim"
There was a problem hiding this comment.
fixed, dropped the prefix since it doesn't look like we use them elsewhere for stuff like this
| if dc, err = r.netclient.NetworkingV1alpha1().ClusterDomainClaims().Create(ctx, resources.MakeDomainClaim(dm), metav1.CreateOptions{}); err != nil { | ||
| return fmt.Errorf("failed to create ClusterDomainClaim: %w", err) | ||
| dc, err = r.createDomainClaimIfAllowed(ctx, dm) | ||
| if err != nil { |
There was a problem hiding this comment.
Did it like this to try to make clear as possible that this is updating the outer dc and doesn't shadow it, but I'll happily change if you don't think this made that clearer
There was a problem hiding this comment.
I see, thanks. I don't mind keeping it this way, please feel free to do so.
But I think @vagababov will one day change it anyway 🤣.
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: julz, tcnghia The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
| // FinalizeKind cleans up the ClusterDomainClaim created by the DomainMapping. | ||
| func (r *Reconciler) FinalizeKind(ctx context.Context, dm *v1alpha1.DomainMapping) reconciler.Event { | ||
| if !config.FromContext(ctx).Network.AutocreateClusterDomainClaims { | ||
| // If we're not responsible for creating domain claims, we're not responsible for cleaning them up. |
There was a problem hiding this comment.
what if I created DM and then disabled the flag? Should we still cleanup the existing ones?
There was a problem hiding this comment.
I think no, if the flag is disabled that implies the administrator is going to manage creating/deleting claims.
| return nil | ||
| } | ||
|
|
||
| func (r *Reconciler) createDomainClaimIfAllowed(ctx context.Context, dm *v1alpha1.DomainMapping) (*netv1alpha1.ClusterDomainClaim, error) { |
There was a problem hiding this comment.
this name presumes there's a createDC without any allowance check. I think just createDomainClaim is fine, especially that it's an internal method.
| return fmt.Errorf("failed to get ClusterDomainClaim: %w", err) | ||
| } | ||
|
|
||
| if dm.Namespace != dc.Spec.Namespace { |
There was a problem hiding this comment.
I'd move this as the else clause of IsNotFound, since it's meaningless to check it when we just built the dc above — we know NS would mathch.
|
/retest |
|
Hmm. /retest |
Part of #9713.
Implements
autocreateClusterDomainClaimconfig. This allows multi-tenant clusters to safely use Domain Mapping, by preventing automatic creation of ClusterDomainClaims in the reconciler. With this option disabled in the config (it defaults to true), domain names must be explicitly delegated to a particular namespace by cluster administrators by creating a ClusterDomainClaim with an appropriate spec.Namespace field. This is important to prevent domain squatting/interception when DNS is being pointed to a shared cluster.Release Note
/assign @mattmoor @tcnghia