AtlasBackupPolicy自定义资源配置适用于AtlasBackupSchedule自定义资源的备份策略,您可以将其应用于AtlasDeployment自定义资源。 当您创建AtlasBackupPolicy自定义资源时,Atlas Kubernetes Operator 会尝试创建或更新备份策略。
重要
自定义资源不再默认删除对象
Atlas Kubernetes Operator使用自定义资源配置文件来管理Atlas配置,但从Atlas Kubernetes Operator2.0 开始,您在Kubernetes中删除的自定义资源不再(默认)在Atlas中删除。相反, Atlas Kubernetes Operator只是停止管理Atlas中的这些资源。
AtlasProject示例,如果您在Kubernetes中删除 自定义资源,默认默认, Atlas Kubernetes Operator不再自动从Atlas中删除相应的项目。这种行为更改旨在帮助防止意外删除。 要学习;了解详情,包括如何将此行为恢复为在Atlas Kubernetes Operator.2 0之前使用的默认,请参阅新默认值: Atlas Kubernetes2 Operator.0 中的删除保护。同样,如果您使用Atlas Kubernetes Operator从Kubernetes中的Atlas项目中删除团队,则Atlas Kubernetes Operator不会从Atlas中删除团队。
显式定义所需的配置详细信息,以避免隐式使用默认Atlas配置值。 在某些情况下,继承Atlas默认值可能会导致协调循环,从而阻止自定义资源实现
READY状态。 示例,在AtlasDeployment自定义资源中显式定义所需的自动伸缩行为(如所包含的示例所示)可确保自定义资源中的静态实例大小不会重复应用于已启用自动伸缩的Atlas部署。autoScaling: diskGB: enabled: true compute: enabled: true scaleDownEnabled: true minInstanceSize: M30 maxInstanceSize: M40
Atlas Kubernetes Operator使用Atlas Cloud Backup Schedule API资源执行以下操作之一:
创建新的备份策略。
更新现有备份策略。
如果您从 Kubernetes 集群中删除AtlasBackupPolicy资源,Atlas 将停止为集群创建备份。
注意
您必须执行以下所有任务才能备份集群:
创建备份策略。
创建备份安排并将
spec.policy.name字段设置为已配置备份策略的名称。将
spec.backupRef.nameAtlasDeployment自定义资源 中的 字段设置为已配置备份计划的名称。
要了解更多信息,请参阅备份 Atlas 集群。
例子
以下示例显示了一个AtlasBackupPolicy自定义资源,该资源配置为每周拍摄一次快照并将快照保留 7 天:
apiVersion: atlas.mongodb.com/v1 kind: AtlasBackupPolicy metadata: name: "atlas-default-backuppolicy" spec: items: - frequencyType: "weekly" frequencyInterval: 1 retentionUnit: "days" retentionValue: 7
参数
本部分介绍一些可用的关键AtlasBackupPolicy自定义资源参数。 有关可用参数的完整列表,请参阅Atlas修改云备份 备份策略API 。 请参阅这些描述、可用示例和API文档,自定义您的规范。
spec.items类型:数组
可选的
包含来自API的策略项参数的列表。 有关可用参数的完整列表,请参阅 Atlas修改云备份备份策略 API。
spec.items.frequencyInterval类型:数字
必需
Number that indicates the desired frequency of the new backup policy item specified by
spec.items.frequencyType. A value of1specifies the first instance of the correspondingspec.items.frequencyType.例子
在月度策略项中,
1表示月度快照发生在该月的第一天。在每周策略项中,
1表示每周快照发生在星期一。
此设置接受以下频率值:
每小时:
1、2、4、6、8和12。每日:
1。每周:
1到7,其中1为星期一,7为星期日。每月:
1到28和40,其中1是该月的第一天,40是该月的最后一天。每年:
1到12,其中1是一月的第一天,12是十二月的第一天。
spec.items.frequencyType类型:字符串
必需
string ,表示与备份策略项关联的频率。 接受的值为:
hourly、daily、weekly、monthly或yearly。注意
您不能指定多个
hourly和daily备份策略项。
spec.items.retentionUnit类型:字符串
必需
String that indicates the scope of the backup policy item. Together with
spec.items.retentionValue, these settings define the length of time to retain snapshots. Accepted values are:days,weeks,months, oryears.
spec.items.retentionValue类型:字符串
必需
String that indicates the value to associate with
spec.items.retentionUnit. Together withspec.items.retentionUnit, these settings define the length of time to retain snapshots.