Skip to content

Commit 13235d3

Browse files
committed
*: add log pvc for errolog
1 parent fe27496 commit 13235d3

File tree

10 files changed

+531
-63
lines changed

10 files changed

+531
-63
lines changed

api/v1alpha1/mysqlcluster_types.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ type MysqlOpts struct {
227227
// +kubebuilder:validation:Minimum=0
228228
// +optional
229229
MaxLagSeconds int `json:"maxLagTime,omitempty"`
230+
231+
// LogfilePVC represents the pvc which save the mysql error log.
232+
// Log file to pvc
233+
// +optional
234+
LogfilePVC *LogPVC `json:"logfilePVC,omitempty"`
230235
}
231236

232237
// XenonOpts defines the options of xenon container.
@@ -317,11 +322,6 @@ type PodPolicy struct {
317322
// +optional
318323
// +kubebuilder:default:=false
319324
AuditLogTail bool `json:"auditLogTail,omitempty"`
320-
321-
// ErrorLogTail represents if tail the mysql error log.
322-
// +optional
323-
// +kubebuilder:default:=false
324-
ErrorLogTail bool `json:"errorLogTail,omitempty"`
325325
}
326326

327327
// Persistence is the desired spec for storing mysql data. Only one of its
@@ -349,6 +349,27 @@ type Persistence struct {
349349
Size string `json:"size,omitempty"`
350350
}
351351

352+
// Persistence is the desired spec for storing mysql data. Only one of its
353+
// members may be specified.
354+
type LogPVC struct {
355+
356+
// AccessModes contains the desired access modes the volume should have.
357+
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1
358+
// +optional
359+
// +kubebuilder:default:={"ReadWriteOnce"}
360+
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
361+
362+
// Name of the StorageClass required by the claim.
363+
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1
364+
// +optional
365+
StorageClass *string `json:"storageClass,omitempty"`
366+
367+
// Size of persistent volume claim.
368+
// +optional
369+
// +kubebuilder:default:="10Gi"
370+
Size string `json:"size,omitempty"`
371+
}
372+
352373
// bothS3NFS opt
353374
type BothS3NFSOpt struct {
354375
// NFS schedule.

api/v1alpha1/zz_generated.deepcopy.go

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

api/v1beta1/mysqlcluster_conversion.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,17 @@ func Convert_v1alpha1_MysqlClusterSpec_To_v1beta1_MysqlClusterSpec(in *v1alpha1.
8080
out.Backup.Resources = in.PodPolicy.ExtraResources
8181
out.Log.SlowLogTail = in.PodPolicy.SlowLogTail
8282
out.Log.AuditLogTail = in.PodPolicy.AuditLogTail
83-
out.Log.ErrorLogTail = in.PodPolicy.ErrorLogTail
83+
if in.MysqlOpts.LogfilePVC != nil {
84+
out.Log.LogfilePVC = &corev1.PersistentVolumeClaimSpec{}
85+
out.Log.LogfilePVC.AccessModes = in.MysqlOpts.LogfilePVC.AccessModes
86+
out.Log.LogfilePVC.Resources.Requests = map[corev1.ResourceName]resource.Quantity{
87+
corev1.ResourceStorage: resource.MustParse(in.MysqlOpts.LogfilePVC.Size),
88+
}
89+
out.Log.LogfilePVC.StorageClassName = in.MysqlOpts.LogfilePVC.StorageClass
90+
} else {
91+
out.Log.LogfilePVC = nil
92+
}
93+
8494
out.Tolerations = in.PodPolicy.Tolerations
8595
out.PriorityClassName = in.PodPolicy.PriorityClassName
8696
out.Log.BusyboxImage = in.PodPolicy.BusyboxImage
@@ -156,7 +166,17 @@ func Convert_v1beta1_MysqlClusterSpec_To_v1alpha1_MysqlClusterSpec(in *MysqlClus
156166
out.MysqlOpts.Image = in.Image
157167
out.PodPolicy.SlowLogTail = in.Log.SlowLogTail
158168
out.PodPolicy.AuditLogTail = in.Log.AuditLogTail
159-
out.PodPolicy.ErrorLogTail = in.Log.ErrorLogTail
169+
//out.MysqlOpts.LogfilePVC = (*v1alpha1.LogPVC)(in.Log.LogfilePVC)
170+
if in.Log.LogfilePVC != nil {
171+
out.MysqlOpts.LogfilePVC = &v1alpha1.LogPVC{}
172+
out.MysqlOpts.LogfilePVC.StorageClass = in.Log.LogfilePVC.StorageClassName
173+
out.MysqlOpts.LogfilePVC.Size = FormatQuantity(in.Log.LogfilePVC.Resources.Requests[corev1.ResourceStorage])
174+
out.MysqlOpts.LogfilePVC.AccessModes = in.Log.LogfilePVC.AccessModes
175+
} else {
176+
out.MysqlOpts.LogfilePVC = nil
177+
}
178+
179+
out.XenonOpts = v1alpha1.XenonOpts(in.Xenon)
160180
out.PodPolicy.BusyboxImage = in.Log.BusyboxImage
161181
out.MetricsOpts.Enabled = in.Monitoring.Exporter.Enabled
162182
out.PodPolicy.ImagePullPolicy = in.ImagePullPolicy

api/v1beta1/mysqlcluster_types.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,10 @@ type LogOpts struct {
490490
// +kubebuilder:default:=false
491491
AuditLogTail bool `json:"auditLogTail,omitempty"`
492492

493-
// ErrorLogTail represents if tail the mysql error log.
493+
// logPvc represents pvc which save the mysql error log.
494+
// Log file to pvc
494495
// +optional
495-
// +kubebuilder:default:=false
496-
ErrorLogTail bool `json:"errorLogTail,omitempty"`
497-
496+
LogfilePVC *corev1.PersistentVolumeClaimSpec `json:"logfilePVC,omitempty"`
498497
//Log container resources of a MySQL container.
499498
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
500499
}

api/v1beta1/zz_generated.deepcopy.go

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

charts/mysql-operator/templates/mysql.radondb.com_mysqlclusters.yaml

Lines changed: 186 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,27 @@ spec:
196196
default: false
197197
description: InitTokuDB represents if install tokudb engine.
198198
type: boolean
199+
logfilePVC:
200+
description: LogfilePVC represents the pvc which save the mysql
201+
error log. Log file to pvc
202+
properties:
203+
accessModes:
204+
default:
205+
- ReadWriteOnce
206+
description: 'AccessModes contains the desired access modes
207+
the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1'
208+
items:
209+
type: string
210+
type: array
211+
size:
212+
default: 10Gi
213+
description: Size of persistent volume claim.
214+
type: string
215+
storageClass:
216+
description: 'Name of the StorageClass required by the claim.
217+
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
218+
type: string
219+
type: object
199220
maxLagTime:
200221
default: 30
201222
description: MaxLagSeconds configures the readiness probe of mysqld
@@ -1216,10 +1237,6 @@ spec:
12161237
default: busybox:1.32
12171238
description: The busybox image.
12181239
type: string
1219-
errorLogTail:
1220-
default: false
1221-
description: ErrorLogTail represents if tail the mysql error log.
1222-
type: boolean
12231240
extraResources:
12241241
default:
12251242
requests:
@@ -3636,15 +3653,176 @@ spec:
36363653
default: false
36373654
description: AuditLogTail represents if tail the mysql audit log.
36383655
type: boolean
3639-
errorLogTail:
3640-
default: false
3641-
description: ErrorLogTail represents if tail the mysql error log.
3642-
type: boolean
36433656
image:
36443657
default: busybox:1.32
36453658
description: To specify the image that will be used for log container.
36463659
The busybox image.
36473660
type: string
3661+
logfilePVC:
3662+
description: logPvc represents pvc which save the mysql error
3663+
log. Log file to pvc
3664+
properties:
3665+
accessModes:
3666+
description: 'AccessModes contains the desired access modes
3667+
the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1'
3668+
items:
3669+
type: string
3670+
type: array
3671+
dataSource:
3672+
description: 'This field can be used to specify either: *
3673+
An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot)
3674+
* An existing PVC (PersistentVolumeClaim) If the provisioner
3675+
or an external controller can support the specified data
3676+
source, it will create a new volume based on the contents
3677+
of the specified data source. If the AnyVolumeDataSource
3678+
feature gate is enabled, this field will always have the
3679+
same contents as the DataSourceRef field.'
3680+
properties:
3681+
apiGroup:
3682+
description: APIGroup is the group for the resource being
3683+
referenced. If APIGroup is not specified, the specified
3684+
Kind must be in the core API group. For any other third-party
3685+
types, APIGroup is required.
3686+
type: string
3687+
kind:
3688+
description: Kind is the type of resource being referenced
3689+
type: string
3690+
name:
3691+
description: Name is the name of resource being referenced
3692+
type: string
3693+
required:
3694+
- kind
3695+
- name
3696+
type: object
3697+
dataSourceRef:
3698+
description: 'Specifies the object from which to populate
3699+
the volume with data, if a non-empty volume is desired.
3700+
This may be any local object from a non-empty API group
3701+
(non core object) or a PersistentVolumeClaim object. When
3702+
this field is specified, volume binding will only succeed
3703+
if the type of the specified object matches some installed
3704+
volume populator or dynamic provisioner. This field will
3705+
replace the functionality of the DataSource field and as
3706+
such if both fields are non-empty, they must have the same
3707+
value. For backwards compatibility, both fields (DataSource
3708+
and DataSourceRef) will be set to the same value automatically
3709+
if one of them is empty and the other is non-empty. There
3710+
are two important differences between DataSource and DataSourceRef:
3711+
* While DataSource only allows two specific types of objects,
3712+
DataSourceRef allows any non-core object, as well as PersistentVolumeClaim
3713+
objects. * While DataSource ignores disallowed values (dropping
3714+
them), DataSourceRef preserves all values, and generates
3715+
an error if a disallowed value is specified. (Alpha) Using
3716+
this field requires the AnyVolumeDataSource feature gate
3717+
to be enabled.'
3718+
properties:
3719+
apiGroup:
3720+
description: APIGroup is the group for the resource being
3721+
referenced. If APIGroup is not specified, the specified
3722+
Kind must be in the core API group. For any other third-party
3723+
types, APIGroup is required.
3724+
type: string
3725+
kind:
3726+
description: Kind is the type of resource being referenced
3727+
type: string
3728+
name:
3729+
description: Name is the name of resource being referenced
3730+
type: string
3731+
required:
3732+
- kind
3733+
- name
3734+
type: object
3735+
resources:
3736+
description: 'Resources represents the minimum resources the
3737+
volume should have. If RecoverVolumeExpansionFailure feature
3738+
is enabled users are allowed to specify resource requirements
3739+
that are lower than previous value but must still be higher
3740+
than capacity recorded in the status field of the claim.
3741+
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources'
3742+
properties:
3743+
limits:
3744+
additionalProperties:
3745+
anyOf:
3746+
- type: integer
3747+
- type: string
3748+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
3749+
x-kubernetes-int-or-string: true
3750+
description: 'Limits describes the maximum amount of compute
3751+
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
3752+
type: object
3753+
requests:
3754+
additionalProperties:
3755+
anyOf:
3756+
- type: integer
3757+
- type: string
3758+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
3759+
x-kubernetes-int-or-string: true
3760+
description: 'Requests describes the minimum amount of
3761+
compute resources required. If Requests is omitted for
3762+
a container, it defaults to Limits if that is explicitly
3763+
specified, otherwise to an implementation-defined value.
3764+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
3765+
type: object
3766+
type: object
3767+
selector:
3768+
description: A label query over volumes to consider for binding.
3769+
properties:
3770+
matchExpressions:
3771+
description: matchExpressions is a list of label selector
3772+
requirements. The requirements are ANDed.
3773+
items:
3774+
description: A label selector requirement is a selector
3775+
that contains values, a key, and an operator that
3776+
relates the key and values.
3777+
properties:
3778+
key:
3779+
description: key is the label key that the selector
3780+
applies to.
3781+
type: string
3782+
operator:
3783+
description: operator represents a key's relationship
3784+
to a set of values. Valid operators are In, NotIn,
3785+
Exists and DoesNotExist.
3786+
type: string
3787+
values:
3788+
description: values is an array of string values.
3789+
If the operator is In or NotIn, the values array
3790+
must be non-empty. If the operator is Exists or
3791+
DoesNotExist, the values array must be empty.
3792+
This array is replaced during a strategic merge
3793+
patch.
3794+
items:
3795+
type: string
3796+
type: array
3797+
required:
3798+
- key
3799+
- operator
3800+
type: object
3801+
type: array
3802+
matchLabels:
3803+
additionalProperties:
3804+
type: string
3805+
description: matchLabels is a map of {key,value} pairs.
3806+
A single {key,value} in the matchLabels map is equivalent
3807+
to an element of matchExpressions, whose key field is
3808+
"key", the operator is "In", and the values array contains
3809+
only "value". The requirements are ANDed.
3810+
type: object
3811+
type: object
3812+
storageClassName:
3813+
description: 'Name of the StorageClass required by the claim.
3814+
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
3815+
type: string
3816+
volumeMode:
3817+
description: volumeMode defines what type of volume is required
3818+
by the claim. Value of Filesystem is implied when not included
3819+
in claim spec.
3820+
type: string
3821+
volumeName:
3822+
description: VolumeName is the binding reference to the PersistentVolume
3823+
backing this claim.
3824+
type: string
3825+
type: object
36483826
resources:
36493827
description: Log container resources of a MySQL container.
36503828
properties:

0 commit comments

Comments
 (0)