Skip to content

Commit 8876cd2

Browse files
authored
chore: GatewayProxy support provider (#87)
Signed-off-by: ashing <[email protected]>
1 parent b50f98e commit 8876cd2

File tree

4 files changed

+288
-1
lines changed

4 files changed

+288
-1
lines changed

api/v1alpha1/gatewayproxy_types.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,95 @@ type GatewayProxySpec struct {
2929
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3030
// Important: Run "make" to regenerate code after modifying this file
3131

32+
PublishService string `json:"publishService,omitempty"`
33+
StatusAddress []string `json:"statusAddress,omitempty"`
34+
Provider *GatewayProxyProvider `json:"provider,omitempty"`
3235
Plugins []GatewayProxyPlugin `json:"plugins,omitempty"`
3336
PluginMetadata map[string]apiextensionsv1.JSON `json:"pluginMetadata,omitempty"`
3437
}
3538

39+
// ProviderType defines the type of provider
40+
// +kubebuilder:validation:Enum=ControlPlane
41+
type ProviderType string
42+
43+
const (
44+
// ProviderTypeControlPlane represents the control plane provider type
45+
ProviderTypeControlPlane ProviderType = "ControlPlane"
46+
)
47+
48+
// GatewayProxyProvider defines the provider configuration for GatewayProxy
49+
// +kubebuilder:validation:XValidation:rule="self.type == 'ControlPlane' ? has(self.controlPlane) : true",message="controlPlane must be specified when type is ControlPlane"
50+
type GatewayProxyProvider struct {
51+
// Type specifies the type of provider
52+
// +kubebuilder:validation:Required
53+
Type ProviderType `json:"type"`
54+
55+
// ControlPlane specifies the configuration for control plane provider
56+
// +optional
57+
ControlPlane *ControlPlaneProvider `json:"controlPlane,omitempty"`
58+
}
59+
60+
// AuthType defines the type of authentication
61+
// +kubebuilder:validation:Enum=AdminKey
62+
type AuthType string
63+
64+
const (
65+
// AuthTypeAdminKey represents the admin key authentication type
66+
AuthTypeAdminKey AuthType = "AdminKey"
67+
)
68+
69+
// SecretKeySelector defines a reference to a specific key within a Secret
70+
type SecretKeySelector struct {
71+
// Name is the name of the secret
72+
// +kubebuilder:validation:Required
73+
Name string `json:"name"`
74+
75+
// Key is the key in the secret
76+
// +kubebuilder:validation:Required
77+
Key string `json:"key"`
78+
}
79+
80+
// AdminKeyAuth defines the admin key authentication configuration
81+
type AdminKeyAuth struct {
82+
// Value specifies the admin key value directly (not recommended for production)
83+
// +optional
84+
Value string `json:"value,omitempty"`
85+
86+
// ValueFrom specifies the source of the admin key
87+
// +optional
88+
ValueFrom *AdminKeyValueFrom `json:"valueFrom,omitempty"`
89+
}
90+
91+
// AdminKeyValueFrom defines the source of the admin key
92+
type AdminKeyValueFrom struct {
93+
// SecretKeyRef references a key in a Secret
94+
// +optional
95+
SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty"`
96+
}
97+
98+
// ControlPlaneAuth defines the authentication configuration for control plane
99+
type ControlPlaneAuth struct {
100+
// Type specifies the type of authentication
101+
// +kubebuilder:validation:Required
102+
Type AuthType `json:"type"`
103+
104+
// AdminKey specifies the admin key authentication configuration
105+
// +optional
106+
AdminKey *AdminKeyAuth `json:"adminKey,omitempty"`
107+
}
108+
109+
// ControlPlaneProvider defines the configuration for control plane provider
110+
type ControlPlaneProvider struct {
111+
// Endpoints specifies the list of control plane endpoints
112+
// +kubebuilder:validation:Required
113+
// +kubebuilder:validation:MinItems=1
114+
Endpoints []string `json:"endpoints"`
115+
116+
// Auth specifies the authentication configuration
117+
// +kubebuilder:validation:Required
118+
Auth ControlPlaneAuth `json:"auth"`
119+
}
120+
36121
// +kubebuilder:object:root=true
37122
// GatewayProxy is the Schema for the gatewayproxies API
38123
type GatewayProxy struct {

api/v1alpha1/zz_generated.deepcopy.go

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

config/crd/bases/gateway.apisix.io_gatewayproxies.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,82 @@ spec:
5454
type: string
5555
type: object
5656
type: array
57+
provider:
58+
description: GatewayProxyProvider defines the provider configuration
59+
for GatewayProxy
60+
properties:
61+
controlPlane:
62+
description: ControlPlane specifies the configuration for control
63+
plane provider
64+
properties:
65+
auth:
66+
description: Auth specifies the authentication configuration
67+
properties:
68+
adminKey:
69+
description: AdminKey specifies the admin key authentication
70+
configuration
71+
properties:
72+
value:
73+
description: Value specifies the admin key value directly
74+
(not recommended for production)
75+
type: string
76+
valueFrom:
77+
description: ValueFrom specifies the source of the
78+
admin key
79+
properties:
80+
secretKeyRef:
81+
description: SecretKeyRef references a key in
82+
a Secret
83+
properties:
84+
key:
85+
description: Key is the key in the secret
86+
type: string
87+
name:
88+
description: Name is the name of the secret
89+
type: string
90+
required:
91+
- key
92+
- name
93+
type: object
94+
type: object
95+
type: object
96+
type:
97+
description: Type specifies the type of authentication
98+
enum:
99+
- AdminKey
100+
type: string
101+
required:
102+
- type
103+
type: object
104+
endpoints:
105+
description: Endpoints specifies the list of control plane
106+
endpoints
107+
items:
108+
type: string
109+
minItems: 1
110+
type: array
111+
required:
112+
- auth
113+
- endpoints
114+
type: object
115+
type:
116+
description: Type specifies the type of provider
117+
enum:
118+
- ControlPlane
119+
type: string
120+
required:
121+
- type
122+
type: object
123+
x-kubernetes-validations:
124+
- message: controlPlane must be specified when type is ControlPlane
125+
rule: 'self.type == ''ControlPlane'' ? has(self.controlPlane) :
126+
true'
127+
publishService:
128+
type: string
129+
statusAddress:
130+
items:
131+
type: string
132+
type: array
57133
type: object
58134
type: object
59135
served: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ require (
2929
go.uber.org/zap v1.27.0
3030
golang.org/x/net v0.28.0
3131
gopkg.in/yaml.v2 v2.4.0
32-
gopkg.in/yaml.v3 v3.0.1
3332
gorm.io/gorm v1.25.11
3433
helm.sh/helm/v3 v3.15.4
3534
k8s.io/api v0.31.1
@@ -213,6 +212,7 @@ require (
213212
gopkg.in/fsnotify.v1 v1.4.7 // indirect
214213
gopkg.in/inf.v0 v0.9.1 // indirect
215214
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
215+
gopkg.in/yaml.v3 v3.0.1 // indirect
216216
k8s.io/apiserver v0.31.1 // indirect
217217
k8s.io/cli-runtime v0.30.3 // indirect
218218
k8s.io/component-base v0.31.1 // indirect

0 commit comments

Comments
 (0)