Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MySQL InnoDB cluster #17

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kubedb.com/v1alpha2/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (r MySQL) roleResourceFn(fn func(rr core.ResourceRequirements) core.Resourc
return nil, err
}
if found && mode == "InnoDBCluster" {
router, replicas, err := api.AppNodeResources(obj, fn, "spec", "topology", "innoDBCluster")
router, replicas, err := api.AppNodeResources(obj, fn, "spec", "topology", "innoDBCluster", "router")
if err != nil {
return nil, err
}
Expand Down
62 changes: 62 additions & 0 deletions kubedb.com/v1alpha2/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,68 @@ func TestMySQL(t *testing.T) {
},
},
},
{
name: "testdata/kubedb.com/v1alpha2/mysql/group-replication.yaml",
want: want{
replicas: 3,
mode: "GroupReplication",
totalResources: core.ResourceRequirements{
Limits: core.ResourceList{
core.ResourceCPU: resource.MustParse("3"),
core.ResourceMemory: resource.MustParse("3456Mi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse("1.5"),
core.ResourceMemory: resource.MustParse("1692Mi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
},
appResources: core.ResourceRequirements{
Limits: core.ResourceList{
core.ResourceCPU: resource.MustParse("1.5"),
core.ResourceMemory: resource.MustParse("3Gi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse("750m"),
core.ResourceMemory: resource.MustParse("1500Mi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
},
},
},
{
name: "testdata/kubedb.com/v1alpha2/mysql/innodb.yaml",
want: want{
replicas: 4,
mode: "InnoDBCluster",
totalResources: core.ResourceRequirements{
Limits: core.ResourceList{
core.ResourceCPU: resource.MustParse("3.5"),
core.ResourceMemory: resource.MustParse("4480Mi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse("1.75"),
core.ResourceMemory: resource.MustParse("2192Mi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
},
appResources: core.ResourceRequirements{
Limits: core.ResourceList{
core.ResourceCPU: resource.MustParse("2"),
core.ResourceMemory: resource.MustParse("4Gi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse("1"),
core.ResourceMemory: resource.MustParse("2000Mi"),
core.ResourceStorage: resource.MustParse("3Gi"),
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
41 changes: 41 additions & 0 deletions testdata/kubedb.com/v1alpha2/mysql/group-replication.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: kubedb.com/v1alpha2
kind: MySQL
metadata:
name: my-group
namespace: demo
spec:
version: "8.0.23-v1"
replicas: 3
topology:
mode: GroupReplication
group:
name: "dc002fc3-c412-4d18-b1d4-66c1fbfbbc9b"
storageType: Durable
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
terminationPolicy: WipeOut
podTemplate:
spec:
resources:
requests:
cpu: 250m
memory: 500Mi
limits:
cpu: 500m
memory: 1Gi
monitor:
agent: prometheus.io
prometheus:
exporter:
resources:
requests:
cpu: 250m
memory: 64Mi
limits:
cpu: 500m
memory: 128Mi
69 changes: 69 additions & 0 deletions testdata/kubedb.com/v1alpha2/mysql/innodb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: kubedb.com/v1alpha2
kind: MySQL
metadata:
name: "innodb"
namespace: demo
spec:
podTemplate:
spec:
resources:
requests:
cpu: 250m
memory: 500Mi
limits:
cpu: 500m
memory: 1Gi
monitor:
agent: prometheus.io
prometheus:
exporter:
resources:
requests:
cpu: 250m
memory: 64Mi
limits:
cpu: 500m
memory: 128Mi
version: "8.0.24"
replicas: 3
topology:
mode: InnoDBCluster
innoDBCluster:
router:
replicas: 1
podTemplate:
spec:
resources:
requests:
cpu: 250m
memory: 500Mi
limits:
cpu: 500m
memory: 1Gi
storageType: Durable
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
requireSSL: true
tls:
issuerRef:
apiGroup: cert-manager.io
kind: Issuer
name: mysql-issuer
certificates:
- alias: server
subject:
organizations:
- kubedb:server
dnsNames:
- localhost
ipAddresses:
- "127.0.0.1"
terminationPolicy: WipeOut
# useAddressType: IPv6