/
types.go
647 lines (560 loc) · 26.8 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package v2beta3
import (
"encoding/json"
"time"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
v2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2"
"github.com/apache/apisix-ingress-controller/pkg/types"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// ApisixRoute is used to define the route rules and upstreams for Apache APISIX.
type ApisixRoute struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Spec ApisixRouteSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"`
}
// ApisixStatus is the status report for Apisix ingress Resources
type ApisixStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty" yaml:"conditions,omitempty"`
}
// ApisixRouteSpec is the spec definition for ApisixRouteSpec.
type ApisixRouteSpec struct {
HTTP []ApisixRouteHTTP `json:"http,omitempty" yaml:"http,omitempty"`
Stream []ApisixRouteStream `json:"stream,omitempty" yaml:"stream,omitempty"`
}
// UpstreamTimeout is settings for the read, send and connect to the upstream.
type UpstreamTimeout struct {
Connect metav1.Duration `json:"connect,omitempty" yaml:"connect,omitempty"`
Send metav1.Duration `json:"send,omitempty" yaml:"send,omitempty"`
Read metav1.Duration `json:"read,omitempty" yaml:"read,omitempty"`
}
// ApisixRouteHTTP represents a single route in for HTTP traffic.
type ApisixRouteHTTP struct {
// The rule name, cannot be empty.
Name string `json:"name" yaml:"name"`
// Route priority, when multiple routes contains
// same URI path (for path matching), route with
// higher priority will take effect.
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
Timeout *UpstreamTimeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Match ApisixRouteHTTPMatch `json:"match,omitempty" yaml:"match,omitempty"`
// Backends represents potential backends to proxy after the route
// rule matched. When number of backends are more than one, traffic-split
// plugin in APISIX will be used to split traffic based on the backend weight.
Backends []v2.ApisixRouteHTTPBackend `json:"backends,omitempty" yaml:"backends,omitempty"`
Websocket bool `json:"websocket" yaml:"websocket"`
PluginConfigName string `json:"plugin_config_name,omitempty" yaml:"plugin_config_name,omitempty"`
Plugins []ApisixRouteHTTPPlugin `json:"plugins,omitempty" yaml:"plugins,omitempty"`
Authentication ApisixRouteAuthentication `json:"authentication,omitempty" yaml:"authentication,omitempty"`
}
// ApisixRouteHTTPBackend represents a HTTP backend (a Kuberentes Service).
type ApisixRouteHTTPBackend struct {
// The name (short) of the service, note cross namespace is forbidden,
// so be sure the ApisixRoute and Service are in the same namespace.
ServiceName string `json:"serviceName" yaml:"serviceName"`
// The service port, could be the name or the port number.
ServicePort intstr.IntOrString `json:"servicePort" yaml:"servicePort"`
// The resolve granularity, can be "endpoints" or "service",
// when set to "endpoints", the pod ips will be used; other
// wise, the service ClusterIP or ExternalIP will be used,
// default is endpoints.
ResolveGranularity string `json:"resolveGranularity,omitempty" yaml:"resolveGranularity,omitempty"`
// Weight of this backend.
Weight *int `json:"weight" yaml:"weight"`
// Subset specifies a subset for the target Service. The subset should be pre-defined
// in ApisixUpstream about this service.
Subset string `json:"subset,omitempty" yaml:"subset,omitempty"`
}
// ApisixRouteHTTPMatch represents the match condition for hitting this route.
type ApisixRouteHTTPMatch struct {
// URI path predicates, at least one path should be
// configured, path could be exact or prefix, for prefix path,
// append "*" after it, for instance, "/foo*".
Paths []string `json:"paths" yaml:"paths"`
// HTTP request method predicates.
Methods []string `json:"methods,omitempty" yaml:"methods,omitempty"`
// HTTP Host predicates, host can be a wildcard domain or
// an exact domain. For wildcard domain, only one generic
// level is allowed, for instance, "*.foo.com" is valid but
// "*.*.foo.com" is not.
Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty"`
// Remote address predicates, items can be valid IPv4 address
// or IPv6 address or CIDR.
RemoteAddrs []string `json:"remoteAddrs,omitempty" yaml:"remoteAddrs,omitempty"`
// NginxVars represents generic match predicates,
// it uses Nginx variable systems, so any predicate
// like headers, querystring and etc can be leveraged
// here to match the route.
// For instance, it can be:
// nginxVars:
// - subject: "$remote_addr"
// op: in
// value:
// - "127.0.0.1"
// - "10.0.5.11"
NginxVars []v2.ApisixRouteHTTPMatchExpr `json:"exprs,omitempty" yaml:"exprs,omitempty"`
}
// ApisixRouteHTTPMatchExpr represents a binary route match expression .
type ApisixRouteHTTPMatchExpr struct {
// Subject is the expression subject, it can
// be any string composed by literals and nginx
// vars.
Subject ApisixRouteHTTPMatchExprSubject `json:"subject" yaml:"subject"`
// Op is the operator.
Op string `json:"op" yaml:"op"`
// Set is an array type object of the expression.
// It should be used when the Op is "in" or "not_in";
Set []string `json:"set" yaml:"set"`
// Value is the normal type object for the expression,
// it should be used when the Op is not "in" and "not_in".
// Set and Value are exclusive so only of them can be set
// in the same time.
Value *string `json:"value" yaml:"value"`
}
// ApisixRouteHTTPMatchExprSubject describes the route match expression subject.
type ApisixRouteHTTPMatchExprSubject struct {
// The subject scope, can be:
// ScopeQuery, ScopeHeader, ScopePath
// when subject is ScopePath, Name field
// will be ignored.
Scope string `json:"scope" yaml:"scope"`
// The name of subject.
Name string `json:"name" yaml:"name"`
}
// ApisixRouteHTTPPlugin represents an APISIX plugin.
type ApisixRouteHTTPPlugin struct {
// The plugin name.
Name string `json:"name" yaml:"name"`
// Whether this plugin is in use, default is true.
Enable bool `json:"enable" yaml:"enable"`
// Plugin configuration.
Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"`
}
// ApisixRouteHTTPPluginConfig is the configuration for
// any plugins.
type ApisixRouteHTTPPluginConfig map[string]interface{}
// ApisixRouteAuthentication is the authentication-related
// configuration in ApisixRoute.
type ApisixRouteAuthentication struct {
Enable bool `json:"enable" yaml:"enable"`
Type string `json:"type" yaml:"type"`
KeyAuth ApisixRouteAuthenticationKeyAuth `json:"keyauth,omitempty" yaml:"keyauth,omitempty"`
}
// ApisixRouteAuthenticationKeyAuth is the keyAuth-related
// configuration in ApisixRouteAuthentication.
type ApisixRouteAuthenticationKeyAuth struct {
Header string `json:"header,omitempty" yaml:"header,omitempty"`
}
func (p ApisixRouteHTTPPluginConfig) DeepCopyInto(out *ApisixRouteHTTPPluginConfig) {
b, _ := json.Marshal(&p)
_ = json.Unmarshal(b, out)
}
func (p *ApisixRouteHTTPPluginConfig) DeepCopy() *ApisixRouteHTTPPluginConfig {
if p == nil {
return nil
}
out := new(ApisixRouteHTTPPluginConfig)
p.DeepCopyInto(out)
return out
}
// ApisixRouteStream is the configuration for level 4 route
type ApisixRouteStream struct {
// The rule name, cannot be empty.
Name string `json:"name" yaml:"name"`
Protocol string `json:"protocol" yaml:"protocol"`
Match ApisixRouteStreamMatch `json:"match" yaml:"match"`
Backend ApisixRouteStreamBackend `json:"backend" yaml:"backend"`
}
// ApisixRouteStreamMatch represents the match conditions of stream route.
type ApisixRouteStreamMatch struct {
// IngressPort represents the port listening on the Ingress proxy server.
// It should be pre-defined as APISIX doesn't support dynamic listening.
IngressPort int32 `json:"ingressPort" yaml:"ingressPort"`
}
// ApisixRouteStreamBackend represents a TCP backend (a Kubernetes Service).
type ApisixRouteStreamBackend struct {
// The name (short) of the service, note cross namespace is forbidden,
// so be sure the ApisixRoute and Service are in the same namespace.
ServiceName string `json:"serviceName" yaml:"serviceName"`
// The service port, could be the name or the port number.
ServicePort intstr.IntOrString `json:"servicePort" yaml:"servicePort"`
// The resolve granularity, can be "endpoints" or "service",
// when set to "endpoints", the pod ips will be used; other
// wise, the service ClusterIP or ExternalIP will be used,
// default is endpoints.
ResolveGranularity string `json:"resolveGranularity,omitempty" yaml:"resolveGranularity,omitempty"`
// Subset specifies a subset for the target Service. The subset should be pre-defined
// in ApisixUpstream about this service.
Subset string `json:"subset,omitempty" yaml:"subset,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ApisixRouteList contains a list of ApisixRoute.
type ApisixRouteList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []ApisixRoute `json:"items,omitempty" yaml:"items,omitempty"`
}
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// ApisixClusterConfig is the Schema for the ApisixClusterConfig resource.
// An ApisixClusterConfig is used to identify an APISIX cluster, it's a
// ClusterScoped resource so the name is unique.
// It also contains some cluster-level configurations like monitoring.
type ApisixClusterConfig struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec defines the desired state of ApisixClusterConfigSpec.
Spec ApisixClusterConfigSpec `json:"spec" yaml:"spec"`
Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"`
}
// ApisixClusterConfigSpec defines the desired state of ApisixClusterConfigSpec.
type ApisixClusterConfigSpec struct {
// Monitoring categories all monitoring related features.
// +optional
Monitoring *ApisixClusterMonitoringConfig `json:"monitoring" yaml:"monitoring"`
// Admin contains the Admin API information about APISIX cluster.
// +optional
Admin *ApisixClusterAdminConfig `json:"admin" yaml:"admin"`
}
// ApisixClusterMonitoringConfig categories all monitoring related features.
type ApisixClusterMonitoringConfig struct {
// Prometheus is the config for using Prometheus in APISIX Cluster.
// +optional
Prometheus ApisixClusterPrometheusConfig `json:"prometheus" yaml:"prometheus"`
// Skywalking is the config for using Skywalking in APISIX Cluster.
// +optional
Skywalking ApisixClusterSkywalkingConfig `json:"skywalking" yaml:"skywalking"`
}
// ApisixClusterPrometheusConfig is the config for using Prometheus in APISIX Cluster.
type ApisixClusterPrometheusConfig struct {
// Enable means whether enable Prometheus or not.
Enable bool `json:"enable" yaml:"enable"`
}
// ApisixClusterSkywalkingConfig is the config for using Skywalking in APISIX Cluster.
type ApisixClusterSkywalkingConfig struct {
// Enable means whether enable Skywalking or not.
Enable bool `json:"enable" yaml:"enable"`
// SampleRatio means the ratio to collect
SampleRatio float64 `json:"sampleRatio" yaml:"sampleRatio"`
}
// ApisixClusterAdminConfig is the admin config for the corresponding APISIX Cluster.
type ApisixClusterAdminConfig struct {
// BaseURL is the base URL for the APISIX Admin API.
// It looks like "http://apisix-admin.default.svc.cluster.local:9080/apisix/admin"
BaseURL string `json:"baseURL" yaml:"baseURL"`
// AdminKey is used to verify the admin API user.
AdminKey string `json:"adminKey" yaml:"adminKey"`
// ClientTimeout is request timeout for the APISIX Admin API client
ClientTimeout types.TimeDuration `json:"clientTimeout" yaml:"clientTimeout"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ApisixClusterConfigList contains a list of ApisixClusterConfig.
type ApisixClusterConfigList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []ApisixClusterConfig `json:"items" yaml:"items"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// ApisixConsumer is the Schema for the ApisixConsumer resource.
// An ApisixConsumer is used to identify a consumer.
type ApisixConsumer struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Spec ApisixConsumerSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"`
}
// ApisixConsumerSpec defines the desired state of ApisixConsumer.
type ApisixConsumerSpec struct {
AuthParameter ApisixConsumerAuthParameter `json:"authParameter" yaml:"authParameter"`
}
type ApisixConsumerAuthParameter struct {
BasicAuth *ApisixConsumerBasicAuth `json:"basicAuth,omitempty" yaml:"basicAuth"`
KeyAuth *ApisixConsumerKeyAuth `json:"keyAuth,omitempty" yaml:"keyAuth"`
}
// ApisixConsumerBasicAuth defines the configuration for basic auth.
type ApisixConsumerBasicAuth struct {
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
Value *ApisixConsumerBasicAuthValue `json:"value,omitempty" yaml:"value,omitempty"`
}
// ApisixConsumerBasicAuthValue defines the in-place username and password configuration for basic auth.
type ApisixConsumerBasicAuthValue struct {
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"username"`
}
// ApisixConsumerKeyAuth defines the configuration for the key auth.
type ApisixConsumerKeyAuth struct {
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
Value *ApisixConsumerKeyAuthValue `json:"value,omitempty" yaml:"value,omitempty"`
}
// ApisixConsumerKeyAuthValue defines the in-place configuration for basic auth.
type ApisixConsumerKeyAuthValue struct {
Key string `json:"key" yaml:"key"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ApisixConsumerList contains a list of ApisixConsumer.
type ApisixConsumerList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []ApisixConsumer `json:"items,omitempty" yaml:"items,omitempty"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// ApisixUpstream is a decorator for Kubernetes Service, it arms the Service
// with rich features like health check, retry policies, load balancer and others.
// It's designed to have same name with the Kubernetes Service and can be customized
// for individual port.
type ApisixUpstream struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Spec *ApisixUpstreamSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"`
}
// ApisixUpstreamSpec describes the specification of ApisixUpstream.
type ApisixUpstreamSpec struct {
ApisixUpstreamConfig `json:",inline" yaml:",inline"`
PortLevelSettings []PortLevelSettings `json:"portLevelSettings,omitempty" yaml:"portLevelSettings,omitempty"`
}
// ApisixUpstreamConfig contains rich features on APISIX Upstream, for instance
// load balancer, health check and etc.
type ApisixUpstreamConfig struct {
// LoadBalancer represents the load balancer configuration for Kubernetes Service.
// The default strategy is round robin.
// +optional
LoadBalancer *LoadBalancer `json:"loadbalancer,omitempty" yaml:"loadbalancer,omitempty"`
// The scheme used to talk with the upstream.
// Now value can be http, grpc.
// +optional
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
// How many times that the proxy (Apache APISIX) should do when
// errors occur (error, timeout or bad http status codes like 500, 502).
// +optional
Retries *int `json:"retries,omitempty" yaml:"retries,omitempty"`
// Timeout settings for the read, send and connect to the upstream.
// +optional
Timeout *UpstreamTimeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
// The health check configurations for the upstream.
// +optional
HealthCheck *HealthCheck `json:"healthCheck,omitempty" yaml:"healthCheck,omitempty"`
// Set the client certificate when connecting to TLS upstream.
// +optional
TLSSecret *ApisixSecret `json:"tlsSecret,omitempty" yaml:"tlsSecret,omitempty"`
// Subsets groups the service endpoints by their labels. Usually used to differentiate
// service versions.
// +optional
Subsets []ApisixUpstreamSubset `json:"subsets,omitempty" yaml:"subsets,omitempty"`
}
// ApisixUpstreamSubset defines a single endpoints group of one Service.
type ApisixUpstreamSubset struct {
// Name is the name of subset.
Name string `json:"name" yaml:"name"`
// Labels is the label set of this subset.
Labels map[string]string `json:"labels" yaml:"labels"`
}
// PortLevelSettings configures the ApisixUpstreamConfig for each individual port. It inherits
// configurations from the outer level (the whole Kubernetes Service) and overrides some of
// them if they are set on the port level.
type PortLevelSettings struct {
ApisixUpstreamConfig `json:",inline" yaml:",inline"`
// Port is a Kubernetes Service port, it should be already defined.
Port int32 `json:"port" yaml:"port"`
}
// LoadBalancer describes the load balancing parameters.
type LoadBalancer struct {
Type string `json:"type" yaml:"type"`
// The HashOn and Key fields are required when Type is "chash".
// HashOn represents the key fetching scope.
HashOn string `json:"hashOn,omitempty" yaml:"hashOn,omitempty"`
// Key represents the hash key.
Key string `json:"key,omitempty" yaml:"key,omitempty"`
}
// HealthCheck describes the upstream health check parameters.
type HealthCheck struct {
Active *ActiveHealthCheck `json:"active" yaml:"active"`
Passive *PassiveHealthCheck `json:"passive,omitempty" yaml:"passive,omitempty"`
}
// ActiveHealthCheck defines the active kind of upstream health check.
type ActiveHealthCheck struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
Host string `json:"host,omitempty" yaml:"host,omitempty"`
Port int32 `json:"port,omitempty" yaml:"port,omitempty"`
HTTPPath string `json:"httpPath,omitempty" yaml:"httpPath,omitempty"`
StrictTLS *bool `json:"strictTLS,omitempty" yaml:"strictTLS,omitempty"`
RequestHeaders []string `json:"requestHeaders,omitempty" yaml:"requestHeaders,omitempty"`
Healthy *ActiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
Unhealthy *ActiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
}
// PassiveHealthCheck defines the conditions to judge whether
// an upstream node is healthy with the passive manager.
type PassiveHealthCheck struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Healthy *PassiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
Unhealthy *PassiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
}
// ActiveHealthCheckHealthy defines the conditions to judge whether
// an upstream node is healthy with the active manner.
type ActiveHealthCheckHealthy struct {
PassiveHealthCheckHealthy `json:",inline" yaml:",inline"`
Interval metav1.Duration `json:"interval,omitempty" yaml:"interval,omitempty"`
}
// ActiveHealthCheckUnhealthy defines the conditions to judge whether
// an upstream node is unhealthy with the active manager.
type ActiveHealthCheckUnhealthy struct {
PassiveHealthCheckUnhealthy `json:",inline" yaml:",inline"`
Interval metav1.Duration `json:"interval,omitempty" yaml:"interval,omitempty"`
}
// PassiveHealthCheckHealthy defines the conditions to judge whether
// an upstream node is healthy with the passive manner.
type PassiveHealthCheckHealthy struct {
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`
Successes int `json:"successes,omitempty" yaml:"successes,omitempty"`
}
// PassiveHealthCheckUnhealthy defines the conditions to judge whether
// an upstream node is unhealthy with the passive manager.
type PassiveHealthCheckUnhealthy struct {
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`
HTTPFailures int `json:"httpFailures,omitempty" yaml:"http_failures,omitempty"`
TCPFailures int `json:"tcpFailures,omitempty" yaml:"tcpFailures,omitempty"`
Timeouts int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ApisixUpstreamList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []ApisixUpstream `json:"items,omitempty" yaml:"items,omitempty"`
}
type Plugin struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Enable bool `json:"enable,omitempty" yaml:"enable,omitempty"`
Config Config `json:"config,omitempty" yaml:"config,omitempty"`
ConfigSet ConfigSet `json:"config_set,omitempty" yaml:"config_set,omitempty"`
}
type ConfigSet []interface{}
func (p ConfigSet) DeepCopyInto(out *ConfigSet) {
b, _ := json.Marshal(&p)
_ = json.Unmarshal(b, out)
}
func (p *ConfigSet) DeepCopy() *ConfigSet {
if p == nil {
return nil
}
out := new(ConfigSet)
p.DeepCopyInto(out)
return out
}
type Config map[string]interface{}
func (p Config) DeepCopyInto(out *Config) {
b, _ := json.Marshal(&p)
_ = json.Unmarshal(b, out)
}
func (p *Config) DeepCopy() *Config {
if p == nil {
return nil
}
out := new(Config)
p.DeepCopyInto(out)
return out
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:shortName=atls
// +kubebuilder:subresource:status
// ApisixTls defines SSL resource in APISIX.
type ApisixTls struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Spec *ApisixTlsSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
// +optional
Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:name="SNIs",type=string,JSONPath=`.spec.hosts`
// +kubebuilder:printcolumn:name="Secret Name",type=string,JSONPath=`.spec.secret.name`
// +kubebuilder:printcolumn:name="Secret Namespace",type=string,JSONPath=`.spec.secret.namespace`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:printcolumn:name="Client CA Secret Name",type=string,JSONPath=`.spec.client.ca.name`
// +kubebuilder:printcolumn:name="Client CA Secret Namespace",type=string,JSONPath=`.spec.client.ca.namespace`
type ApisixTlsList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []ApisixTls `json:"items,omitempty" yaml:"items,omitempty"`
}
// +kubebuilder:validation:Pattern="^\\*?[0-9a-zA-Z-.]+$"
type HostType string
// ApisixTlsSpec is the specification of ApisixSSL.
type ApisixTlsSpec struct {
// +required
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
Hosts []HostType `json:"hosts" yaml:"hosts,omitempty"`
// +required
// +kubebuilder:validation:Required
Secret ApisixSecret `json:"secret" yaml:"secret"`
// +optional
Client *ApisixMutualTlsClientConfig `json:"client,omitempty" yaml:"client,omitempty"`
}
// ApisixSecret describes the Kubernetes Secret name and namespace.
type ApisixSecret struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Required
Name string `json:"name" yaml:"name"`
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Required
Namespace string `json:"namespace" yaml:"namespace"`
}
// ApisixMutualTlsClientConfig describes the mutual TLS CA and verify depth
type ApisixMutualTlsClientConfig struct {
CASecret ApisixSecret `json:"caSecret,omitempty" yaml:"caSecret,omitempty"`
Depth int `json:"depth,omitempty" yaml:"depth,omitempty"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// ApisixPluginConfig is the Schema for the ApisixPluginConfig resource.
// An ApisixPluginConfig is used to support a group of plugin configs
type ApisixPluginConfig struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
// Spec defines the desired state of ApisixPluginConfigSpec.
Spec ApisixPluginConfigSpec `json:"spec" yaml:"spec"`
Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"`
}
// ApisixPluginConfigSpec defines the desired state of ApisixPluginConfigSpec.
type ApisixPluginConfigSpec struct {
// Plugins contains a list of ApisixRouteHTTPPlugin
// +required
Plugins []ApisixRouteHTTPPlugin `json:"plugins" yaml:"plugins"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:generate=true
// ApisixPluginConfigList contains a list of ApisixPluginConfig.
type ApisixPluginConfigList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata" yaml:"metadata"`
Items []ApisixPluginConfig `json:"items,omitempty" yaml:"items,omitempty"`
}