-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
State of the world reconciler (#838)
* FEAT: Policy Machinery * FEAT: add kuadrant CR to topology This also includes the different policies (auth, DNS, ratelimit, TLS) The kuadrant CR has been added as the root to the topology. This does not take into account what happens if more than one kuadrant CR is added to the cluster * RBAC: gatewayclasses Adding RBAC to allow listing and watching the Gateway Class so they can be added to the graph. * Feat: ConfigMap in topology Topology configmap writes only happen if the data['topology'] is different. - Acquire namespace from environment variable - setting namespace - panic if envvar is not there --------- Signed-off-by: Jim Fitzpatrick <[email protected]>
- Loading branch information
Showing
17 changed files
with
533 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ tmp | |
/coverage/ | ||
|
||
# Vendor dependencies | ||
vendor | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package v1alpha1 | ||
|
||
// Contains of this file allow the DNSPolicy and TLSPolicy to adhere to the machinery.Policy interface | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/machinery" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
var ( | ||
DNSPoliciesResource = GroupVersion.WithResource("dnspolicies") | ||
DNSPolicyKind = schema.GroupKind{Group: GroupVersion.Group, Kind: "DNSPolicy"} | ||
TLSPoliciesResource = GroupVersion.WithResource("tlspolicies") | ||
TLSPolicyKind = schema.GroupKind{Group: GroupVersion.Group, Kind: "TLSPolicy"} | ||
) | ||
|
||
var _ machinery.Policy = &DNSPolicy{} | ||
|
||
func (p *DNSPolicy) GetTargetRefs() []machinery.PolicyTargetReference { | ||
return []machinery.PolicyTargetReference{ | ||
machinery.LocalPolicyTargetReference{ | ||
LocalPolicyTargetReference: p.Spec.TargetRef, | ||
PolicyNamespace: p.Namespace, | ||
}, | ||
} | ||
} | ||
|
||
func (p *DNSPolicy) GetMergeStrategy() machinery.MergeStrategy { | ||
return func(policy machinery.Policy, _ machinery.Policy) machinery.Policy { | ||
return policy | ||
} | ||
} | ||
|
||
func (p *DNSPolicy) Merge(other machinery.Policy) machinery.Policy { | ||
return other | ||
} | ||
|
||
func (p *DNSPolicy) GetLocator() string { | ||
return machinery.LocatorFromObject(p) | ||
} | ||
|
||
var _ machinery.Policy = &TLSPolicy{} | ||
|
||
func (p *TLSPolicy) GetTargetRefs() []machinery.PolicyTargetReference { | ||
return []machinery.PolicyTargetReference{ | ||
machinery.LocalPolicyTargetReference{ | ||
LocalPolicyTargetReference: p.Spec.TargetRef, | ||
PolicyNamespace: p.Namespace, | ||
}, | ||
} | ||
} | ||
|
||
func (p *TLSPolicy) GetMergeStrategy() machinery.MergeStrategy { | ||
return func(policy machinery.Policy, _ machinery.Policy) machinery.Policy { | ||
return policy | ||
} | ||
} | ||
|
||
func (p *TLSPolicy) Merge(other machinery.Policy) machinery.Policy { | ||
return other | ||
} | ||
|
||
func (p *TLSPolicy) GetLocator() string { | ||
return machinery.LocatorFromObject(p) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package v1beta1 | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/controller" | ||
"github.com/kuadrant/policy-machinery/machinery" | ||
"github.com/samber/lo" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" | ||
) | ||
|
||
var ( | ||
KuadrantResource = GroupVersion.WithResource("kuadrants") | ||
KuadrantKind = schema.GroupKind{Group: GroupVersion.Group, Kind: "Kuadrant"} | ||
) | ||
|
||
var _ machinery.Object = &Kuadrant{} | ||
|
||
func (p *Kuadrant) GetLocator() string { | ||
return machinery.LocatorFromObject(p) | ||
} | ||
|
||
func LinkKuadrantToGatewayClasses(objs controller.Store) machinery.LinkFunc { | ||
kuadrants := lo.Map(objs.FilterByGroupKind(KuadrantKind), controller.ObjectAs[*Kuadrant]) | ||
|
||
return machinery.LinkFunc{ | ||
From: KuadrantKind, | ||
To: schema.GroupKind{Group: gwapiv1.GroupVersion.Group, Kind: "GatewayClass"}, | ||
Func: func(_ machinery.Object) []machinery.Object { | ||
parents := make([]machinery.Object, len(kuadrants)) | ||
for _, parent := range kuadrants { | ||
parents = append(parents, parent) | ||
} | ||
return parents | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package v1beta2 | ||
|
||
// Contains of this file allow the AuthPolicy and RateLimitPolicy to adhere to the machinery.Policy interface | ||
|
||
import ( | ||
"github.com/kuadrant/policy-machinery/machinery" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
var ( | ||
AuthPoliciesResource = GroupVersion.WithResource("authpolicies") | ||
AuthPolicyKind = schema.GroupKind{Group: GroupVersion.Group, Kind: "AuthPolicy"} | ||
RateLimitPoliciesResource = GroupVersion.WithResource("ratelimitpolicies") | ||
RateLimitPolicyKind = schema.GroupKind{Group: GroupVersion.Group, Kind: "RateLimitPolicy"} | ||
) | ||
|
||
var _ machinery.Policy = &AuthPolicy{} | ||
|
||
func (ap *AuthPolicy) GetTargetRefs() []machinery.PolicyTargetReference { | ||
return []machinery.PolicyTargetReference{ | ||
machinery.LocalPolicyTargetReference{ | ||
LocalPolicyTargetReference: ap.Spec.TargetRef, | ||
PolicyNamespace: ap.Namespace, | ||
}, | ||
} | ||
} | ||
|
||
func (ap *AuthPolicy) GetMergeStrategy() machinery.MergeStrategy { | ||
return func(policy machinery.Policy, _ machinery.Policy) machinery.Policy { | ||
return policy | ||
} | ||
} | ||
|
||
func (ap *AuthPolicy) Merge(other machinery.Policy) machinery.Policy { | ||
return other | ||
} | ||
|
||
func (ap *AuthPolicy) GetLocator() string { | ||
return machinery.LocatorFromObject(ap) | ||
} | ||
|
||
var _ machinery.Policy = &RateLimitPolicy{} | ||
|
||
func (r *RateLimitPolicy) GetTargetRefs() []machinery.PolicyTargetReference { | ||
return []machinery.PolicyTargetReference{ | ||
machinery.LocalPolicyTargetReference{ | ||
LocalPolicyTargetReference: r.Spec.TargetRef, | ||
PolicyNamespace: r.Namespace, | ||
}, | ||
} | ||
} | ||
|
||
func (r *RateLimitPolicy) GetMergeStrategy() machinery.MergeStrategy { | ||
return func(policy machinery.Policy, _ machinery.Policy) machinery.Policy { | ||
return policy | ||
} | ||
} | ||
|
||
func (r *RateLimitPolicy) Merge(other machinery.Policy) machinery.Policy { | ||
return other | ||
} | ||
|
||
func (r *RateLimitPolicy) GetLocator() string { | ||
return machinery.LocatorFromObject(r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.