forked from kosmos-io/kosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: syncleaf CRD and informer init
Signed-off-by: renxiangyu <[email protected]>
- Loading branch information
renxiangyu
committed
Jan 29, 2024
1 parent
6ab2df4
commit abf69ea
Showing
19 changed files
with
1,247 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.11.0 | ||
creationTimestamp: null | ||
name: promotepolicies.kosmos.io | ||
spec: | ||
group: kosmos.io | ||
names: | ||
kind: PromotePolicy | ||
listKind: PromotePolicyList | ||
plural: promotepolicies | ||
singular: promotepolicy | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: PromotePolicy is custom resource that represents the capture | ||
of sync leaf cluster | ||
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: PromotePolicySpec defines the desired state of promotePolicy | ||
properties: | ||
clusterName: | ||
description: Cluster is a cluster that needs to be migrated | ||
type: string | ||
excludedNamespaceScopedResources: | ||
description: ExcludedNamespaceScopedResources is a slice of namespace-scoped | ||
resource type names to exclude from the backup. If set to "*", all | ||
namespace-scoped resource types are excluded. The default value | ||
is empty. | ||
items: | ||
type: string | ||
nullable: true | ||
type: array | ||
excludedNamespaces: | ||
description: ExcludedNamespaces contains a list of namespaces that | ||
are not included in the backup. | ||
items: | ||
type: string | ||
nullable: true | ||
type: array | ||
includedNamespaceScopedResources: | ||
description: IncludedNamespaceScopedResources is a slice of namespace-scoped | ||
resource type names to include in the backup. The default value | ||
is "*". | ||
items: | ||
type: string | ||
nullable: true | ||
type: array | ||
includedNamespaces: | ||
description: IncludedNamespaces is a slice of namespace names to include | ||
objects from. If empty, all namespaces are included. | ||
items: | ||
type: string | ||
nullable: true | ||
type: array | ||
type: object | ||
status: | ||
description: PromotePolicyStatus defines the observed state of promotePolicy | ||
properties: | ||
completionTimestamp: | ||
description: CompletionTimestamp records the time a sync was completed. | ||
Completion time is recorded even on failed sync. The server's time | ||
is used for CompletionTimestamps | ||
format: date-time | ||
nullable: true | ||
type: string | ||
failureReason: | ||
description: FailureReason is an error that caused the entire sync | ||
to fail. | ||
type: string | ||
phase: | ||
description: Phase is the current state of the Backup. | ||
type: string | ||
precheckErrors: | ||
description: PrecheckErrors is a slice of all precheck errors (if | ||
applicable). | ||
items: | ||
type: string | ||
nullable: true | ||
type: array | ||
progress: | ||
description: Progress contains information about the sync's execution | ||
progress. Note that this information is best-effort only -- if fails | ||
to update it for any reason, it may be inaccurate/stale. | ||
nullable: true | ||
properties: | ||
itemsBackedUp: | ||
description: ItemsBackedUp is the number of items that have actually | ||
been written to the backup tarball so far. | ||
type: integer | ||
totalItems: | ||
description: TotalItems is the total number of items to be backed | ||
up. This number may change throughout the execution of the backup | ||
due to plugins that return additional related items to back | ||
up, the velero.io/exclude-from-backup label, and various other | ||
filters that happen as items are processed. | ||
type: integer | ||
type: object | ||
startTimestamp: | ||
description: StartTimestamp records the time a sync was started. The | ||
server's time is used for StartTimestamps | ||
format: date-time | ||
nullable: true | ||
type: string | ||
type: object | ||
type: object | ||
served: true | ||
storage: true |
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,18 @@ | ||
apiVersion: kosmos.io/v1alpha1 | ||
kind: PromotePolicy | ||
metadata: | ||
name: promote-pilicy-sample | ||
spec: | ||
includedNamespaces: | ||
- namespace1 | ||
- namespace2 | ||
excludedNamespaces: | ||
- namespace3 | ||
includedNamespaceScopedResources: | ||
- deployment | ||
- service | ||
excludedNamespaceScopedResources: | ||
- pod | ||
clusterName: | ||
cluster | ||
|
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,153 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// PromotePolicySpec defines the desired state of promotePolicy | ||
type PromotePolicySpec struct { | ||
// Cluster is a cluster that needs to be migrated | ||
ClusterName string `json:"clusterName,omitempty"` | ||
|
||
// IncludedNamespaces is a slice of namespace names to include objects | ||
// from. If empty, all namespaces are included. | ||
// +optional | ||
// +nullable | ||
IncludedNamespaces []string `json:"includedNamespaces,omitempty"` | ||
|
||
// ExcludedNamespaces contains a list of namespaces that are not | ||
// included in the backup. | ||
// +optional | ||
// +nullable | ||
ExcludedNamespaces []string `json:"excludedNamespaces,omitempty"` | ||
|
||
// IncludedNamespaceScopedResources is a slice of namespace-scoped | ||
// resource type names to include in the backup. | ||
// The default value is "*". | ||
// +optional | ||
// +nullable | ||
IncludedNamespaceScopedResources []string `json:"includedNamespaceScopedResources,omitempty"` | ||
|
||
// ExcludedNamespaceScopedResources is a slice of namespace-scoped | ||
// resource type names to exclude from the backup. | ||
// If set to "*", all namespace-scoped resource types are excluded. | ||
// The default value is empty. | ||
// +optional | ||
// +nullable | ||
ExcludedNamespaceScopedResources []string `json:"excludedNamespaceScopedResources,omitempty"` | ||
} | ||
|
||
// PromotePolicyPhase is a string representation of the lifecycle phase | ||
type PromotePolicyPhase string | ||
|
||
const ( | ||
// PromotePolicyPhasePrecheck means in precheck progess | ||
PromotePolicyPhasePrecheck PromotePolicyPhase = "Prechecking" | ||
|
||
// PromotePolicyPhaseFailedPrecheck means precheck has failed | ||
PromotePolicyPhaseFailedPrecheck PromotePolicyPhase = "FailedPrecheck" | ||
|
||
// PromotePolicyPhaseBackup means in backup progess | ||
PromotePolicyPhaseBackup PromotePolicyPhase = "Backuping" | ||
|
||
// PromotePolicyPhaseFailedBackup means backup has failed | ||
PromotePolicyPhaseFailedBackup PromotePolicyPhase = "FailedBackup" | ||
|
||
// PromotePolicyPhaseDetach means in detach progess | ||
PromotePolicyPhaseDetach PromotePolicyPhase = "Detaching" | ||
|
||
// PromotePolicyPhaseFailedDetach means detach has failed | ||
PromotePolicyPhaseFailedDetach PromotePolicyPhase = "FailedDetach" | ||
|
||
// PromotePolicyPhaseRestore means in restore progess | ||
PromotePolicyPhaseRestore PromotePolicyPhase = "Restoring" | ||
|
||
// PromotePolicyPhaseFailedRestore means restore has failed | ||
PromotePolicyPhaseFailedRestore PromotePolicyPhase = "FailedRestore" | ||
|
||
// PromotePolicyPhaseCompleted means the sync has run successfully | ||
PromotePolicyPhaseCompleted PromotePolicyPhase = "Completed" | ||
) | ||
|
||
// BackupProgress stores information about the progress of a Backup's execution. | ||
type PromotePolicyProgress struct { | ||
// TotalItems is the total number of items to be backed up. This number may change | ||
// throughout the execution of the backup due to plugins that return additional related | ||
// items to back up, the velero.io/exclude-from-backup label, and various other | ||
// filters that happen as items are processed. | ||
// +optional | ||
TotalItems int `json:"totalItems,omitempty"` | ||
|
||
// ItemsBackedUp is the number of items that have actually been written to the | ||
// backup tarball so far. | ||
// +optional | ||
ItemsBackedUp int `json:"itemsBackedUp,omitempty"` | ||
} | ||
|
||
// PromotePolicyStatus defines the observed state of promotePolicy | ||
type PromotePolicyStatus struct { | ||
// Phase is the current state of the Backup. | ||
// +optional | ||
Phase PromotePolicyPhase `json:"phase,omitempty"` | ||
|
||
// PrecheckErrors is a slice of all precheck errors (if | ||
// applicable). | ||
// +optional | ||
// +nullable | ||
PrecheckErrors []string `json:"precheckErrors,omitempty"` | ||
|
||
// StartTimestamp records the time a sync was started. | ||
// The server's time is used for StartTimestamps | ||
// +optional | ||
// +nullable | ||
StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"` | ||
|
||
// CompletionTimestamp records the time a sync was completed. | ||
// Completion time is recorded even on failed sync. | ||
// The server's time is used for CompletionTimestamps | ||
// +optional | ||
// +nullable | ||
CompletionTimestamp *metav1.Time `json:"completionTimestamp,omitempty"` | ||
|
||
// FailureReason is an error that caused the entire sync to fail. | ||
// +optional | ||
FailureReason string `json:"failureReason,omitempty"` | ||
|
||
// Progress contains information about the sync's execution progress. Note | ||
// that this information is best-effort only -- if fails to update it for any reason, it may be inaccurate/stale. | ||
// +optional | ||
// +nullable | ||
Progress *PromotePolicyProgress `json:"progress,omitempty"` | ||
} | ||
|
||
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// +kubebuilder:object:root=true | ||
// +kubebuilder:object:generate=true | ||
// +kubebuilder:storageversion | ||
// +kubebuilder:rbac:groups=velero.io,resources=backups,verbs=create;delete;get;list;patch;update;watch | ||
// +kubebuilder:rbac:groups=velero.io,resources=backups/status,verbs=get;update;patch | ||
|
||
// PromotePolicy is custom resource that represents the capture of sync leaf cluster | ||
type PromotePolicy struct { | ||
metav1.TypeMeta `json:",inline"` | ||
|
||
// +optional | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec PromotePolicySpec `json:"spec,omitempty"` | ||
|
||
Status PromotePolicyStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// BackupList is a list of promotePolicys. | ||
type PromotePolicyList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
|
||
// +optional | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
|
||
Items []PromotePolicy `json:"items"` | ||
} |
Oops, something went wrong.