mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 13:26:26 +00:00
Write kubernetes version info to annoations
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
@@ -51,15 +51,15 @@ const (
|
||||
// namespace a restic repository stores pod volume backups for.
|
||||
ResticVolumeNamespaceLabel = "velero.io/volume-namespace"
|
||||
|
||||
// SourceClusterK8sVersionLabel is the label key used to identify the k8s
|
||||
// SourceClusterK8sVersionAnnotation is the label key used to identify the k8s
|
||||
// git version of the backup , i.e. v1.16.4
|
||||
SourceClusterK8sGitVersionLabel = "velero.io/source-cluster-k8s-gitversion"
|
||||
SourceClusterK8sGitVersionAnnotation = "velero.io/source-cluster-k8s-gitversion"
|
||||
|
||||
// SourceClusterK8sMajorVersionLabel is the label key used to identify the k8s
|
||||
// SourceClusterK8sMajorVersionAnnotation is the label key used to identify the k8s
|
||||
// major version of the backup , i.e. 1
|
||||
SourceClusterK8sMajorVersionLabel = "velero.io/source-cluster-k8s-major-version"
|
||||
SourceClusterK8sMajorVersionAnnotation = "velero.io/source-cluster-k8s-major-version"
|
||||
|
||||
// SourceClusterK8sMajorVersionLabel is the label key used to identify the k8s
|
||||
// SourceClusterK8sMajorVersionAnnotation is the label key used to identify the k8s
|
||||
// minor version of the backup , i.e. 16
|
||||
SourceClusterK8sMinorVersionLabel = "velero.io/source-cluster-k8s-minor-version"
|
||||
SourceClusterK8sMinorVersionAnnotation = "velero.io/source-cluster-k8s-minor-version"
|
||||
)
|
||||
|
||||
@@ -333,9 +333,12 @@ func (c *backupController) prepareBackupRequest(backup *velerov1api.Backup) *pkg
|
||||
request.Labels[velerov1api.StorageLocationLabel] = label.GetValidName(request.Spec.StorageLocation)
|
||||
|
||||
// Getting all information of cluster version - useful for future skip-level migration
|
||||
request.Labels[velerov1api.SourceClusterK8sGitVersionLabel] = label.GetValidName(c.discoveryHelper.ServerVersion().String())
|
||||
request.Labels[velerov1api.SourceClusterK8sMajorVersionLabel] = label.GetValidName(c.discoveryHelper.ServerVersion().Major)
|
||||
request.Labels[velerov1api.SourceClusterK8sMinorVersionLabel] = label.GetValidName(c.discoveryHelper.ServerVersion().Minor)
|
||||
if request.Annotations == nil {
|
||||
request.Annotations = make(map[string]string)
|
||||
}
|
||||
request.Annotations[velerov1api.SourceClusterK8sGitVersionAnnotation] = c.discoveryHelper.ServerVersion().String()
|
||||
request.Annotations[velerov1api.SourceClusterK8sMajorVersionAnnotation] = c.discoveryHelper.ServerVersion().Major
|
||||
request.Annotations[velerov1api.SourceClusterK8sMinorVersionAnnotation] = c.discoveryHelper.ServerVersion().Minor
|
||||
|
||||
// validate the included/excluded resources
|
||||
for _, err := range collections.ValidateIncludesExcludes(request.Spec.IncludedResources, request.Spec.ExcludedResources) {
|
||||
|
||||
@@ -359,10 +359,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: velerov1api.DefaultNamespace,
|
||||
Name: "backup-1",
|
||||
Labels: map[string]string{
|
||||
Annotations: map[string]string{
|
||||
"velero.io/source-cluster-k8s-major-version": "1",
|
||||
"velero.io/source-cluster-k8s-minor-version": "16",
|
||||
"velero.io/source-cluster-k8s-gitversion": "v1.16.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"velero.io/storage-location": "loc-1",
|
||||
},
|
||||
},
|
||||
@@ -390,10 +392,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: velerov1api.DefaultNamespace,
|
||||
Name: "backup-1",
|
||||
Labels: map[string]string{
|
||||
Annotations: map[string]string{
|
||||
"velero.io/source-cluster-k8s-major-version": "1",
|
||||
"velero.io/source-cluster-k8s-minor-version": "16",
|
||||
"velero.io/source-cluster-k8s-gitversion": "v1.16.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"velero.io/storage-location": "alt-loc",
|
||||
},
|
||||
},
|
||||
@@ -424,10 +428,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: velerov1api.DefaultNamespace,
|
||||
Name: "backup-1",
|
||||
Labels: map[string]string{
|
||||
Annotations: map[string]string{
|
||||
"velero.io/source-cluster-k8s-major-version": "1",
|
||||
"velero.io/source-cluster-k8s-minor-version": "16",
|
||||
"velero.io/source-cluster-k8s-gitversion": "v1.16.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"velero.io/storage-location": "read-write",
|
||||
},
|
||||
},
|
||||
@@ -455,10 +461,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: velerov1api.DefaultNamespace,
|
||||
Name: "backup-1",
|
||||
Labels: map[string]string{
|
||||
Annotations: map[string]string{
|
||||
"velero.io/source-cluster-k8s-major-version": "1",
|
||||
"velero.io/source-cluster-k8s-minor-version": "16",
|
||||
"velero.io/source-cluster-k8s-gitversion": "v1.16.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"velero.io/storage-location": "loc-1",
|
||||
},
|
||||
},
|
||||
@@ -488,10 +496,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: velerov1api.DefaultNamespace,
|
||||
Name: "backup-1",
|
||||
Labels: map[string]string{
|
||||
Annotations: map[string]string{
|
||||
"velero.io/source-cluster-k8s-major-version": "1",
|
||||
"velero.io/source-cluster-k8s-minor-version": "16",
|
||||
"velero.io/source-cluster-k8s-gitversion": "v1.16.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"velero.io/storage-location": "loc-1",
|
||||
},
|
||||
},
|
||||
@@ -522,10 +532,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: velerov1api.DefaultNamespace,
|
||||
Name: "backup-1",
|
||||
Labels: map[string]string{
|
||||
Annotations: map[string]string{
|
||||
"velero.io/source-cluster-k8s-major-version": "1",
|
||||
"velero.io/source-cluster-k8s-minor-version": "16",
|
||||
"velero.io/source-cluster-k8s-gitversion": "v1.16.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"velero.io/storage-location": "loc-1",
|
||||
},
|
||||
},
|
||||
@@ -554,10 +566,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: velerov1api.DefaultNamespace,
|
||||
Name: "backup-1",
|
||||
Labels: map[string]string{
|
||||
Annotations: map[string]string{
|
||||
"velero.io/source-cluster-k8s-major-version": "1",
|
||||
"velero.io/source-cluster-k8s-minor-version": "16",
|
||||
"velero.io/source-cluster-k8s-gitversion": "v1.16.4",
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"velero.io/storage-location": "loc-1",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user