Skip to content

Commit 0b42780

Browse files
authored
Merge pull request #65 from zvlb/main
Add Api HttpFilter
2 parents 2c14ffe + 28524d8 commit 0b42780

24 files changed

+450
-58
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,13 @@ resources:
8383
kind: AccessLogConfig
8484
path: github.com/kaasops/envoy-xds-controller/api/v1alpha1
8585
version: v1alpha1
86+
- api:
87+
crdVersion: v1
88+
namespaced: true
89+
controller: true
90+
domain: kaasops.io
91+
group: envoy
92+
kind: HttpFilter
93+
path: github.com/kaasops/envoy-xds-controller/api/v1alpha1
94+
version: v1alpha1
8695
version: "3"

api/v1alpha1/httpfilter_types.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright 2023.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
runtime "k8s.io/apimachinery/pkg/runtime"
22+
)
23+
24+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
25+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
26+
27+
//+kubebuilder:object:root=true
28+
//+kubebuilder:subresource:status
29+
30+
// HttpFilter is the Schema for the httpfilters API
31+
type HttpFilter struct {
32+
metav1.TypeMeta `json:",inline"`
33+
metav1.ObjectMeta `json:"metadata,omitempty"`
34+
35+
Spec []*runtime.RawExtension `json:"spec,omitempty"`
36+
}
37+
38+
//+kubebuilder:object:root=true
39+
40+
// HttpFilterList contains a list of HttpFilter
41+
type HttpFilterList struct {
42+
metav1.TypeMeta `json:",inline"`
43+
metav1.ListMeta `json:"metadata,omitempty"`
44+
Items []HttpFilter `json:"items"`
45+
}
46+
47+
func init() {
48+
SchemeBuilder.Register(&HttpFilter{}, &HttpFilterList{})
49+
}

api/v1alpha1/virtualservice_types.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ import (
2828
type VirtualServiceSpec struct {
2929
VirtualHost *runtime.RawExtension `json:"virtualHost,omitempty"`
3030
// +kubebuilder:validation:Required
31-
Listener *ResourceRef `json:"listener,omitempty"`
32-
TlsConfig *TlsConfig `json:"tlsConfig,omitempty"`
33-
AccessLog *runtime.RawExtension `json:"accessLog,omitempty"`
34-
AccessLogConfig *ResourceRef `json:"accessLogConfig,omitempty"`
35-
AdditionalRoutes []*ResourceRef `json:"additionalRoutes,omitempty"`
31+
Listener *ResourceRef `json:"listener,omitempty"`
32+
TlsConfig *TlsConfig `json:"tlsConfig,omitempty"`
33+
AccessLog *runtime.RawExtension `json:"accessLog,omitempty"`
34+
AccessLogConfig *ResourceRef `json:"accessLogConfig,omitempty"`
35+
AdditionalHttpFilters []*ResourceRef `json:"additionalHttpFilters,omitempty"`
36+
AdditionalRoutes []*ResourceRef `json:"additionalRoutes,omitempty"`
3637

3738
// HTTPFilters for use custom HTTP filters
3839
HTTPFilters []*runtime.RawExtension `json:"httpFilters,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.11.1
7+
creationTimestamp: null
8+
name: httpfilters.envoy.kaasops.io
9+
spec:
10+
group: envoy.kaasops.io
11+
names:
12+
kind: HttpFilter
13+
listKind: HttpFilterList
14+
plural: httpfilters
15+
singular: httpfilter
16+
scope: Namespaced
17+
versions:
18+
- name: v1alpha1
19+
schema:
20+
openAPIV3Schema:
21+
description: HttpFilter is the Schema for the httpfilters API
22+
properties:
23+
apiVersion:
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
27+
type: string
28+
kind:
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
type: string
33+
metadata:
34+
type: object
35+
spec:
36+
items:
37+
type: object
38+
x-kubernetes-preserve-unknown-fields: true
39+
type: array
40+
type: object
41+
served: true
42+
storage: true
43+
subresources:
44+
status: {}

config/crd/bases/envoy.kaasops.io_virtualservices.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ spec:
5454
name:
5555
type: string
5656
type: object
57+
additionalHttpFilters:
58+
items:
59+
properties:
60+
name:
61+
type: string
62+
type: object
63+
type: array
5764
additionalRoutes:
5865
items:
5966
properties:

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ resources:
1010
- bases/envoy.kaasops.io_secrets.yaml
1111
- bases/envoy.kaasops.io_virtualservices.yaml
1212
- bases/envoy.kaasops.io_accesslogconfigs.yaml
13+
- bases/envoy.kaasops.io_httpfilters.yaml
1314
#+kubebuilder:scaffold:crdkustomizeresource
1415

1516
patchesStrategicMerge:
@@ -23,6 +24,7 @@ patchesStrategicMerge:
2324
#- patches/webhook_in_secrets.yaml
2425
#- patches/webhook_in_virtualservices.yaml
2526
#- patches/webhook_in_accesslogconfigs.yaml
27+
#- patches/webhook_in_httpfilter.yaml
2628
#+kubebuilder:scaffold:crdkustomizewebhookpatch
2729

2830
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
@@ -35,6 +37,7 @@ patchesStrategicMerge:
3537
#- patches/cainjection_in_secrets.yaml
3638
#- patches/cainjection_in_virtualservices.yaml
3739
#- patches/cainjection_in_accesslogconfigs.yaml
40+
#- patches/cainjection_in_httpfilter.yaml
3841
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
3942

4043
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
name: httpfilter.envoy.kaasops.io
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following patch enables a conversion webhook for the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: httpfilter.envoy.kaasops.io
6+
spec:
7+
conversion:
8+
strategy: Webhook
9+
webhook:
10+
clientConfig:
11+
service:
12+
namespace: system
13+
name: webhook-service
14+
path: /convert
15+
conversionReviewVersions:
16+
- v1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# permissions for end users to edit httpfilters.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: clusterrole
7+
app.kubernetes.io/instance: httpfilter-editor-role
8+
app.kubernetes.io/component: rbac
9+
app.kubernetes.io/created-by: envoy-xds-controller
10+
app.kubernetes.io/part-of: envoy-xds-controller
11+
app.kubernetes.io/managed-by: kustomize
12+
name: httpfilter-editor-role
13+
rules:
14+
- apiGroups:
15+
- envoy.kaasops.io
16+
resources:
17+
- httpfilters
18+
verbs:
19+
- create
20+
- delete
21+
- get
22+
- list
23+
- patch
24+
- update
25+
- watch
26+
- apiGroups:
27+
- envoy.kaasops.io
28+
resources:
29+
- httpfilters/status
30+
verbs:
31+
- get

0 commit comments

Comments
 (0)