Skip to content

Commit a60ebfa

Browse files
feat(tenant): support gateway/class (#1463)
* feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> Co-authored-by: Oliver Bähler <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> * feat(tenant): support gateway/class Signed-off-by: Hristo Hristov <[email protected]> --------- Signed-off-by: Hristo Hristov <[email protected]> Co-authored-by: Oliver Bähler <[email protected]>
1 parent 7d0a4c5 commit a60ebfa

25 files changed

+895
-293
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,15 @@ golint: golangci-lint
224224
e2e: ginkgo
225225
$(MAKE) e2e-build && $(MAKE) e2e-exec && $(MAKE) e2e-destroy
226226

227+
API_GW := none
228+
API_GW_VERSION := v1.3.0
229+
API_GW_LOOKUP := kubernetes-sigs/gateway-api/
230+
e2e-install-deps:
231+
@$(KUBECTL) apply --force-conflicts --server-side=true -f https://github.com/$(API_GW_LOOKUP)/releases/download/$(API_GW_VERSION)/standard-install.yaml
232+
227233
e2e-build: kind
228234
$(KIND) create cluster --wait=60s --name $(CLUSTER_NAME) --image kindest/node:$(KUBERNETES_SUPPORTED_VERSION)
235+
$(MAKE) e2e-install-deps
229236
$(MAKE) e2e-install
230237

231238
.PHONY: e2e-install
@@ -266,6 +273,7 @@ trace-e2e: kind
266273
$(KIND) create cluster --wait=60s --image kindest/node:$(KUBERNETES_SUPPORTED_VERSION) --config hack/kind-cluster.yml
267274
$(MAKE) e2e-load-image CLUSTER_NAME=capsule-tracing IMAGE=$(CAPSULE_IMG) VERSION=tracing
268275
$(MAKE) trace-install
276+
$(MAKE) e2e-install-deps
269277
$(MAKE) e2e-exec
270278
$(KIND) delete cluster --name capsule-tracing
271279

api/v1beta2/gateway_options.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2020-2023 Project Capsule Authors.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1beta2
5+
6+
import (
7+
"github.com/projectcapsule/capsule/pkg/api"
8+
)
9+
10+
type GatewayOptions struct {
11+
AllowedClasses *api.SelectionListWithDefaultSpec `json:"allowedClasses,omitempty"`
12+
}

api/v1beta2/tenant_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ type TenantSpec struct {
4949
// A default value can be specified, and all the Pod resources created will inherit the declared class.
5050
// Optional.
5151
PriorityClasses *api.DefaultAllowedListSpec `json:"priorityClasses,omitempty"`
52+
// Specifies options for the GatewayClass resources.
53+
GatewayOptions GatewayOptions `json:"gatewayOptions,omitempty"`
5254
// Toggling the Tenant resources cordoning, when enable resources cannot be deleted.
5355
//+kubebuilder:default:=false
5456
Cordoned bool `json:"cordoned,omitempty"`

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/capsule/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ Here the values you can override:
212212
| webhooks.hooks.defaults.pvc.failurePolicy | string | `"Fail"` | |
213213
| webhooks.hooks.defaults.pvc.namespaceSelector.matchExpressions[0].key | string | `"capsule.clastix.io/tenant"` | |
214214
| webhooks.hooks.defaults.pvc.namespaceSelector.matchExpressions[0].operator | string | `"Exists"` | |
215+
| webhooks.hooks.gateways.failurePolicy | string | `"Fail"` | |
216+
| webhooks.hooks.gateways.namespaceSelector.matchExpressions[0].key | string | `"capsule.clastix.io/tenant"` | |
217+
| webhooks.hooks.gateways.namespaceSelector.matchExpressions[0].operator | string | `"Exists"` | |
215218
| webhooks.hooks.ingresses.failurePolicy | string | `"Fail"` | |
216219
| webhooks.hooks.ingresses.namespaceSelector.matchExpressions[0].key | string | `"capsule.clastix.io/tenant"` | |
217220
| webhooks.hooks.ingresses.namespaceSelector.matchExpressions[0].operator | string | `"Exists"` | |

charts/capsule/crds/capsule.clastix.io_tenants.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,57 @@ spec:
11601160
If unset, Tenant uses CapsuleConfiguration's forceTenantPrefix
11611161
Optional
11621162
type: boolean
1163+
gatewayOptions:
1164+
description: Specifies options for the GatewayClass resources.
1165+
properties:
1166+
allowedClasses:
1167+
properties:
1168+
default:
1169+
type: string
1170+
matchExpressions:
1171+
description: matchExpressions is a list of label selector
1172+
requirements. The requirements are ANDed.
1173+
items:
1174+
description: |-
1175+
A label selector requirement is a selector that contains values, a key, and an operator that
1176+
relates the key and values.
1177+
properties:
1178+
key:
1179+
description: key is the label key that the selector
1180+
applies to.
1181+
type: string
1182+
operator:
1183+
description: |-
1184+
operator represents a key's relationship to a set of values.
1185+
Valid operators are In, NotIn, Exists and DoesNotExist.
1186+
type: string
1187+
values:
1188+
description: |-
1189+
values is an array of string values. If the operator is In or NotIn,
1190+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
1191+
the values array must be empty. This array is replaced during a strategic
1192+
merge patch.
1193+
items:
1194+
type: string
1195+
type: array
1196+
x-kubernetes-list-type: atomic
1197+
required:
1198+
- key
1199+
- operator
1200+
type: object
1201+
type: array
1202+
x-kubernetes-list-type: atomic
1203+
matchLabels:
1204+
additionalProperties:
1205+
type: string
1206+
description: |-
1207+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
1208+
map is equivalent to an element of matchExpressions, whose key field is "key", the
1209+
operator is "In", and the values array contains only "value". The requirements are ANDed.
1210+
type: object
1211+
type: object
1212+
x-kubernetes-map-type: atomic
1213+
type: object
11631214
imagePullPolicies:
11641215
description: Specify the allowed values for the imagePullPolicies
11651216
option in Pod resources. Capsule assures that all Pod resources

charts/capsule/templates/mutatingwebhookconfiguration.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ webhooks:
8181
sideEffects: None
8282
timeoutSeconds: {{ $.Values.webhooks.mutatingWebhooksTimeoutSeconds }}
8383
{{- end }}
84+
{{- with .Values.webhooks.hooks.gateways }}
85+
- admissionReviewVersions:
86+
- v1
87+
clientConfig:
88+
{{- include "capsule.webhooks.service" (dict "path" "/defaults" "ctx" $) | nindent 4 }}
89+
failurePolicy: {{ .failurePolicy }}
90+
name: gateway.defaults.projectcapsule.dev
91+
rules:
92+
- apiGroups:
93+
- gateway.networking.k8s.io
94+
apiVersions:
95+
- v1
96+
operations:
97+
- CREATE
98+
- UPDATE
99+
resources:
100+
- gateways
101+
scope: "Namespaced"
102+
namespaceSelector:
103+
{{- toYaml .namespaceSelector | nindent 4}}
104+
sideEffects: None
105+
timeoutSeconds: {{ $.Values.webhooks.mutatingWebhooksTimeoutSeconds }}
106+
{{- end }}
84107
{{- with (mergeOverwrite .Values.webhooks.hooks.namespace.mutation .Values.webhooks.hooks.namespaceOwnerReference) }}
85108
- admissionReviewVersions:
86109
- v1

charts/capsule/templates/validatingwebhookconfiguration.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,32 @@ webhooks:
4040
sideEffects: None
4141
timeoutSeconds: {{ $.Values.webhooks.validatingWebhooksTimeoutSeconds }}
4242
{{- end }}
43+
{{- with .Values.webhooks.hooks.gateways }}
44+
- admissionReviewVersions:
45+
- v1
46+
- v1beta1
47+
clientConfig:
48+
{{- include "capsule.webhooks.service" (dict "path" "/gateways" "ctx" $) | nindent 4 }}
49+
failurePolicy: {{ .failurePolicy }}
50+
matchPolicy: Equivalent
51+
name: gateway.projectcapsule.dev
52+
namespaceSelector:
53+
{{- toYaml .namespaceSelector | nindent 4}}
54+
objectSelector: {}
55+
rules:
56+
- apiGroups:
57+
- gateway.networking.k8s.io
58+
apiVersions:
59+
- v1
60+
operations:
61+
- CREATE
62+
- UPDATE
63+
resources:
64+
- gateways
65+
scope: Namespaced
66+
sideEffects: None
67+
timeoutSeconds: {{ $.Values.webhooks.validatingWebhooksTimeoutSeconds }}
68+
{{- end }}
4369
{{- with .Values.webhooks.hooks.ingresses }}
4470
- admissionReviewVersions:
4571
- v1

charts/capsule/values.schema.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,33 @@
629629
},
630630
"type": "object"
631631
},
632+
"gateways": {
633+
"properties": {
634+
"failurePolicy": {
635+
"type": "string"
636+
},
637+
"namespaceSelector": {
638+
"properties": {
639+
"matchExpressions": {
640+
"items": {
641+
"properties": {
642+
"key": {
643+
"type": "string"
644+
},
645+
"operator": {
646+
"type": "string"
647+
}
648+
},
649+
"type": "object"
650+
},
651+
"type": "array"
652+
}
653+
},
654+
"type": "object"
655+
}
656+
},
657+
"type": "object"
658+
},
632659
"ingresses": {
633660
"properties": {
634661
"failurePolicy": {

charts/capsule/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ webhooks:
289289
operator: Exists
290290
- key: projectcapsule.dev/cordoned
291291
operator: Exists
292+
gateways:
293+
failurePolicy: Fail
294+
namespaceSelector:
295+
matchExpressions:
296+
- key: capsule.clastix.io/tenant
297+
operator: Exists
292298
ingresses:
293299
failurePolicy: Fail
294300
namespaceSelector:

0 commit comments

Comments
 (0)