Skip to content
Open
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
4 changes: 4 additions & 0 deletions deploy/crds/planetscale.com_vitessbackupschedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ spec:
- Forbid
example: Forbid
type: string
extraLabels:
additionalProperties:
type: string
type: object
failedJobsHistoryLimit:
format: int32
minimum: 0
Expand Down
4 changes: 4 additions & 0 deletions deploy/crds/planetscale.com_vitessbackupstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
type: object
spec:
properties:
extraLabels:
additionalProperties:
type: string
type: object
location:
properties:
annotations:
Expand Down
4 changes: 4 additions & 0 deletions deploy/crds/planetscale.com_vitessclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ spec:
- xtrabackup
- mysqlshell
type: string
extraLabels:
additionalProperties:
type: string
type: object
locations:
items:
properties:
Expand Down
66 changes: 66 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,20 @@ This is a list of VitessBackupScheduleTemplate where the “name” fiel
across all the items of the list.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to pods created by backup schedules
and the VitessBackupStorage subcontroller. These labels will be applied to both the backup
schedule job pods and the subcontroller pod.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.ConcurrencyPolicy">ConcurrencyPolicy
Expand Down Expand Up @@ -2540,6 +2554,19 @@ Kubernetes core/v1.PullPolicy
The PullPolicy used will be the same as the one used to pull the vtctld image.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the pods created by VitessBackupSchedule.
This is populated from ClusterBackupSpec.ExtraLabels when the schedule is created.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -2628,6 +2655,19 @@ Kubernetes core/v1.PullPolicy
The PullPolicy used will be the same as the one used to pull the vtctld image.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the pods created by VitessBackupSchedule.
This is populated from ClusterBackupSpec.ExtraLabels when the schedule is created.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.VitessBackupScheduleStatus">VitessBackupScheduleStatus
Expand Down Expand Up @@ -3232,6 +3272,19 @@ VitessBackupSubcontrollerSpec
<p>Subcontroller specifies any parameters needed for launching the VitessBackupStorage subcontroller pod.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the VitessBackupStorage subcontroller pod.
This is populated from ClusterBackupSpec.ExtraLabels when the storage object is created.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -3293,6 +3346,19 @@ VitessBackupSubcontrollerSpec
<p>Subcontroller specifies any parameters needed for launching the VitessBackupStorage subcontroller pod.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the VitessBackupStorage subcontroller pod.
This is populated from ClusterBackupSpec.ExtraLabels when the storage object is created.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.VitessBackupStorageStatus">VitessBackupStorageStatus
Expand Down
66 changes: 66 additions & 0 deletions docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,20 @@ <h3 id="planetscale.com/v2.ClusterBackupSpec">ClusterBackupSpec
across all the items of the list.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to pods created by backup schedules
and the VitessBackupStorage subcontroller. These labels will be applied to both the backup
schedule job pods and the subcontroller pod.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.ConcurrencyPolicy">ConcurrencyPolicy
Expand Down Expand Up @@ -2542,6 +2556,19 @@ <h3 id="planetscale.com/v2.VitessBackupSchedule">VitessBackupSchedule
The PullPolicy used will be the same as the one used to pull the vtctld image.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the pods created by VitessBackupSchedule.
This is populated from ClusterBackupSpec.ExtraLabels when the schedule is created.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -2630,6 +2657,19 @@ <h3 id="planetscale.com/v2.VitessBackupScheduleSpec">VitessBackupScheduleSpec
The PullPolicy used will be the same as the one used to pull the vtctld image.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the pods created by VitessBackupSchedule.
This is populated from ClusterBackupSpec.ExtraLabels when the schedule is created.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.VitessBackupScheduleStatus">VitessBackupScheduleStatus
Expand Down Expand Up @@ -3234,6 +3274,19 @@ <h3 id="planetscale.com/v2.VitessBackupStorage">VitessBackupStorage
<p>Subcontroller specifies any parameters needed for launching the VitessBackupStorage subcontroller pod.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the VitessBackupStorage subcontroller pod.
This is populated from ClusterBackupSpec.ExtraLabels when the storage object is created.</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -3295,6 +3348,19 @@ <h3 id="planetscale.com/v2.VitessBackupStorageSpec">VitessBackupStorageSpec
<p>Subcontroller specifies any parameters needed for launching the VitessBackupStorage subcontroller pod.</p>
</td>
</tr>
<tr>
<td>
<code>extraLabels</code><br>
<em>
map[string]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraLabels can optionally be used to attach custom labels to the VitessBackupStorage subcontroller pod.
This is populated from ClusterBackupSpec.ExtraLabels when the storage object is created.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.VitessBackupStorageStatus">VitessBackupStorageStatus
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/planetscale/v2/vitessbackupschedule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ type VitessBackupScheduleSpec struct {
// ImagePullPolicy defines the policy to pull the Docker image in the job's pod.
// The PullPolicy used will be the same as the one used to pull the vtctld image.
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`

// ExtraLabels can optionally be used to attach custom labels to the pods created by VitessBackupSchedule.
// This is populated from ClusterBackupSpec.ExtraLabels when the schedule is created.
// +optional
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
}

// VitessBackupScheduleTemplate contains all the user-specific fields that the user will be
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/planetscale/v2/vitessbackupstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ type VitessBackupStorageSpec struct {
Location VitessBackupLocation `json:"location"`
// Subcontroller specifies any parameters needed for launching the VitessBackupStorage subcontroller pod.
Subcontroller *VitessBackupSubcontrollerSpec `json:"subcontroller,omitempty"`
// ExtraLabels can optionally be used to attach custom labels to the VitessBackupStorage subcontroller pod.
// This is populated from ClusterBackupSpec.ExtraLabels when the storage object is created.
// +optional
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
}

type VitessBackupSubcontrollerSpec struct {
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/planetscale/v2/vitesscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ type ClusterBackupSpec struct {
// +patchMergeKey=name
// +patchStrategy=merge
Schedules []VitessBackupScheduleTemplate `json:"schedules,omitempty"`

// ExtraLabels can optionally be used to attach custom labels to pods created by backup schedules
// and the VitessBackupStorage subcontroller. These labels will be applied to both the backup
// schedule job pods and the subcontroller pod.
// +optional
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
}

// VitessBackupEngine is the backup implementation to use.
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.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"planetscale.dev/vitess-operator/pkg/operator/reconciler"
"planetscale.dev/vitess-operator/pkg/operator/results"
"planetscale.dev/vitess-operator/pkg/operator/resync"
"planetscale.dev/vitess-operator/pkg/operator/update"
"planetscale.dev/vitess-operator/pkg/operator/vitessbackup"
"planetscale.dev/vitess-operator/pkg/operator/vttablet"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand Down Expand Up @@ -616,6 +617,10 @@ func (r *ReconcileVitessBackupsSchedule) createJob(
planetscalev2.KeyspaceLabel: strategy.Keyspace,
planetscalev2.ShardLabel: vkr.SafeName(),
}
// Merge user-provided extra labels.
if vbsc.Spec.ExtraLabels != nil {
update.Labels(&labels, vbsc.Spec.ExtraLabels)
}

meta := metav1.ObjectMeta{
Labels: labels,
Expand All @@ -629,6 +634,10 @@ func (r *ReconcileVitessBackupsSchedule) createJob(
meta.Annotations[scheduledTimeAnnotation] = scheduledTime.Format(time.RFC3339)

maps.Copy(meta.Labels, vbsc.Labels)
// Merge user-provided extra labels into meta as well.
if vbsc.Spec.ExtraLabels != nil {
update.Labels(&meta.Labels, vbsc.Spec.ExtraLabels)
}

pod, vtbackupSpec, err := r.createJobPod(ctx, vbsc, strategy, name, vkr, labels)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/vitessbackupstorage/reconcile_subcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (r *ReconcileVitessBackupStorage) reconcileSubcontroller(ctx context.Contex
planetscalev2.ClusterLabel: clusterName,
vitessbackup.LocationLabel: vbs.Spec.Location.Name,
}
// Merge user-provided extra labels from ClusterBackupSpec.
if vbs.Spec.ExtraLabels != nil {
update.Labels(&labels, vbs.Spec.ExtraLabels)
}

spec, err := r.newSubcontrollerPodSpec(ctx, vbs)
if err != nil {
Expand Down
Loading