-
Notifications
You must be signed in to change notification settings - Fork 72
/
maxscale_types.go
909 lines (833 loc) · 40.1 KB
/
maxscale_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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
package v1alpha1
import (
"errors"
"fmt"
"time"
ds "github.com/mariadb-operator/mariadb-operator/pkg/datastructures"
"github.com/mariadb-operator/mariadb-operator/pkg/environment"
mxsstate "github.com/mariadb-operator/mariadb-operator/pkg/maxscale/state"
"github.com/mariadb-operator/mariadb-operator/pkg/statefulset"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// MaxScaleServer defines a MariaDB server to forward traffic to.
type MaxScaleServer struct {
// Name is the identifier of the MariaDB server.
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec
Name string `json:"name"`
// Address is the network address of the MariaDB server.
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec
Address string `json:"address"`
// Port is the network port of the MariaDB server. If not provided, it defaults to 3306.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"}
Port int32 `json:"port,omitempty"`
// Protocol is the MaxScale protocol to use when communicating with this MariaDB server. If not provided, it defaults to MariaDBBackend.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Protocol string `json:"protocol,omitempty"`
// Maintenance indicates whether the server is in maintenance mode.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
Maintenance bool `json:"maintenance,omitempty"`
// Params defines extra parameters to pass to the server.
// Any parameter supported by MaxScale may be specified here. See reference:
// https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-maxscale-configuration-guide/#server_1.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Params map[string]string `json:"params,omitempty"`
}
// SetDefaults sets default values.
func (m *MaxScaleServer) SetDefaults() {
if m.Port == 0 {
m.Port = 3306
}
if m.Protocol == "" {
m.Protocol = "MariaDBBackend"
}
}
// SuspendTemplate indicates whether the current resource should be suspended or not. Feature flag --feature-maxscale-suspend is required in the controller to enable this.
type SuspendTemplate struct {
// Suspend indicates whether the current resource should be suspended or not. Feature flag --feature-maxscale-suspend is required in the controller to enable this.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch","urn:alm:descriptor:com.tectonic.ui:advanced"}
Suspend bool `json:"suspend,omitempty"`
}
// MonitorModule defines the type of monitor module
type MonitorModule string
const (
// MonitorModuleMariadb is a monitor to be used with MariaDB servers.
MonitorModuleMariadb MonitorModule = "mariadbmon"
// MonitorModuleGalera is a monitor to be used with Galera servers.
MonitorModuleGalera MonitorModule = "galeramon"
)
// Validate determines whether a MonitorModule is valid.
func (m MonitorModule) Validate() error {
switch m {
case MonitorModuleMariadb, MonitorModuleGalera:
return nil
}
return fmt.Errorf("unsupported value: '%v'", m)
}
// CooperativeMonitoring enables coordination between multiple MaxScale instances running monitors.
// See: https://mariadb.com/docs/server/architecture/components/maxscale/monitors/mariadbmon/use-cooperative-locking-ha-maxscale-mariadb-monitor/
type CooperativeMonitoring string
const (
// CooperativeMonitoringMajorityOfAll requires a lock from the majority of the MariaDB servers, even the ones that are down.
CooperativeMonitoringMajorityOfAll CooperativeMonitoring = "majority_of_all"
// CooperativeMonitoringMajorityOfRunning requires a lock from the majority of the MariaDB servers.
CooperativeMonitoringMajorityOfRunning CooperativeMonitoring = "majority_of_running"
)
// MaxScaleMonitor monitors MariaDB server instances
type MaxScaleMonitor struct {
// SuspendTemplate defines how a resource can be suspended.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
SuspendTemplate `json:",inline"`
// Name is the identifier of the monitor. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Name string `json:"name"`
// Module is the module to use to monitor MariaDB servers. It is mandatory when no MariaDB reference is provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Module MonitorModule `json:"module" webhook:"inmutableinit"`
// Interval used to monitor MariaDB servers. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Interval metav1.Duration `json:"interval,omitempty"`
// CooperativeMonitoring enables coordination between multiple MaxScale instances running monitors. It is defaulted when HA is enabled.
// +optional
// +kubebuilder:validation:Enum=majority_of_all;majority_of_running
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
CooperativeMonitoring *CooperativeMonitoring `json:"cooperativeMonitoring,omitempty"`
// Params defines extra parameters to pass to the monitor.
// Any parameter supported by MaxScale may be specified here. See reference:
// https://mariadb.com/kb/en/mariadb-maxscale-2308-common-monitor-parameters/.
// Monitor specific parameter are also suported:
// https://mariadb.com/kb/en/mariadb-maxscale-2308-galera-monitor/#galera-monitor-optional-parameters.
// https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-monitor/#configuration.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Params map[string]string `json:"params,omitempty"`
}
// SetCondition sets a status condition to MaxScale
func (m *MaxScaleMonitor) SetDefaults(mxs *MaxScale) {
if m.Name == "" && m.Module != "" {
m.Name = fmt.Sprintf("%s-monitor", string(m.Module))
}
if m.Interval == (metav1.Duration{}) {
m.Interval = metav1.Duration{Duration: 2 * time.Second}
}
if mxs.IsHAEnabled() && m.CooperativeMonitoring == nil {
m.CooperativeMonitoring = ptr.To(CooperativeMonitoringMajorityOfAll)
}
}
// MaxScaleListener defines how the MaxScale server will listen for connections.
type MaxScaleListener struct {
// SuspendTemplate defines how a resource can be suspended.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
SuspendTemplate `json:",inline"`
// Name is the identifier of the listener. It is defaulted if not provided
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Name string `json:"name"`
// Port is the network port where the MaxScale server will listen.
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"}
Port int32 `json:"port,omitempty" webhook:"inmutable"`
// Protocol is the MaxScale protocol to use when communicating with the client. If not provided, it defaults to MariaDBProtocol.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Protocol string `json:"protocol,omitempty"`
// Params defines extra parameters to pass to the listener.
// Any parameter supported by MaxScale may be specified here. See reference:
// https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-maxscale-configuration-guide/#listener_1.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Params map[string]string `json:"params,omitempty"`
}
// SetDefaults sets default values.
func (m *MaxScaleListener) SetDefaults(svc *MaxScaleService) {
if m.Name == "" {
m.Name = fmt.Sprintf("%s-listener", svc.Name)
}
if m.Protocol == "" {
m.Protocol = "MariaDBProtocol"
}
}
// ServiceRouter defines the type of service router.
type ServiceRouter string
const (
// ServiceRouterReadWriteSplit splits the load based on the queries. Write queries are performed on master and read queries on the replicas.
ServiceRouterReadWriteSplit ServiceRouter = "readwritesplit"
// ServiceRouterReadConnRoute splits the load based on the connections. Each connection is assigned to a server.
ServiceRouterReadConnRoute ServiceRouter = "readconnroute"
)
// Services define how the traffic is forwarded to the MariaDB servers.
type MaxScaleService struct {
// SuspendTemplate defines how a resource can be suspended.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
SuspendTemplate `json:",inline"`
// Name is the identifier of the MaxScale service.
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec
Name string `json:"name"`
// Router is the type of router to use.
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=readwritesplit;readconnroute
// +operator-sdk:csv:customresourcedefinitions:type=spec
Router ServiceRouter `json:"router" webhook:"inmutable"`
// MaxScaleListener defines how the MaxScale server will listen for connections.
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec
Listener MaxScaleListener `json:"listener"`
// Params defines extra parameters to pass to the service.
// Any parameter supported by MaxScale may be specified here. See reference:
// https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-maxscale-configuration-guide/#service_1.
// Router specific parameter are also suported:
// https://mariadb.com/kb/en/mariadb-maxscale-2308-readwritesplit/#configuration.
// https://mariadb.com/kb/en/mariadb-maxscale-2308-readconnroute/#configuration.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Params map[string]string `json:"params,omitempty"`
}
// SetDefaults sets default values.
func (m *MaxScaleService) SetDefaults() {
m.Listener.SetDefaults(m)
}
// MaxScaleAdmin configures the admin REST API and GUI.
type MaxScaleAdmin struct {
// Port where the admin REST API and GUI will be exposed.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"}
Port int32 `json:"port"`
// GuiEnabled indicates whether the admin GUI should be enabled.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
GuiEnabled *bool `json:"guiEnabled,omitempty"`
}
// SetDefaults sets default values.
func (m *MaxScaleAdmin) SetDefaults(mxs *MaxScale) {
if m.Port == 0 {
m.Port = 8989
}
if m.GuiEnabled == nil {
m.GuiEnabled = ptr.To(true)
}
}
// MaxScaleConfigSync defines how the config changes are replicated across replicas.
type MaxScaleConfigSync struct {
// Database is the MariaDB logical database where the 'maxscale_config' table will be created in order to persist and synchronize config changes. If not provided, it defaults to 'mysql'.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Database string `json:"database,omitempty"`
// Interval defines the config synchronization interval. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Interval metav1.Duration `json:"interval,omitempty"`
// Interval defines the config synchronization timeout. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Timeout metav1.Duration `json:"timeout,omitempty"`
}
// MaxScaleConfig defines the MaxScale configuration.
type MaxScaleConfig struct {
// Params is a key value pair of parameters to be used in the MaxScale static configuration file.
// Any parameter supported by MaxScale may be specified here. See reference:
// https://mariadb.com/kb/en/mariadb-maxscale-2308-mariadb-maxscale-configuration-guide/#global-settings.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Params map[string]string `json:"params,omitempty"`
// VolumeClaimTemplate provides a template to define the PVCs for storing MaxScale runtime configuration files. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
VolumeClaimTemplate VolumeClaimTemplate `json:"volumeClaimTemplate"`
// Sync defines how to replicate configuration across MaxScale replicas. It is defaulted when HA is enabled.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Sync *MaxScaleConfigSync `json:"sync,omitempty"`
}
func (m *MaxScaleConfig) SetDefaults(mxs *MaxScale) {
if m.VolumeClaimTemplate.Resources.Requests == nil {
m.VolumeClaimTemplate.Resources.Requests = make(corev1.ResourceList)
}
if _, exit := m.VolumeClaimTemplate.Resources.Requests["storage"]; !exit {
m.VolumeClaimTemplate.Resources.Requests["storage"] = resource.MustParse("100Mi")
}
if len(m.VolumeClaimTemplate.AccessModes) == 0 {
m.VolumeClaimTemplate.AccessModes = append(m.VolumeClaimTemplate.AccessModes, corev1.ReadWriteOnce)
}
if mxs.IsHAEnabled() {
if m.Sync == nil {
m.Sync = &MaxScaleConfigSync{}
}
if m.Sync.Database == "" {
m.Sync.Database = "mysql"
}
if m.Sync.Interval == (metav1.Duration{}) {
m.Sync.Interval = metav1.Duration{Duration: 5 * time.Second}
}
if m.Sync.Timeout == (metav1.Duration{}) {
m.Sync.Timeout = metav1.Duration{Duration: 10 * time.Second}
}
}
}
// MaxScaleAuth defines the credentials required for MaxScale to connect to MariaDB.
type MaxScaleAuth struct {
// Generate defies whether the operator should generate users and grants for MaxScale to work.
// It only supports MariaDBs specified via spec.mariaDbRef.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
Generate *bool `json:"generate,omitempty" webhook:"inmutableinit"`
// AdminUsername is an admin username to call the admin REST API. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
AdminUsername string `json:"adminUsername,omitempty" webhook:"inmutableinit"`
// AdminPasswordSecretKeyRef is Secret key reference to the admin password to call the admin REST API. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
AdminPasswordSecretKeyRef GeneratedSecretKeyRef `json:"adminPasswordSecretKeyRef,omitempty" webhook:"inmutableinit"`
// DeleteDefaultAdmin determines whether the default admin user should be deleted after the initial configuration. If not provided, it defaults to true.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch","urn:alm:descriptor:com.tectonic.ui:advanced"}
DeleteDefaultAdmin *bool `json:"deleteDefaultAdmin,omitempty" webhook:"inmutableinit"`
// MetricsUsername is an metrics username to call the REST API. It is defaulted if metrics are enabled.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
MetricsUsername string `json:"metricsUsername,omitempty" webhook:"inmutableinit"`
// MetricsPasswordSecretKeyRef is Secret key reference to the metrics password to call the admib REST API. It is defaulted if metrics are enabled.
// If the referred Secret is labeled with "k8s.mariadb.com/watch", updates may be performed to the Secret in order to update the password.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
MetricsPasswordSecretKeyRef GeneratedSecretKeyRef `json:"metricsPasswordSecretKeyRef,omitempty"`
// ClientUsername is the user to connect to MaxScale. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
ClientUsername string `json:"clientUsername,omitempty" webhook:"inmutableinit"`
// ClientPasswordSecretKeyRef is Secret key reference to the password to connect to MaxScale. It is defaulted if not provided.
// If the referred Secret is labeled with "k8s.mariadb.com/watch", updates may be performed to the Secret in order to update the password.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
ClientPasswordSecretKeyRef GeneratedSecretKeyRef `json:"clientPasswordSecretKeyRef,omitempty"`
// ClientMaxConnections defines the maximum number of connections that the client can establish.
// If HA is enabled, make sure to increase this value, as more MaxScale replicas implies more connections.
// It defaults to 30 times the number of MaxScale replicas.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
ClientMaxConnections int32 `json:"clientMaxConnections,omitempty" webhook:"inmutableinit"`
// ServerUsername is the user used by MaxScale to connect to MariaDB server. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
ServerUsername string `json:"serverUsername,omitempty" webhook:"inmutableinit"`
// ServerPasswordSecretKeyRef is Secret key reference to the password used by MaxScale to connect to MariaDB server. It is defaulted if not provided.
// If the referred Secret is labeled with "k8s.mariadb.com/watch", updates may be performed to the Secret in order to update the password.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
ServerPasswordSecretKeyRef GeneratedSecretKeyRef `json:"serverPasswordSecretKeyRef,omitempty"`
// ServerMaxConnections defines the maximum number of connections that the server can establish.
// If HA is enabled, make sure to increase this value, as more MaxScale replicas implies more connections.
// It defaults to 30 times the number of MaxScale replicas.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
ServerMaxConnections int32 `json:"serverMaxConnections,omitempty" webhook:"inmutableinit"`
// MonitorUsername is the user used by MaxScale monitor to connect to MariaDB server. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
MonitorUsername string `json:"monitorUsername,omitempty" webhook:"inmutableinit"`
// MonitorPasswordSecretKeyRef is Secret key reference to the password used by MaxScale monitor to connect to MariaDB server. It is defaulted if not provided.
// If the referred Secret is labeled with "k8s.mariadb.com/watch", updates may be performed to the Secret in order to update the password.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
MonitorPasswordSecretKeyRef GeneratedSecretKeyRef `json:"monitorPasswordSecretKeyRef,omitempty"`
// MonitorMaxConnections defines the maximum number of connections that the monitor can establish.
// If HA is enabled, make sure to increase this value, as more MaxScale replicas implies more connections.
// It defaults to 30 times the number of MaxScale replicas.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
MonitorMaxConnections int32 `json:"monitorMaxConnections,omitempty" webhook:"inmutableinit"`
// MonitoSyncUsernamerUsername is the user used by MaxScale config sync to connect to MariaDB server. It is defaulted when HA is enabled.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
SyncUsername *string `json:"syncUsername,omitempty" webhook:"inmutableinit"`
// SyncPasswordSecretKeyRef is Secret key reference to the password used by MaxScale config to connect to MariaDB server. It is defaulted when HA is enabled.
// If the referred Secret is labeled with "k8s.mariadb.com/watch", updates may be performed to the Secret in order to update the password.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
SyncPasswordSecretKeyRef *GeneratedSecretKeyRef `json:"syncPasswordSecretKeyRef,omitempty"`
// SyncMaxConnections defines the maximum number of connections that the sync can establish.
// If HA is enabled, make sure to increase this value, as more MaxScale replicas implies more connections.
// It defaults to 30 times the number of MaxScale replicas.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number","urn:alm:descriptor:com.tectonic.ui:advanced"}
SyncMaxConnections *int32 `json:"syncMaxConnections,omitempty" webhook:"inmutableinit"`
}
// SetDefaults sets default values.
func (m *MaxScaleAuth) SetDefaults(mxs *MaxScale) {
if mxs.Spec.MariaDBRef != nil && m.Generate == nil {
m.Generate = ptr.To(true)
}
if m.AdminUsername == "" {
m.AdminUsername = "mariadb-operator"
}
if m.AdminPasswordSecretKeyRef == (GeneratedSecretKeyRef{}) {
m.AdminPasswordSecretKeyRef = mxs.AdminPasswordSecretKeyRef()
}
if m.DeleteDefaultAdmin == nil {
m.DeleteDefaultAdmin = ptr.To(true)
}
metrics := ptr.Deref(mxs.Spec.Metrics, MaxScaleMetrics{})
if metrics.Enabled {
if m.MetricsUsername == "" {
m.MetricsUsername = "metrics"
}
if m.MetricsPasswordSecretKeyRef == (GeneratedSecretKeyRef{}) {
m.MetricsPasswordSecretKeyRef = mxs.MetricsPasswordSecretKeyRef()
}
}
if m.ClientUsername == "" {
m.ClientUsername = mxs.AuthClientUserKey().Name
}
if m.ClientPasswordSecretKeyRef == (GeneratedSecretKeyRef{}) {
m.ClientPasswordSecretKeyRef = mxs.AuthClientPasswordSecretKeyRef()
}
if m.ClientMaxConnections == 0 {
m.ClientMaxConnections = mxs.defaultConnections()
}
if m.ServerUsername == "" {
m.ServerUsername = mxs.AuthServerUserKey().Name
}
if m.ServerPasswordSecretKeyRef == (GeneratedSecretKeyRef{}) {
m.ServerPasswordSecretKeyRef = mxs.AuthServerPasswordSecretKeyRef()
}
if m.ServerMaxConnections == 0 {
m.ServerMaxConnections = mxs.defaultConnections()
}
if m.MonitorUsername == "" {
m.MonitorUsername = mxs.AuthMonitorUserKey().Name
}
if m.MonitorPasswordSecretKeyRef == (GeneratedSecretKeyRef{}) {
m.MonitorPasswordSecretKeyRef = mxs.AuthMonitorPasswordSecretKeyRef()
}
if m.MonitorMaxConnections == 0 {
m.MonitorMaxConnections = mxs.defaultConnections()
}
if mxs.IsHAEnabled() {
if m.SyncUsername == nil {
m.SyncUsername = ptr.To(mxs.AuthSyncUserKey().Name)
}
if m.SyncPasswordSecretKeyRef == nil {
m.SyncPasswordSecretKeyRef = ptr.To(mxs.AuthSyncPasswordSecretKeyRef())
}
if m.SyncMaxConnections == nil {
m.SyncMaxConnections = ptr.To(mxs.defaultConnections())
}
}
}
// MaxScaleMetrics defines the metrics for a Maxscale.
type MaxScaleMetrics struct {
// Enabled is a flag to enable Metrics
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
Enabled bool `json:"enabled,omitempty"`
// Exporter defines the metrics exporter container.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Exporter Exporter `json:"exporter"`
// ServiceMonitor defines the ServiceMonior object.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
ServiceMonitor ServiceMonitor `json:"serviceMonitor"`
}
// MaxScaleSpec defines the desired state of MaxScale.
type MaxScaleSpec struct {
// ContainerTemplate defines templates to configure Container objects.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
ContainerTemplate `json:",inline"`
// PodTemplate defines templates to configure Pod objects.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
PodTemplate `json:",inline"`
// MariaDBRef is a reference to the MariaDB that MaxScale points to. It is used to initialize the servers field.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
MariaDBRef *MariaDBRef `json:"mariaDbRef,omitempty" webhook:"inmutable"`
// Servers are the MariaDB servers to forward traffic to. It is required if 'spec.mariaDbRef' is not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Servers []MaxScaleServer `json:"servers"`
// Image name to be used by the MaxScale instances. The supported format is `<image>:<tag>`.
// Only MaxScale official images are supported.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Image string `json:"image,omitempty"`
// ImagePullPolicy is the image pull policy. One of `Always`, `Never` or `IfNotPresent`. If not defined, it defaults to `IfNotPresent`.
// +optional
// +kubebuilder:validation:Enum=Always;Never;IfNotPresent
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:imagePullPolicy","urn:alm:descriptor:com.tectonic.ui:advanced"}
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
// InheritMetadata defines the metadata to be inherited by children resources.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
InheritMetadata *Metadata `json:"inheritMetadata,omitempty"`
// Services define how the traffic is forwarded to the MariaDB servers. It is defaulted if not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Services []MaxScaleService `json:"services,omitempty"`
// Monitor monitors MariaDB server instances. It is required if 'spec.mariaDbRef' is not provided.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Monitor MaxScaleMonitor `json:"monitor,omitempty"`
// Admin configures the admin REST API and GUI.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Admin MaxScaleAdmin `json:"admin,omitempty"`
// Config defines the MaxScale configuration.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Config MaxScaleConfig `json:"config,omitempty"`
// Auth defines the credentials required for MaxScale to connect to MariaDB.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Auth MaxScaleAuth `json:"auth,omitempty"`
// Metrics configures metrics and how to scrape them.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Metrics *MaxScaleMetrics `json:"metrics,omitempty"`
// Connection provides a template to define the Connection for MaxScale.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Connection *ConnectionTemplate `json:"connection,omitempty"`
// Replicas indicates the number of desired instances.
// +kubebuilder:default=1
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:podCount"}
Replicas int32 `json:"replicas,omitempty"`
// PodDisruptionBudget defines the budget for replica availability.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
PodDisruptionBudget *PodDisruptionBudget `json:"podDisruptionBudget,omitempty"`
// UpdateStrategy defines the update strategy for the StatefulSet object.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:updateStrategy","urn:alm:descriptor:com.tectonic.ui:advanced"}
UpdateStrategy *appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
// KubernetesService defines a template for a Kubernetes Service object to connect to MaxScale.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
KubernetesService *ServiceTemplate `json:"kubernetesService,omitempty"`
// GuiKubernetesService defines a template for a Kubernetes Service object to connect to MaxScale's GUI.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
GuiKubernetesService *ServiceTemplate `json:"guiKubernetesService,omitempty"`
// RequeueInterval is used to perform requeue reconciliations. If not defined, it defaults to 10s.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
RequeueInterval *metav1.Duration `json:"requeueInterval,omitempty"`
}
// MaxScaleAPIStatus is the state of the servers in the MaxScale API.
type MaxScaleServerStatus struct {
Name string `json:"name"`
State string `json:"state"`
}
// IsMaster indicates whether the current server is in Master state.
func (s *MaxScaleServerStatus) IsMaster() bool {
return mxsstate.IsMaster(s.State)
}
// IsReady indicates whether the current server is in ready state.
func (s *MaxScaleServerStatus) IsReady() bool {
return mxsstate.IsReady(s.State)
}
// InMaintenance indicates whether the current server is in maintenance state.
func (s *MaxScaleServerStatus) InMaintenance() bool {
return mxsstate.InMaintenance(s.State)
}
// MaxScaleResourceStatus indicates whether the resource is in a given state.
type MaxScaleResourceStatus struct {
Name string `json:"name"`
State string `json:"state"`
}
type MaxScaleConfigSyncStatus struct {
MaxScaleVersion int `json:"maxScaleVersion"`
DatabaseVersion int `json:"databaseVersion"`
}
// MaxScaleStatus defines the observed state of MaxScale
type MaxScaleStatus struct {
// Conditions for the MaxScale object.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:io.kubernetes.conditions"}
Conditions []metav1.Condition `json:"conditions,omitempty"`
// Replicas indicates the number of current instances.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:podCount"}
Replicas int32 `json:"replicas,omitempty"`
// PrimaryServer is the primary server in the MaxScale API.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
PrimaryServer *string `json:"primaryServer,omitempty"`
// Servers is the state of the servers in the MaxScale API.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
Servers []MaxScaleServerStatus `json:"servers,omitempty"`
// Monitor is the state of the monitor in the MaxScale API.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
Monitor *MaxScaleResourceStatus `json:"monitor,omitempty"`
// Services is the state of the services in the MaxScale API.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
Services []MaxScaleResourceStatus `json:"services,omitempty"`
// Listeners is the state of the listeners in the MaxScale API.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
Listeners []MaxScaleResourceStatus `json:"listeners,omitempty"`
// ConfigSync is the state of config sync.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
ConfigSync *MaxScaleConfigSyncStatus `json:"configSync,omitempty"`
}
// SetCondition sets a status condition to MaxScale
func (s *MaxScaleStatus) SetCondition(condition metav1.Condition) {
if s.Conditions == nil {
s.Conditions = make([]metav1.Condition, 0)
}
meta.SetStatusCondition(&s.Conditions, condition)
}
// GetPrimaryServer obtains the current primary server.
func (s *MaxScaleStatus) GetPrimaryServer() *string {
for _, srv := range s.Servers {
if srv.IsMaster() {
return &srv.Name
}
}
return nil
}
// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName=mxs
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status"
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message"
// +kubebuilder:printcolumn:name="Primary Server",type="string",JSONPath=".status.primaryServer"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +operator-sdk:csv:customresourcedefinitions:resources={{MaxScale,v1alpha1},{User,v1alpha1},{Grant,v1alpha1},{Connection,v1alpha1},{Event,v1},{Service,v1},{Secret,v1},{ServiceAccount,v1},{StatefulSet,v1},{Deployment,v1},{PodDisruptionBudget,v1}}
// MaxScale is the Schema for the maxscales API. It is used to define MaxScale clusters.
type MaxScale struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec MaxScaleSpec `json:"spec,omitempty"`
Status MaxScaleStatus `json:"status,omitempty"`
}
// SetDefaults sets default values.
func (m *MaxScale) SetDefaults(env *environment.OperatorEnv, mariadb *MariaDB) {
if m.Spec.Image == "" {
m.Spec.Image = env.RelatedMaxscaleImage
}
if m.Spec.RequeueInterval == nil {
m.Spec.RequeueInterval = &metav1.Duration{Duration: 10 * time.Second}
}
for i := range m.Spec.Servers {
m.Spec.Servers[i].SetDefaults()
}
if len(m.Spec.Services) == 0 {
m.Spec.Services = []MaxScaleService{
{
Name: "rw-router",
Router: ServiceRouterReadWriteSplit,
Listener: MaxScaleListener{
Port: 3306,
},
Params: map[string]string{
"transaction_replay": "true",
"master_accept_reads": "true",
},
},
{
Name: "rconn-master-router",
Router: ServiceRouterReadConnRoute,
Listener: MaxScaleListener{
Port: 3307,
},
Params: map[string]string{
"router_options": "master",
"master_accept_reads": "true",
},
},
{
Name: "rconn-slave-router",
Router: ServiceRouterReadConnRoute,
Listener: MaxScaleListener{
Port: 3308,
},
Params: map[string]string{
"router_options": "slave",
},
},
}
}
for i := range m.Spec.Services {
m.Spec.Services[i].SetDefaults()
}
m.Spec.Monitor.SetDefaults(m)
m.Spec.Admin.SetDefaults(m)
m.Spec.Config.SetDefaults(m)
m.Spec.Auth.SetDefaults(m)
antiAffinityInstances := m.getAntiAffinityInstances(mariadb)
if m.AreMetricsEnabled() {
if m.Spec.Metrics.Exporter.Image == "" {
m.Spec.Metrics.Exporter.Image = env.RelatedExporterMaxscaleImage
}
if m.Spec.Metrics.Exporter.Port == 0 {
m.Spec.Metrics.Exporter.Port = 9105
}
if m.Spec.Metrics.Exporter.Affinity != nil {
m.Spec.Metrics.Exporter.Affinity.SetDefaults(antiAffinityInstances...)
}
}
if m.Spec.Affinity != nil {
m.Spec.Affinity.SetDefaults(antiAffinityInstances...)
}
m.Spec.PodTemplate.SetDefaults(m.ObjectMeta)
}
func (m *MaxScale) getAntiAffinityInstances(mariadb *MariaDB) []string {
instances := []string{m.ObjectMeta.Name}
if mariadb != nil {
instances = append(instances, mariadb.ObjectMeta.Name)
}
return instances
}
// IsBeingDeleted indicates that MaxScale has been marked for deletion
func (m *MaxScale) IsBeingDeleted() bool {
return !m.DeletionTimestamp.IsZero()
}
// IsReady indicates whether the Maxscale instance is ready.
func (m *MaxScale) IsReady() bool {
return meta.IsStatusConditionTrue(m.Status.Conditions, ConditionTypeReady)
}
// IsHAEnabled indicated whether high availability is enabled.
func (m *MaxScale) IsHAEnabled() bool {
return m.Spec.Replicas > 1
}
// AreMetricsEnabled indicates whether the MariaDB instance has metrics enabled
func (m *MaxScale) AreMetricsEnabled() bool {
return ptr.Deref(m.Spec.Metrics, MaxScaleMetrics{}).Enabled
}
// APIUrl returns the URL of the admin API pointing to the Kubernetes Service.
func (m *MaxScale) APIUrl() string {
fqdn := statefulset.ServiceFQDNWithService(m.ObjectMeta, m.Name)
return m.apiUrlWithAddress(fqdn)
}
// PodAPIUrl returns the URL of the admin API pointing to a Pod.
func (m *MaxScale) PodAPIUrl(podIndex int) string {
fqdn := statefulset.PodFQDNWithService(m.ObjectMeta, podIndex, m.InternalServiceKey().Name)
return m.apiUrlWithAddress(fqdn)
}
// ServerIDs returns the servers indexed by ID.
func (m *MaxScale) ServerIndex() ds.Index[MaxScaleServer] {
return ds.NewIndex[MaxScaleServer](m.Spec.Servers, func(mss MaxScaleServer) string {
return mss.Name
})
}
// ServerIDs returns the IDs of the servers.
func (m *MaxScale) ServerIDs() []string {
return ds.Keys[MaxScaleServer](m.ServerIndex())
}
// ServiceIndex returns the services indexed by ID.
func (m *MaxScale) ServiceIndex() ds.Index[MaxScaleService] {
return ds.NewIndex[MaxScaleService](m.Spec.Services, func(mss MaxScaleService) string {
return mss.Name
})
}
// ServiceIDs returns the IDs of the services.
func (m *MaxScale) ServiceIDs() []string {
return ds.Keys[MaxScaleService](m.ServiceIndex())
}
// ServiceForListener finds the service for a given listener
func (m *MaxScale) ServiceForListener(listener string) (string, error) {
for _, svc := range m.Spec.Services {
if svc.Listener.Name == listener {
return svc.Name, nil
}
}
return "", errors.New("service not found")
}
// Listeners returns the listeners
func (m *MaxScale) Listeners() []MaxScaleListener {
listeners := make([]MaxScaleListener, len(m.Spec.Services))
for i, svc := range m.Spec.Services {
listeners[i] = svc.Listener
}
return listeners
}
// ListenerIndex returns the listeners indexed by ID.
func (m *MaxScale) ListenerIndex() ds.Index[MaxScaleListener] {
return ds.NewIndex[MaxScaleListener](m.Listeners(), func(mss MaxScaleListener) string {
return mss.Name
})
}
// ListenerIDs returns the IDs of the listeners.
func (m *MaxScale) ListenerIDs() []string {
return ds.Keys[MaxScaleListener](m.ListenerIndex())
}
// DefaultPort returns the default port.
func (m *MaxScale) DefaultPort() (*int32, error) {
if len(m.Spec.Services) == 0 {
return nil, errors.New("port not found")
}
return &m.Spec.Services[0].Listener.Port, nil
}
func (m *MaxScale) apiUrlWithAddress(addr string) string {
return fmt.Sprintf("http://%s:%d", addr, m.Spec.Admin.Port)
}
func (m *MaxScale) defaultConnections() int32 {
if m.Spec.Replicas > 0 {
return m.Spec.Replicas * 30
}
return 30
}
// MaxScaleMetricsPasswordSecretFieldPath is the path related to the metrics password Secret field.
const MaxScaleMetricsPasswordSecretFieldPath = ".spec.auth.metricsPasswordSecretKeyRef.name"
// IndexerFuncForFieldPath returns an indexer function for a given field path.
func (m *MaxScale) IndexerFuncForFieldPath(fieldPath string) (client.IndexerFunc, error) {
switch fieldPath {
case MaxScaleMetricsPasswordSecretFieldPath:
return func(obj client.Object) []string {
maxscale, ok := obj.(*MaxScale)
if !ok {
return nil
}
if maxscale.AreMetricsEnabled() && maxscale.Spec.Auth.MetricsPasswordSecretKeyRef.Name != "" {
return []string{maxscale.Spec.Auth.MetricsPasswordSecretKeyRef.Name}
}
return nil
}, nil
default:
return nil, fmt.Errorf("unsupported field path: %s", fieldPath)
}
}
//+kubebuilder:object:root=true
// MaxScaleList contains a list of MaxScale
type MaxScaleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MaxScale `json:"items"`
}
// ListItems gets a copy of the Items slice.
func (m *MaxScaleList) ListItems() []client.Object {
items := make([]client.Object, len(m.Items))
for i, item := range m.Items {
items[i] = item.DeepCopy()
}
return items
}
func init() {
SchemeBuilder.Register(&MaxScale{}, &MaxScaleList{})
}