Skip to content

Commit

Permalink
Add mysqld exporter resources spec
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Krasilnikov <[email protected]>
  • Loading branch information
chapsuk committed Oct 16, 2023
1 parent 2f52734 commit 1208eb7
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 0 deletions.
72 changes: 72 additions & 0 deletions deploy/crds/planetscale.com_vitessclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,42 @@ spec:
required:
- resources
type: object
mysqldExporter:
properties:
resources:
properties:
claims:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
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
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
type: object
type: object
required:
- resources
type: object
name:
default: ""
type: string
Expand Down Expand Up @@ -1900,6 +1936,42 @@ spec:
required:
- resources
type: object
mysqldExporter:
properties:
resources:
properties:
claims:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
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
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
type: object
type: object
required:
- resources
type: object
name:
default: ""
type: string
Expand Down
72 changes: 72 additions & 0 deletions deploy/crds/planetscale.com_vitesskeyspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,42 @@ spec:
required:
- resources
type: object
mysqldExporter:
properties:
resources:
properties:
claims:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
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
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
type: object
type: object
required:
- resources
type: object
name:
default: ""
type: string
Expand Down Expand Up @@ -948,6 +984,42 @@ spec:
required:
- resources
type: object
mysqldExporter:
properties:
resources:
properties:
claims:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
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
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
type: object
type: object
required:
- resources
type: object
name:
default: ""
type: string
Expand Down
36 changes: 36 additions & 0 deletions deploy/crds/planetscale.com_vitessshards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,42 @@ spec:
required:
- resources
type: object
mysqldExporter:
properties:
resources:
properties:
claims:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
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
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
type: object
type: object
required:
- resources
type: object
name:
default: ""
type: string
Expand Down
45 changes: 45 additions & 0 deletions docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,38 @@ <h3 id="planetscale.com/v2.LockserverStatus">LockserverStatus
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.MysqldExporterSpec">MysqldExporterSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#planetscale.com/v2.VitessShardTabletPool">VitessShardTabletPool</a>)
</p>
<p>
<p>MysqldExporterSpec configures the local MySQL exporter within a tablet.</p>
</p>
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>resources</code></br>
<em>
<a href="https://v1-18.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#resourcerequirements-v1-core">
Kubernetes core/v1.ResourceRequirements
</a>
</em>
</td>
<td>
<p>Resources specify the compute resources to allocate for just the MySQL Exporter.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.MysqldImage">MysqldImage
</h3>
<p>
Expand Down Expand Up @@ -7154,6 +7186,19 @@ <h3 id="planetscale.com/v2.VitessShardTabletPool">VitessShardTabletPool
</tr>
<tr>
<td>
<code>mysqldExporter</code></br>
<em>
<a href="#planetscale.com/v2.MysqldExporterSpec">
MysqldExporterSpec
</a>
</em>
</td>
<td>
<p>MysqldExporter configures a MySQL exporter running inside each tablet Pod.</p>
</td>
</tr>
<tr>
<td>
<code>externalDatastore</code></br>
<em>
<a href="#planetscale.com/v2.ExternalDatastore">
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/planetscale/v2/vitessshard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ type VitessShardTabletPool struct {
// Mysqld configures a local MySQL running inside each tablet Pod.
// You must specify either Mysqld or ExternalDatastore, but not both.
Mysqld *MysqldSpec `json:"mysqld,omitempty"`

// MysqldExporter configures a MySQL exporter running inside each tablet Pod.
MysqldExporter *MysqldExporterSpec `json:"mysqldExporter,omitempty"`

// ExternalDatastore provides information for an externally managed MySQL.
// You must specify either Mysqld or ExternalDatastore, but not both.
ExternalDatastore *ExternalDatastore `json:"externalDatastore,omitempty"`
Expand Down Expand Up @@ -307,6 +311,12 @@ type MysqldSpec struct {
ConfigOverrides string `json:"configOverrides,omitempty"`
}

// MysqldExporterSpec configures the local MySQL exporter within a tablet.
type MysqldExporterSpec struct {
// Resources specify the compute resources to allocate for just the MySQL Exporter.
Resources corev1.ResourceRequirements `json:"resources"`
}

// VitessTabletPoolType represents the tablet types for which it makes sense
// to deploy a dedicated pool. Tablet types that indicate temporary or
// transient states are not valid pool types.
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/planetscale/v2/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions pkg/controller/vitessshard/reconcile_backup_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func vtbackupSpec(key client.ObjectKey, vts *planetscalev2.VitessShard, parentLa
KeyRange: vts.Spec.KeyRange,
Vttablet: &pool.Vttablet,
Mysqld: pool.Mysqld,
MysqldExporter: pool.MysqldExporter,
DataVolumePVCName: key.Name,
DataVolumePVCSpec: pool.DataVolumeClaimTemplate,
KeyspaceName: keyspaceName,
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/vitessshard/reconcile_tablets.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ func vttabletSpecs(vts *planetscalev2.VitessShard, parentLabels map[string]strin
Zone: vts.Spec.ZoneMap[tabletAlias.Cell],
Vttablet: &vttabletcpy,
Mysqld: pool.Mysqld,
MysqldExporter: pool.MysqldExporter,
ExternalDatastore: pool.ExternalDatastore,
Type: pool.Type,
DataVolumePVCSpec: pool.DataVolumeClaimTemplate,
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/vttablet/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
// This depends on the exact semantics of each of mysqld-exporter's HTTP handlers,
// so we need to do more investigation. For now it's better to leave them empty.
}

if spec.MysqldExporter != nil {
update.ResourceRequirements(&mysqldExporterContainer.Resources, &spec.MysqldExporter.Resources)
}
}

// Set the resource requirements on each of the default vttablet init
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/vttablet/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Spec struct {
DatabaseName string
Vttablet *planetscalev2.VttabletSpec
Mysqld *planetscalev2.MysqldSpec
MysqldExporter *planetscalev2.MysqldExporterSpec
ExternalDatastore *planetscalev2.ExternalDatastore
DataVolumePVCSpec *corev1.PersistentVolumeClaimSpec
DataVolumePVCName string
Expand Down

0 comments on commit 1208eb7

Please sign in to comment.