Skip to content

Commit 3c91bc8

Browse files
author
Kate Osborn
committed
Implement ClientSettingsPolicy Attachment
1 parent 4cb9578 commit 3c91bc8

File tree

89 files changed

+7902
-392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+7902
-392
lines changed

apis/v1alpha1/clientsettingspolicy_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ type ClientKeepAlive struct {
9595

9696
// Timeout defines the keep-alive timeouts for clients.
9797
//
98+
// +kubebuilder:validation:XValidation:message="header can only be specified if server is specified",rule="!(has(self.header) && !has(self.server))"
99+
//
100+
//
98101
// +optional
102+
//nolint:lll
99103
Timeout *ClientKeepAliveTimeout `json:"timeout,omitempty"`
100104
}
101105

apis/v1alpha1/policy_methods.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package v1alpha1
2+
3+
import (
4+
"sigs.k8s.io/gateway-api/apis/v1alpha2"
5+
)
6+
7+
// FIXME(kate-osborn): https://github.com/nginxinc/nginx-gateway-fabric/issues/1939.
8+
// Figure out a way to generate these methods for all our policies.
9+
// These methods implement the policies.Policy interface which extends client.Object to add the following methods.
10+
11+
func (p *ClientSettingsPolicy) GetTargetRef() v1alpha2.PolicyTargetReference {
12+
return p.Spec.TargetRef
13+
}
14+
15+
func (p *ClientSettingsPolicy) GetPolicyStatus() v1alpha2.PolicyStatus {
16+
return p.Status
17+
}
18+
19+
func (p *ClientSettingsPolicy) SetPolicyStatus(status v1alpha2.PolicyStatus) {
20+
p.Status = status
21+
}

charts/nginx-gateway-fabric/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ spec:
124124
mountPath: /etc/nginx/secrets
125125
- name: nginx-run
126126
mountPath: /var/run/nginx
127+
- name: nginx-includes
128+
mountPath: /etc/nginx/includes
127129
{{- with .Values.nginxGateway.extraVolumeMounts -}}
128130
{{ toYaml . | nindent 8 }}
129131
{{- end }}
@@ -161,6 +163,8 @@ spec:
161163
mountPath: /var/cache/nginx
162164
- name: nginx-lib
163165
mountPath: /var/lib/nginx
166+
- name: nginx-includes
167+
mountPath: /etc/nginx/includes
164168
{{- with .Values.nginx.extraVolumeMounts -}}
165169
{{ toYaml . | nindent 8 }}
166170
{{- end }}
@@ -195,6 +199,8 @@ spec:
195199
emptyDir: {}
196200
- name: nginx-lib
197201
emptyDir: {}
202+
- name: nginx-includes
203+
emptyDir: {}
198204
{{- with .Values.extraVolumes -}}
199205
{{ toYaml . | nindent 6 }}
200206
{{- end }}

charts/nginx-gateway-fabric/templates/rbac.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ rules:
113113
- gateway.nginx.org
114114
resources:
115115
- nginxgateways
116+
- clientsettingspolicies
116117
verbs:
117118
- get
118119
- list
@@ -128,6 +129,7 @@ rules:
128129
- gateway.nginx.org
129130
resources:
130131
- nginxgateways/status
132+
- clientsettingspolicies/status
131133
verbs:
132134
- update
133135
{{- if .Values.nginxGateway.leaderElection.enable }}

config/crd/bases/gateway.nginx.org_clientsettingspolicies.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ spec:
108108
pattern: ^\d{1,4}(ms|s)?$
109109
type: string
110110
type: object
111+
x-kubernetes-validations:
112+
- message: header can only be specified if server is specified
113+
rule: '!(has(self.header) && !has(self.server))'
111114
type: object
112115
targetRef:
113116
description: |-

conformance/provisioner/static-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ spec:
7676
mountPath: /etc/nginx/secrets
7777
- name: nginx-run
7878
mountPath: /var/run/nginx
79+
- name: nginx-includes
80+
mountPath: /etc/nginx/includes
7981
- image: ghcr.io/nginxinc/nginx-gateway-fabric/nginx:edge
8082
imagePullPolicy: Always
8183
name: nginx
@@ -106,6 +108,8 @@ spec:
106108
mountPath: /var/cache/nginx
107109
- name: nginx-lib
108110
mountPath: /var/lib/nginx
111+
- name: nginx-includes
112+
mountPath: /etc/nginx/includes
109113
terminationGracePeriodSeconds: 30
110114
serviceAccountName: nginx-gateway
111115
shareProcessNamespace: true
@@ -125,3 +129,5 @@ spec:
125129
emptyDir: {}
126130
- name: nginx-lib
127131
emptyDir: {}
132+
- name: nginx-includes
133+
emptyDir: {}

deploy/manifests/nginx-gateway-experimental.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ rules:
9595
- gateway.nginx.org
9696
resources:
9797
- nginxgateways
98+
- clientsettingspolicies
9899
verbs:
99100
- get
100101
- list
@@ -110,6 +111,7 @@ rules:
110111
- gateway.nginx.org
111112
resources:
112113
- nginxgateways/status
114+
- clientsettingspolicies/status
113115
verbs:
114116
- update
115117
- apiGroups:
@@ -228,6 +230,8 @@ spec:
228230
mountPath: /etc/nginx/secrets
229231
- name: nginx-run
230232
mountPath: /var/run/nginx
233+
- name: nginx-includes
234+
mountPath: /etc/nginx/includes
231235
- image: ghcr.io/nginxinc/nginx-gateway-fabric/nginx:edge
232236
imagePullPolicy: Always
233237
name: nginx
@@ -258,6 +262,8 @@ spec:
258262
mountPath: /var/cache/nginx
259263
- name: nginx-lib
260264
mountPath: /var/lib/nginx
265+
- name: nginx-includes
266+
mountPath: /etc/nginx/includes
261267
terminationGracePeriodSeconds: 30
262268
serviceAccountName: nginx-gateway
263269
shareProcessNamespace: true
@@ -277,6 +283,8 @@ spec:
277283
emptyDir: {}
278284
- name: nginx-lib
279285
emptyDir: {}
286+
- name: nginx-includes
287+
emptyDir: {}
280288
---
281289
# Source: nginx-gateway-fabric/templates/gatewayclass.yaml
282290
apiVersion: gateway.networking.k8s.io/v1

deploy/manifests/nginx-gateway.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ rules:
9090
- gateway.nginx.org
9191
resources:
9292
- nginxgateways
93+
- clientsettingspolicies
9394
verbs:
9495
- get
9596
- list
@@ -105,6 +106,7 @@ rules:
105106
- gateway.nginx.org
106107
resources:
107108
- nginxgateways/status
109+
- clientsettingspolicies/status
108110
verbs:
109111
- update
110112
- apiGroups:
@@ -222,6 +224,8 @@ spec:
222224
mountPath: /etc/nginx/secrets
223225
- name: nginx-run
224226
mountPath: /var/run/nginx
227+
- name: nginx-includes
228+
mountPath: /etc/nginx/includes
225229
- image: ghcr.io/nginxinc/nginx-gateway-fabric/nginx:edge
226230
imagePullPolicy: Always
227231
name: nginx
@@ -252,6 +256,8 @@ spec:
252256
mountPath: /var/cache/nginx
253257
- name: nginx-lib
254258
mountPath: /var/lib/nginx
259+
- name: nginx-includes
260+
mountPath: /etc/nginx/includes
255261
terminationGracePeriodSeconds: 30
256262
serviceAccountName: nginx-gateway
257263
shareProcessNamespace: true
@@ -271,6 +277,8 @@ spec:
271277
emptyDir: {}
272278
- name: nginx-lib
273279
emptyDir: {}
280+
- name: nginx-includes
281+
emptyDir: {}
274282
---
275283
# Source: nginx-gateway-fabric/templates/gatewayclass.yaml
276284
apiVersion: gateway.networking.k8s.io/v1

deploy/manifests/nginx-plus-gateway-experimental.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ rules:
101101
- gateway.nginx.org
102102
resources:
103103
- nginxgateways
104+
- clientsettingspolicies
104105
verbs:
105106
- get
106107
- list
@@ -116,6 +117,7 @@ rules:
116117
- gateway.nginx.org
117118
resources:
118119
- nginxgateways/status
120+
- clientsettingspolicies/status
119121
verbs:
120122
- update
121123
- apiGroups:
@@ -235,6 +237,8 @@ spec:
235237
mountPath: /etc/nginx/secrets
236238
- name: nginx-run
237239
mountPath: /var/run/nginx
240+
- name: nginx-includes
241+
mountPath: /etc/nginx/includes
238242
- image: nginx-gateway-fabric/nginx-plus:edge
239243
imagePullPolicy: Always
240244
name: nginx
@@ -265,6 +269,8 @@ spec:
265269
mountPath: /var/cache/nginx
266270
- name: nginx-lib
267271
mountPath: /var/lib/nginx
272+
- name: nginx-includes
273+
mountPath: /etc/nginx/includes
268274
terminationGracePeriodSeconds: 30
269275
serviceAccountName: nginx-gateway
270276
shareProcessNamespace: true
@@ -284,6 +290,8 @@ spec:
284290
emptyDir: {}
285291
- name: nginx-lib
286292
emptyDir: {}
293+
- name: nginx-includes
294+
emptyDir: {}
287295
---
288296
# Source: nginx-gateway-fabric/templates/gatewayclass.yaml
289297
apiVersion: gateway.networking.k8s.io/v1

deploy/manifests/nginx-plus-gateway.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ rules:
9696
- gateway.nginx.org
9797
resources:
9898
- nginxgateways
99+
- clientsettingspolicies
99100
verbs:
100101
- get
101102
- list
@@ -111,6 +112,7 @@ rules:
111112
- gateway.nginx.org
112113
resources:
113114
- nginxgateways/status
115+
- clientsettingspolicies/status
114116
verbs:
115117
- update
116118
- apiGroups:
@@ -229,6 +231,8 @@ spec:
229231
mountPath: /etc/nginx/secrets
230232
- name: nginx-run
231233
mountPath: /var/run/nginx
234+
- name: nginx-includes
235+
mountPath: /etc/nginx/includes
232236
- image: nginx-gateway-fabric/nginx-plus:edge
233237
imagePullPolicy: Always
234238
name: nginx
@@ -259,6 +263,8 @@ spec:
259263
mountPath: /var/cache/nginx
260264
- name: nginx-lib
261265
mountPath: /var/lib/nginx
266+
- name: nginx-includes
267+
mountPath: /etc/nginx/includes
262268
terminationGracePeriodSeconds: 30
263269
serviceAccountName: nginx-gateway
264270
shareProcessNamespace: true
@@ -278,6 +284,8 @@ spec:
278284
emptyDir: {}
279285
- name: nginx-lib
280286
emptyDir: {}
287+
- name: nginx-includes
288+
emptyDir: {}
281289
---
282290
# Source: nginx-gateway-fabric/templates/gatewayclass.yaml
283291
apiVersion: gateway.networking.k8s.io/v1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
TODO(kate-osborn): remove before merging to main
2+
3+
# Client Settings Policy
4+
5+
This contains examples for testing Client Settings Policy.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: coffee
5+
spec:
6+
parentRefs:
7+
- name: gateway
8+
sectionName: http
9+
- name: gateway
10+
sectionName: http2
11+
hostnames:
12+
- "cafe.example.com"
13+
- "cafe.example.org"
14+
rules:
15+
- matches:
16+
- path:
17+
type: PathPrefix
18+
value: /coffee
19+
backendRefs:
20+
- name: coffee
21+
port: 80
22+
---
23+
apiVersion: gateway.networking.k8s.io/v1
24+
kind: HTTPRoute
25+
metadata:
26+
name: tea
27+
spec:
28+
parentRefs:
29+
- name: gateway
30+
sectionName: http
31+
- name: gateway
32+
sectionName: http2
33+
hostnames:
34+
- "cafe.example.com"
35+
- "cafe.example.org"
36+
rules:
37+
- matches:
38+
- path:
39+
type: Exact
40+
value: /tea
41+
backendRefs:
42+
- name: tea
43+
port: 80
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: coffee
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: coffee
10+
template:
11+
metadata:
12+
labels:
13+
app: coffee
14+
spec:
15+
containers:
16+
- name: coffee
17+
image: nginxdemos/nginx-hello:plain-text
18+
ports:
19+
- containerPort: 8080
20+
---
21+
apiVersion: v1
22+
kind: Service
23+
metadata:
24+
name: coffee
25+
spec:
26+
ports:
27+
- port: 80
28+
targetPort: 8080
29+
protocol: TCP
30+
name: http
31+
selector:
32+
app: coffee
33+
---
34+
apiVersion: apps/v1
35+
kind: Deployment
36+
metadata:
37+
name: tea
38+
spec:
39+
replicas: 1
40+
selector:
41+
matchLabels:
42+
app: tea
43+
template:
44+
metadata:
45+
labels:
46+
app: tea
47+
spec:
48+
containers:
49+
- name: tea
50+
image: nginxdemos/nginx-hello:plain-text
51+
ports:
52+
- containerPort: 8080
53+
---
54+
apiVersion: v1
55+
kind: Service
56+
metadata:
57+
name: tea
58+
spec:
59+
ports:
60+
- port: 80
61+
targetPort: 8080
62+
protocol: TCP
63+
name: http
64+
selector:
65+
app: tea

0 commit comments

Comments
 (0)