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

Watch UpstreamSettingsPolicies and translate into dataplane configuration #2887

Merged
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
2 changes: 2 additions & 0 deletions charts/nginx-gateway-fabric/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
{{- if .Values.nginxGateway.snippetsFilters.enable }}
- snippetsfilters
{{- end }}
Expand All @@ -116,6 +117,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
{{- if .Values.nginxGateway.snippetsFilters.enable }}
- snippetsfilters/status
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ resources:
- bases/gateway.nginx.org_nginxgateways.yaml
- bases/gateway.nginx.org_nginxproxies.yaml
- bases/gateway.nginx.org_observabilitypolicies.yaml
- bases/gateway.nginx.org_snippetsfilters.yaml
- bases/gateway.nginx.org_upstreamsettingspolicies.yaml
2 changes: 2 additions & 0 deletions deploy/aws-nlb/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -107,6 +108,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions deploy/azure/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -107,6 +108,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
633 changes: 633 additions & 0 deletions deploy/crds.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions deploy/default/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -107,6 +108,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions deploy/experimental-nginx-plus/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -120,6 +121,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions deploy/experimental/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -112,6 +113,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions deploy/nginx-plus/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -115,6 +116,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions deploy/nodeport/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -107,6 +108,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions deploy/openshift/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
verbs:
- list
- watch
Expand All @@ -107,6 +108,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
verbs:
- update
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions deploy/snippets-filters-nginx-plus/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
- snippetsfilters
verbs:
- list
Expand All @@ -116,6 +117,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
- snippetsfilters/status
verbs:
- update
Expand Down
2 changes: 2 additions & 0 deletions deploy/snippets-filters/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ rules:
- nginxproxies
- clientsettingspolicies
- observabilitypolicies
- upstreamsettingspolicies
- snippetsfilters
verbs:
- list
Expand All @@ -108,6 +109,7 @@ rules:
- nginxgateways/status
- clientsettingspolicies/status
- observabilitypolicies/status
- upstreamsettingspolicies/status
- snippetsfilters/status
verbs:
- update
Expand Down
37 changes: 37 additions & 0 deletions examples/upstream-settings-policy/cafe-routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: coffee
spec:
parentRefs:
- name: gateway
sectionName: http
hostnames:
- "cafe.example.com"
rules:
- matches:
- path:
type: PathPrefix
value: /coffee
backendRefs:
- name: coffee
port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: tea
spec:
parentRefs:
- name: gateway
sectionName: http
hostnames:
- "cafe.example.com"
rules:
- matches:
- path:
type: Exact
value: /tea
backendRefs:
- name: tea
port: 80
65 changes: 65 additions & 0 deletions examples/upstream-settings-policy/cafe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: coffee
spec:
replicas: 1
selector:
matchLabels:
app: coffee
template:
metadata:
labels:
app: coffee
spec:
containers:
- name: coffee
image: nginxdemos/nginx-hello:plain-text
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: coffee
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: coffee
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tea
spec:
replicas: 1
selector:
matchLabels:
app: tea
template:
metadata:
labels:
app: tea
spec:
containers:
- name: tea
image: nginxdemos/nginx-hello:plain-text
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: tea
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: tea
11 changes: 11 additions & 0 deletions examples/upstream-settings-policy/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gateway
spec:
gatewayClassName: nginx
listeners:
- name: http
port: 80
protocol: HTTP
hostname: "*.example.com"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
targetRefs:
- group: core
kind: Service
name: service
name: coffee
keepAlive:
connections: 32
requests: 1001
Expand Down
12 changes: 10 additions & 2 deletions internal/framework/kinds/kinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

// Gateway API Kinds.
const (
// Gateway is the Gateway Kind.
// Gateway is the Gateway kind.
Gateway = "Gateway"
// GatewayClass is the GatewayClass Kind.
// GatewayClass is the GatewayClass kind.
GatewayClass = "GatewayClass"
// HTTPRoute is the HTTPRoute kind.
HTTPRoute = "HTTPRoute"
Expand All @@ -23,6 +23,12 @@ const (
TLSRoute = "TLSRoute"
)

// Core API Kinds.
const (
// Service is the Service kind.
Service = "Service"
)

// NGINX Gateway Fabric kinds.
const (
// ClientSettingsPolicy is the ClientSettingsPolicy kind.
Expand All @@ -33,6 +39,8 @@ const (
NginxProxy = "NginxProxy"
// SnippetsFilter is the SnippetsFilter kind.
SnippetsFilter = "SnippetsFilter"
// UpstreamSettingsPolicy is the UpstreamSettingsPolicy kind.
UpstreamSettingsPolicy = "UpstreamSettingsPolicy"
)

// MustExtractGVK is a function that extracts the GroupVersionKind (GVK) of a client.object.
Expand Down
12 changes: 12 additions & 0 deletions internal/mode/static/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies/clientsettings"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies/observability"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies/upstreamsettings"
ngxvalidation "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/validation"
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
ngxruntime "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/runtime"
Expand Down Expand Up @@ -311,6 +312,10 @@
GVK: mustExtractGVK(&ngfAPI.ObservabilityPolicy{}),
Validator: observability.NewValidator(validator),
},
{
GVK: mustExtractGVK(&ngfAPI.UpstreamSettingsPolicy{}),
Validator: upstreamsettings.NewValidator(validator),
},

Check warning on line 318 in internal/mode/static/manager.go

View check run for this annotation

Codecov / codecov/patch

internal/mode/static/manager.go#L315-L318

Added lines #L315 - L318 were not covered by tests
}

return policies.NewManager(mustExtractGVK, cfgs...)
Expand Down Expand Up @@ -492,6 +497,12 @@
controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}),
},
},
{
objectType: &ngfAPI.UpstreamSettingsPolicy{},
options: []controller.Option{
controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}),
},
},
}

if cfg.ExperimentalFeatures {
Expand Down Expand Up @@ -728,6 +739,7 @@
&gatewayv1.GRPCRouteList{},
&ngfAPI.ClientSettingsPolicyList{},
&ngfAPI.ObservabilityPolicyList{},
&ngfAPI.UpstreamSettingsPolicyList{},
partialObjectMetadataList,
}

Expand Down
Loading
Loading