-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, the only restore supported was in a DR scenario and required usage of a separate python package ("kubedrctl"). With this change, one can create a resource "MetadataRestore" and etcd snapshot (and optionally certificates) will be restored to the given PVC.
- Loading branch information
Showing
21 changed files
with
760 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
Copyright 2020 Catalogic Software | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// MetadataRestoreSpec defines the desired state of MetadataRestore | ||
type MetadataRestoreSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// kubebuilder:validation:MinLength:=1 | ||
MBRName string `json:"mbrName"` | ||
|
||
// kubebuilder:validation:MinLength:=1 | ||
PVCName string `json:"pvcName"` | ||
} | ||
|
||
// MetadataRestoreStatus defines the observed state of MetadataRestore | ||
type MetadataRestoreStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// +kubebuilder:validation:Optional | ||
ObservedGeneration int64 `json:"observedGeneration"` | ||
|
||
RestoreStatus string `json:"restoreStatus"` | ||
|
||
// +kubebuilder:validation:Optional | ||
RestoreErrorMessage string `json:"restoreErrorMessage"` | ||
|
||
RestoreTime string `json:"restoreTime"` | ||
} | ||
|
||
// The creation of this resource triggers full restore of the data | ||
// (etcd snapshot and certificates (if they were part of the backup). | ||
// It would have been ideal to use a custom subresource (such as | ||
// "/restore" but custom subresources are not yet supported for | ||
// custom resources. | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// MetadataRestore is the Schema for the metadatarestores API | ||
type MetadataRestore struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec MetadataRestoreSpec `json:"spec,omitempty"` | ||
Status MetadataRestoreStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// MetadataRestoreList contains a list of MetadataRestore | ||
type MetadataRestoreList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []MetadataRestore `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&MetadataRestore{}, &MetadataRestoreList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
kubedr/config/crd/bases/kubedr.catalogicsoftware.com_metadatarestores.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.2.2 | ||
creationTimestamp: null | ||
name: metadatarestores.kubedr.catalogicsoftware.com | ||
spec: | ||
group: kubedr.catalogicsoftware.com | ||
names: | ||
kind: MetadataRestore | ||
listKind: MetadataRestoreList | ||
plural: metadatarestores | ||
singular: metadatarestore | ||
scope: "" | ||
subresources: | ||
status: {} | ||
validation: | ||
openAPIV3Schema: | ||
description: MetadataRestore is the Schema for the metadatarestores API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: MetadataRestoreSpec defines the desired state of MetadataRestore | ||
properties: | ||
mbrName: | ||
description: kubebuilder:validation:MinLength:=1 | ||
type: string | ||
pvcName: | ||
description: kubebuilder:validation:MinLength:=1 | ||
type: string | ||
required: | ||
- mbrName | ||
- pvcName | ||
type: object | ||
status: | ||
description: MetadataRestoreStatus defines the observed state of MetadataRestore | ||
properties: | ||
observedGeneration: | ||
format: int64 | ||
type: integer | ||
restoreErrorMessage: | ||
type: string | ||
restoreStatus: | ||
type: string | ||
restoreTime: | ||
type: string | ||
required: | ||
- restoreStatus | ||
- restoreTime | ||
type: object | ||
type: object | ||
version: v1alpha1 | ||
versions: | ||
- name: v1alpha1 | ||
served: true | ||
storage: true | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
kubedr/config/crd/patches/cainjection_in_metadatarestores.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# The following patch adds a directive for certmanager to inject CA into the CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) | ||
name: metadatarestores.kubedr.catalogicsoftware.com |
17 changes: 17 additions & 0 deletions
17
kubedr/config/crd/patches/webhook_in_metadatarestores.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# The following patch enables conversion webhook for CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: metadatarestores.kubedr.catalogicsoftware.com | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhookClientConfig: | ||
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, | ||
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) | ||
caBundle: Cg== | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: kubedr.catalogicsoftware.com/v1alpha1 | ||
kind: MetadataRestore | ||
metadata: | ||
name: metadatarestore-sample | ||
spec: | ||
# Add fields here | ||
foo: bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.