Backup API 總覽

Kubernetes 的設計宗旨是可擴充性。您可以將備份和 GKE 備份代理程式 API 等新 API 新增至 Kubernetes 叢集。這些 API 遵循統一的 API 模型,也就是 Kubernetes 資源模型 (KRM)。

這些 API 使用 Kubernetes 自訂資源,並依賴 KRM。這些 API 用於管理備份的生命週期,以及建立備份存放區、政策和方案。

Service 端點

以下是 Backup KRM API 的 API 端點網址:

https://MANAGEMENT_API_SERVER_ENDPOINT/apis/backup.gdc.goog/v1

以下網址是 GKE Backup Agent API 的 API 端點:

https://MANAGEMENT_API_SERVER_ENDPOINT/apis/gkebackup.gke.io/v1

MANAGEMENT_API_SERVER_ENDPOINT 替換成 Management API 伺服器的端點。

探索文件

使用 kubectl proxy --port=8001 指令在本機開啟 API 伺服器的 Proxy。接著,您就可以透過下列任一網址存取探索文件:

  • http://127.0.0.1:8001/apis/backup.gdc.goog/v1
  • http://127.0.0.1:8001/apis/gkebackup.gke.io/v1

範例 ClusterBackupPlan 資源

以下是 ClusterBackupPlan 資源的範例:

apiVersion: backup.gdc.goog/v1
kind: ClusterBackupPlan
metadata:
  name: backup-plan
  namespace: project-namespace
spec:
  targetCluster:
    targetClusterType: UserCluster
    targetClusterName:
      kind: "Cluster"
      name: "cluster-sample"
  backupSchedule:
    cronSchedule: "*/30 * * * *"
    paused: false
  clusterBackupConfig:
    backupScope:
      selectedNamespaces:
        namespaces: ["nginx"]
    clusterBackupRepositoryName: backup-repository
  retentionPolicy:
    backupDeleteLockDays: 10
    backupRetainDays: 10

範例 ProtectedApplication 資源

以下是 ProtectedApplication 資源的範例:

apiVersion: gkebackup.gke.io/v1
kind: ProtectedApplication
metadata:
  name: protected-application-test
  namespace: applications
spec:
  applicationName: protectedApplication
  resourceSelection:
    type: Selector
    selector:
      matchLabels:
        app: protected
  components:
    - name: protect-application-deployment
      resourceKind: Deployment
      resourceNames:
        - protected-application-deployment
      strategy:
        type: BackupAllRestoreAll

範例 ClusterBackupRepository 資源

以下是 ClusterBackupRepository 資源的範例:

apiVersion: backup.gdc.goog/v1
kind: ClusterBackupRepository
metadata:
  name: user-1-user
  namespace: user-1-user-cluster
spec:
    secretReference:
        namespace: "object-storage-secret-ns"
        name: "object-storage-secret"
    endpoint: "https://objectstorage.google.gdch.test"
    type: "S3"
    s3Options:
      bucket: "fully-qualified-bucket-name"
      region: "us-east-1"
      forcePathStyle: true
    importPolicy: "ReadWrite"