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

Add EnvoyPatchPolicy support in K8s provider #1624

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/gateway-helm/templates/generated/rbac/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rules:
- gateway.envoyproxy.io
resources:
- authenticationfilters
- envoypatchpolicies
- ratelimitfilters
verbs:
- get
Expand Down
2 changes: 2 additions & 0 deletions internal/gatewayapi/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Resources struct {
RateLimitFilters []*egv1a1.RateLimitFilter `json:"rateLimitFilters,omitempty"`
EnvoyProxy *egcfgv1a1.EnvoyProxy `json:"envoyProxy,omitempty"`
ExtensionRefFilters []unstructured.Unstructured `json:"extensionRefFilters,omitempty"`
EnvoyPatchPolicies []*egv1a1.EnvoyPatchPolicy `json:"envoyPatchPolicies,omitempty"`
}

func NewResources() *Resources {
Expand All @@ -58,6 +59,7 @@ func NewResources() *Resources {
RateLimitFilters: []*egv1a1.RateLimitFilter{},
AuthenticationFilters: []*egv1a1.AuthenticationFilter{},
ExtensionRefFilters: []unstructured.Unstructured{},
EnvoyPatchPolicies: []*egv1a1.EnvoyPatchPolicy{},
}
}

Expand Down
11 changes: 11 additions & 0 deletions internal/gatewayapi/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions internal/provider/kubernetes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, request reconcile.
resourceTree.ReferenceGrants = append(resourceTree.ReferenceGrants, referenceGrant)
}

// Add all EnvoyPatchPolicies
envoyPatchPolicies := egv1a1.EnvoyPatchPolicyList{}
if err := r.client.List(ctx, &envoyPatchPolicies); err != nil {
return reconcile.Result{}, fmt.Errorf("error listing envoypatchpolicies: %v", err)
}
for _, policy := range envoyPatchPolicies.Items {
policy := policy
resourceTree.EnvoyPatchPolicies = append(resourceTree.EnvoyPatchPolicies, &policy)
}

// For this particular Gateway, and all associated objects, check whether the
// namespace exists. Add to the resourceTree.
for ns := range resourceMap.allAssociatedNamespaces {
Expand Down Expand Up @@ -1216,6 +1226,13 @@ func (r *gatewayAPIReconciler) watchResources(ctx context.Context, mgr manager.M
return err
}

// Watch EnvoyPatchPolicy CRUDs
if err := c.Watch(
source.Kind(mgr.GetCache(), &egv1a1.EnvoyPatchPolicy{}),
&handler.EnqueueRequestForObject{}); err != nil {
return err
}

r.log.Info("Watching gatewayAPI related objects")

// Watch any additional GVKs from the registered extension.
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/kubernetes/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package kubernetes

// RBAC for Envoy Gateway custom resources.
// +kubebuilder:rbac:groups="config.gateway.envoyproxy.io",resources=envoyproxies,verbs=get;list;watch;update
// +kubebuilder:rbac:groups="gateway.envoyproxy.io",resources=authenticationfilters;ratelimitfilters,verbs=get;list;watch;update
// +kubebuilder:rbac:groups="gateway.envoyproxy.io",resources=authenticationfilters;ratelimitfilters;envoypatchpolicies,verbs=get;list;watch;update

// RBAC for watched resources of Gateway API controllers.
// +kubebuilder:rbac:groups="",resources=secrets;services;namespaces;nodes,verbs=get;list;watch
Expand Down