Skip to content

Commit 3305f32

Browse files
committed
update CRD docs
1 parent f14c95e commit 3305f32

11 files changed

+251
-151
lines changed

api/v1alpha1/backendtrafficpolicy_types.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ type BackendTrafficPolicy struct {
1010
metav1.TypeMeta `json:",inline"`
1111
metav1.ObjectMeta `json:"metadata,omitempty"`
1212

13+
// BackendTrafficPolicySpec defines traffic handling policies applied to backend services,
14+
// such as load balancing strategy, connection settings, and failover behavior.
1315
Spec BackendTrafficPolicySpec `json:"spec,omitempty"`
1416
Status PolicyStatus `json:"status,omitempty"`
1517
}
@@ -25,57 +27,67 @@ type BackendTrafficPolicySpec struct {
2527
// LoadBalancer represents the load balancer configuration for Kubernetes Service.
2628
// The default strategy is round robin.
2729
LoadBalancer *LoadBalancer `json:"loadbalancer,omitempty" yaml:"loadbalancer,omitempty"`
28-
// The scheme used to talk with the upstream.
29-
//
30+
// Scheme is the protocol used to communicate with the upstream.
31+
// Can be one of `http`, `https`, `grpc`, or `grpcs`.
3032
// +kubebuilder:validation:Enum=http;https;grpc;grpcs;
3133
// +kubebuilder:default=http
3234
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
3335

34-
// How many times that the proxy (Apache APISIX) should do when
35-
// errors occur (error, timeout or bad http status codes like 500, 502).
36+
// Retries specify the number of times the gateway should retry sending
37+
// requests when errors such as timeouts or 502 errors occur.
3638
// +optional
3739
Retries *int `json:"retries,omitempty" yaml:"retries,omitempty"`
3840

39-
// Timeout settings for the read, send and connect to the upstream.
41+
// Timeout sets the read, send, and connect timeouts to the upstream.
4042
Timeout *Timeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
4143

42-
// Configures the host when the request is forwarded to the upstream.
43-
// Can be one of pass, node or rewrite.
44+
// PassHost configures how the host header should be determined when a
45+
// request is forwarded to the upstream.
46+
// Can be one of `pass`, `node` or `rewrite`.
4447
//
4548
// +kubebuilder:validation:Enum=pass;node;rewrite;
4649
// +kubebuilder:default=pass
4750
PassHost string `json:"passHost,omitempty" yaml:"passHost,omitempty"`
4851

49-
// Specifies the host of the Upstream request. This is only valid if
50-
// the passHost is set to rewrite
52+
// UpstreamHost specifies the host of the Upstream request. Used only if
53+
// passHost is set to `rewrite`.
5154
Host Hostname `json:"upstreamHost,omitempty" yaml:"upstreamHost,omitempty"`
5255
}
5356

5457
// LoadBalancer describes the load balancing parameters.
5558
// +kubebuilder:validation:XValidation:rule="!(has(self.key) && self.type != 'chash')"
5659
type LoadBalancer struct {
60+
// Type specifies the load balancing algorithms.
61+
// Can be one of `roundrobin`, `chash`, `ewma`, or `least_conn`.
5762
// +kubebuilder:validation:Enum=roundrobin;chash;ewma;least_conn;
5863
// +kubebuilder:default=roundrobin
5964
// +kubebuilder:validation:Required
6065
Type string `json:"type" yaml:"type"`
61-
// The HashOn and Key fields are required when Type is "chash".
62-
// HashOn represents the key fetching scope.
66+
// HashOn specified the type of field used for hashing, required when Type is `chash`.
67+
// Can be one of `vars`, `header`, `cookie`, `consumer`, or `vars_combinations`.
6368
// +kubebuilder:validation:Enum=vars;header;cookie;consumer;vars_combinations;
6469
// +kubebuilder:default=vars
6570
HashOn string `json:"hashOn,omitempty" yaml:"hashOn,omitempty"`
66-
// Key represents the hash key.
71+
// Key is used with HashOn, generally required when Type is `chash`.
72+
// When HashOn is `header` or `cookie`, specifies the name of the header or cookie.
73+
// When HashOn is `consumer`, key is not required, as the consumer name is used automatically.
74+
// When HashOn is `vars` or `vars_combinations`, key refers to one or a combination of
75+
// [built-in variables](/enterprise/reference/built-in-variables).
6776
Key string `json:"key,omitempty" yaml:"key,omitempty"`
6877
}
6978

7079
type Timeout struct {
80+
// Connection timeout. Default is `60s`.
7181
// +kubebuilder:default="60s"
7282
// +kubebuilder:validation:Pattern=`^[0-9]+s$`
7383
// +kubebuilder:validation:Type=string
7484
Connect metav1.Duration `json:"connect,omitempty" yaml:"connect,omitempty"`
85+
// Send timeout. Default is `60s`.
7586
// +kubebuilder:default="60s"
7687
// +kubebuilder:validation:Pattern=`^[0-9]+s$`
7788
// +kubebuilder:validation:Type=string
7889
Send metav1.Duration `json:"send,omitempty" yaml:"send,omitempty"`
90+
// Read timeout. Default is `60s`.
7991
// +kubebuilder:default="60s"
8092
// +kubebuilder:validation:Pattern=`^[0-9]+s$`
8193
// +kubebuilder:validation:Type=string

api/v1alpha1/consumer_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,54 @@ type Consumer struct {
1111
metav1.TypeMeta `json:",inline"`
1212
metav1.ObjectMeta `json:"metadata,omitempty"`
1313

14+
// ConsumerSpec defines the configuration for a consumer, including consumer name,
15+
// authentication credentials, and plugin settings.
1416
Spec ConsumerSpec `json:"spec,omitempty"`
1517
Status Status `json:"status,omitempty"`
1618
}
1719

1820
type ConsumerSpec struct {
21+
// GatewayRef specifies the gateway details.
1922
GatewayRef GatewayRef `json:"gatewayRef,omitempty"`
23+
// Credentials specifies the credential details of a consumer.
2024
Credentials []Credential `json:"credentials,omitempty"`
25+
// Plugins define the plugins associated with a consumer.
2126
Plugins []Plugin `json:"plugins,omitempty"`
2227
}
2328

2429
type GatewayRef struct {
30+
// Name is the name of the gateway.
2531
// +kubebuilder:validation:Required
2632
// +kubebuilder:validation:MinLength=1
2733
Name string `json:"name"`
34+
// Kind is the type of Kubernetes object. Default to `Gateway`.
2835
// +kubebuilder:default=Gateway
2936
Kind *string `json:"kind,omitempty"`
37+
// Group is the API group the resource belongs to. Default to `gateway.networking.k8s.io`.
3038
// +kubebuilder:default=gateway.networking.k8s.io
3139
Group *string `json:"group,omitempty"`
40+
// Namespace is namespace of the resource.
3241
Namespace *string `json:"namespace,omitempty"`
3342
}
3443

3544
type Credential struct {
3645
// +kubebuilder:validation:Required
3746
// +kubebuilder:validation:Enum=jwt-auth;basic-auth;key-auth;hmac-auth;
47+
// Type specifies the type of authentication to configure credentials for.
48+
// Can be one of `jwt-auth`, `basic-auth`, `key-auth`, or `hmac-auth`.
3849
Type string `json:"type"`
50+
// Config specifies the credential details for authentication.
3951
Config apiextensionsv1.JSON `json:"config,omitempty"`
52+
// SecretRef references to the Secret that contains the credentials.
4053
SecretRef *SecretReference `json:"secretRef,omitempty"`
54+
// Name is the name of the credential.
4155
Name string `json:"name,omitempty"`
4256
}
4357

4458
type SecretReference struct {
59+
// Name is the name of the secret.
4560
Name string `json:"name"`
61+
// Namespace is the namespace of the secret.
4662
Namespace *string `json:"namespace,omitempty"`
4763
}
4864

api/v1alpha1/gatewayproxy_types.go

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,124 +24,137 @@ import (
2424
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2525
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2626

27-
// GatewayProxySpec defines the desired state of GatewayProxy
27+
// GatewayProxySpec defines the desired state of GatewayProxy.
2828
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 specifies the LoadBalancer-type Service whose external address the controller uses to
33+
// update the status of Ingress resources.
3234
PublishService string `json:"publishService,omitempty"`
35+
// StatusAddress specifies the external IP addresses that the controller uses to populate the status field
36+
// of GatewayProxy or Ingress resources for developers to access.
3337
StatusAddress []string `json:"statusAddress,omitempty"`
38+
// Provider configures the provider details.
3439
Provider *GatewayProxyProvider `json:"provider,omitempty"`
40+
// Plugins configure global plugins.
3541
Plugins []GatewayProxyPlugin `json:"plugins,omitempty"`
42+
// PluginMetadata configures common configurations shared by all plugin instances of the same name.
3643
PluginMetadata map[string]apiextensionsv1.JSON `json:"pluginMetadata,omitempty"`
3744
}
3845

39-
// ProviderType defines the type of provider
46+
// ProviderType defines the type of provider.
4047
// +kubebuilder:validation:Enum=ControlPlane
4148
type ProviderType string
4249

4350
const (
44-
// ProviderTypeControlPlane represents the control plane provider type
51+
// ProviderTypeControlPlane represents the control plane provider type.
4552
ProviderTypeControlPlane ProviderType = "ControlPlane"
4653
)
4754

48-
// GatewayProxyProvider defines the provider configuration for GatewayProxy
55+
// GatewayProxyProvider defines the provider configuration for GatewayProxy.
4956
// +kubebuilder:validation:XValidation:rule="self.type == 'ControlPlane' ? has(self.controlPlane) : true",message="controlPlane must be specified when type is ControlPlane"
5057
type GatewayProxyProvider struct {
51-
// Type specifies the type of provider
58+
// Type specifies the type of provider.
5259
// +kubebuilder:validation:Required
5360
Type ProviderType `json:"type"`
5461

55-
// ControlPlane specifies the configuration for control plane provider
62+
// ControlPlane specifies the configuration for control plane provider.
5663
// +optional
5764
ControlPlane *ControlPlaneProvider `json:"controlPlane,omitempty"`
5865
}
5966

60-
// AuthType defines the type of authentication
67+
// AuthType defines the type of authentication.
6168
// +kubebuilder:validation:Enum=AdminKey
6269
type AuthType string
6370

6471
const (
65-
// AuthTypeAdminKey represents the admin key authentication type
72+
// AuthTypeAdminKey represents the admin key authentication type.
6673
AuthTypeAdminKey AuthType = "AdminKey"
6774
)
6875

69-
// SecretKeySelector defines a reference to a specific key within a Secret
76+
// SecretKeySelector defines a reference to a specific key within a Secret.
7077
type SecretKeySelector struct {
71-
// Name is the name of the secret
78+
// Name is the name of the secret.
7279
// +kubebuilder:validation:Required
7380
Name string `json:"name"`
7481

75-
// Key is the key in the secret
82+
// Key is the key in the secret to retrieve the secret from.
7683
// +kubebuilder:validation:Required
7784
Key string `json:"key"`
7885
}
7986

80-
// AdminKeyAuth defines the admin key authentication configuration
87+
// AdminKeyAuth defines the admin key authentication configuration.
8188
type AdminKeyAuth struct {
82-
// Value specifies the admin key value directly (not recommended for production)
89+
// Value sets the admin key value explicitly (not recommended for production).
8390
// +optional
8491
Value string `json:"value,omitempty"`
8592

86-
// ValueFrom specifies the source of the admin key
93+
// ValueFrom specifies the source of the admin key.
8794
// +optional
8895
ValueFrom *AdminKeyValueFrom `json:"valueFrom,omitempty"`
8996
}
9097

91-
// AdminKeyValueFrom defines the source of the admin key
98+
// AdminKeyValueFrom defines the source of the admin key.
9299
type AdminKeyValueFrom struct {
93-
// SecretKeyRef references a key in a Secret
100+
// SecretKeyRef references a key in a Secret.
94101
// +optional
95102
SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty"`
96103
}
97104

98-
// ControlPlaneAuth defines the authentication configuration for control plane
105+
// ControlPlaneAuth defines the authentication configuration for control plane.
99106
type ControlPlaneAuth struct {
100-
// Type specifies the type of authentication
107+
// Type specifies the type of authentication.
101108
// +kubebuilder:validation:Required
102109
Type AuthType `json:"type"`
103110

104-
// AdminKey specifies the admin key authentication configuration
111+
// AdminKey specifies the admin key authentication configuration.
105112
// +optional
106113
AdminKey *AdminKeyAuth `json:"adminKey,omitempty"`
107114
}
108115

109-
// ControlPlaneProvider defines the configuration for control plane provider
116+
// ControlPlaneProvider defines the configuration for control plane provider.
110117
type ControlPlaneProvider struct {
111-
// Endpoints specifies the list of control plane endpoints
118+
// Endpoints specifies the list of control plane endpoints.
112119
// +kubebuilder:validation:Required
113120
// +kubebuilder:validation:MinItems=1
114121
Endpoints []string `json:"endpoints"`
115122

116-
// TlsVerify specifies whether to verify the TLS certificate of the control plane
123+
// TlsVerify specifies whether to verify the TLS certificate of the control plane.
117124
// +optional
118125
TlsVerify *bool `json:"tlsVerify,omitempty"`
119126

120-
// Auth specifies the authentication configuration
127+
// Auth specifies the authentication configurations.
121128
// +kubebuilder:validation:Required
122129
Auth ControlPlaneAuth `json:"auth"`
123130
}
124131

125132
// +kubebuilder:object:root=true
126-
// GatewayProxy is the Schema for the gatewayproxies API
133+
// GatewayProxy is the Schema for the gatewayproxies API.
127134
type GatewayProxy struct {
128135
metav1.TypeMeta `json:",inline"`
129136
metav1.ObjectMeta `json:"metadata,omitempty"`
130137

138+
// GatewayProxySpec defines the desired state and configuration of a GatewayProxy,
139+
// including networking settings, global plugins, and plugin metadata.
131140
Spec GatewayProxySpec `json:"spec,omitempty"`
132141
}
133142

134143
// +kubebuilder:object:root=true
135-
// GatewayProxyList contains a list of GatewayProxy
144+
// GatewayProxyList contains a list of GatewayProxy.
136145
type GatewayProxyList struct {
137146
metav1.TypeMeta `json:",inline"`
138147
metav1.ListMeta `json:"metadata,omitempty"`
139148
Items []GatewayProxy `json:"items"`
140149
}
141150

151+
// GatewayProxyPlugin contains plugin configurations.
142152
type GatewayProxyPlugin struct {
153+
// Name is the name of the plugin.
143154
Name string `json:"name,omitempty"`
155+
// Enabled defines whether the plugin is enabled.
144156
Enabled bool `json:"enabled,omitempty"`
157+
// Config defines the plugin's configuration details.
145158
Config apiextensionsv1.JSON `json:"config,omitempty"`
146159
}
147160

api/v1alpha1/httproutepolicy_types.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ import (
2424

2525
// HTTPRoutePolicySpec defines the desired state of HTTPRoutePolicy.
2626
type HTTPRoutePolicySpec struct {
27-
// TargetRef identifies an API object (enum: HTTPRoute, Ingress) to apply HTTPRoutePolicy to.
28-
//
29-
// target references.
27+
// TargetRef identifies an API object (i.e. HTTPRoute, Ingress) to apply HTTPRoutePolicy to.
3028
// +kubebuilder:validation:MinItems=1
3129
// +kubebuilder:validation:MaxItems=16
3230
TargetRefs []gatewayv1alpha2.LocalPolicyTargetReferenceWithSectionName `json:"targetRefs"`
33-
31+
// Priority sets the priority for route. A higher value sets a higher priority in route matching.
3432
Priority *int64 `json:"priority,omitempty" yaml:"priority,omitempty"`
33+
// Vars sets the request matching conditions.
3534
Vars []apiextensionsv1.JSON `json:"vars,omitempty" yaml:"vars,omitempty"`
3635
}
3736

api/v1alpha1/pluginconfig_types.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,33 @@ import (
1010

1111
// +kubebuilder:object:root=true
1212

13-
// PluginConfig is the Schema for the PluginConfigs API
13+
// PluginConfig is the Schema for the PluginConfigs API.
1414
type PluginConfig struct {
1515
metav1.TypeMeta `json:",inline"`
1616
metav1.ObjectMeta `json:"metadata,omitempty"`
1717

1818
Spec PluginConfigSpec `json:"spec,omitempty"`
1919
}
2020

21-
// PluginConfigSpec defines the desired state of PluginConfig
21+
// PluginConfigSpec defines the desired state of PluginConfig.
2222
type PluginConfigSpec struct {
23+
// Plugins are an array of plugins and their configurations to be applied.
2324
Plugins []Plugin `json:"plugins"`
2425
}
2526

2627
// +kubebuilder:object:root=true
2728

28-
// PluginConfigList contains a list of PluginConfig
29+
// PluginConfigList contains a list of PluginConfig.
2930
type PluginConfigList struct {
3031
metav1.TypeMeta `json:",inline"`
3132
metav1.ListMeta `json:"metadata,omitempty"`
3233
Items []PluginConfig `json:"items"`
3334
}
3435

3536
type Plugin struct {
36-
// The plugin name.
37+
// Name is the name of the plugin.
3738
Name string `json:"name" yaml:"name"`
38-
// Plugin configuration.
39+
// Config is plugin configuration details.
3940
Config apiextensionsv1.JSON `json:"config,omitempty" yaml:"config,omitempty"`
4041
}
4142

0 commit comments

Comments
 (0)