Skip to content

Commit

Permalink
feat: allow user specify pt-heartbeat resource
Browse files Browse the repository at this point in the history
  • Loading branch information
drivebyer authored and cndoit18 committed Aug 18, 2022
1 parent f0f34ba commit 58c35d1
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
* `MysqlDatabase` `MysqlUser` Add delete policy
* Add `PtHeartbeatResources` in `.Spec.PodSpec` to allow the user specifying resources for pt-heartbeat.
### Changed
* Set default MySQL server version to `5.7.35`
### Removed
Expand Down
22 changes: 22 additions & 0 deletions config/crd/bases/mysql.presslabs.org_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2741,6 +2741,28 @@ spec:
type: object
priorityClassName:
type: string
ptHeartbeatResources:
description: PtHeartbeatResources allows you to specify resources for pt-heartbeat container
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
resources:
description: ResourceRequirements describes the compute resource requirements.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,28 @@ spec:
type: object
priorityClassName:
type: string
ptHeartbeatResources:
description: PtHeartbeatResources allows you to specify resources for pt-heartbeat container
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
resources:
description: ResourceRequirements describes the compute resource requirements.
properties:
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/mysql/v1alpha1/mysqlcluster_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ func (c *MysqlCluster) setPodSpecDefaults(spec *PodSpec) {
// for the sidecar set the same limits as for mysql
spec.MySQLOperatorSidecarResources.Limits = spec.Resources.Limits
}

if len(spec.PtHeartbeatResources.Requests) == 0 {
spec.PtHeartbeatResources.Requests = corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("10m"),
corev1.ResourceMemory: resource.MustParse("32Mi"),
}
}

if len(spec.PtHeartbeatResources.Limits) == 0 {
spec.PtHeartbeatResources.Limits = corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("100m"),
corev1.ResourceMemory: resource.MustParse("64Mi"),
}
}
}

// SetDefaults for VolumeSpec
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ type PodSpec struct {
// used to take backups with xtrabackup
// +optional
MySQLOperatorSidecarResources core.ResourceRequirements `json:"mysqlOperatorSidecarResources,omitempty"`

// PtHeartbeatResources allows you to specify resources for pt-heartbeat container
// +optional
PtHeartbeatResources core.ResourceRequirements `json:"ptHeartbeatResources,omitempty"`
}

// VolumeSpec is the desired spec for storing mysql data. Only one of its
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions pkg/controller/mysqlcluster/internal/syncer/statefullset.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,6 @@ func (s *sfsSyncer) getLabels(extra map[string]string) map[string]string {
}

func (s *sfsSyncer) ensureResources(name string) core.ResourceRequirements {
limits := core.ResourceList{
core.ResourceCPU: resource.MustParse("100m"),
}
requests := core.ResourceList{
core.ResourceCPU: resource.MustParse("10m"),
core.ResourceMemory: resource.MustParse("32Mi"),
}

switch name {
case containerExporterName:
return s.cluster.Spec.PodSpec.MetricsExporterResources
Expand All @@ -688,16 +680,20 @@ func (s *sfsSyncer) ensureResources(name string) core.ResourceRequirements {
return s.cluster.Spec.PodSpec.Resources

case containerHeartBeatName:
limits[core.ResourceMemory] = resource.MustParse("64Mi")
return s.cluster.Spec.PodSpec.PtHeartbeatResources

case containerSidecarName:
return s.cluster.Spec.PodSpec.MySQLOperatorSidecarResources

}

return core.ResourceRequirements{
Limits: limits,
Requests: requests,
Limits: core.ResourceList{
core.ResourceCPU: resource.MustParse("100m"),
},
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse("10m"),
core.ResourceMemory: resource.MustParse("32Mi"),
},
}
}

Expand Down

0 comments on commit 58c35d1

Please sign in to comment.