GoogleCloudAPIStorage#

class phalanx.storage.google_cloud_api.GoogleCloudAPIStorage(region, project, labels=None)#

Bases: object

Run commands against the Google Cloud API in a region and project.

Anything that uses this should assume all authentication has already been done and that the Google Cloud Python SDK can find whatever it needs to send authenticated requests.

If you’re running locally, gcloud auth application-default login should work.

Parameters:
  • region (str) – The Google Cloud region to run comands against.

  • project (str) – The Google Cloud project to run comands against.

  • labels (Optional[dict[str, str]], default: None) – Labels to set on provisioned Google Cloud resources.

Methods Summary

create_backup(backup_plan)

Create a GKE backup from the given backup plan.

create_backup_plan(source_cluster)

Create a backup plan to backup everything in source_cluster.

create_pvc_restore(restore_plan, backup)

Create a PVC-only restore for a GKE cluster.

create_restore_plan(backup_plan, ...)

Create a restore plan.

delete_backup(backup)

Delete a backup, including all associated volume resources.

delete_backup_plan(backup_plan)

Delete a backup plan.

delete_restore(restore)

Delete a restore and all of its associated VolumeRestores.

delete_restore_plan(restore_plan)

Delete a restore plan.

get_cluster(cluster)

Get details about a GKE cluster.

get_firewall_rule(name)

Get information about a Google Cloud firewall rule.

list_backup_plans(filter_exp)

Get backup plans with a specific label value.

list_backups(backup_plan, filter_exp)

Get backups with from a backup plan, filtered by filter_exp.

list_restore_plans(filter_exp)

Get restore plans with a specific label value.

list_restores(restore_plan, filter_exp)

Get restores from a specific restore plan, filtered with filter_exp.

list_static_ip_addresses()

List all of the provisioned static IP addresses.

wait_for_backup(backup_name[, interval, ...])

Wait for a GKE backup to complete.

wait_for_restore(restore_name[, interval, ...])

Wait for a GKE restore to complete.

Methods Documentation

create_backup(backup_plan)#

Create a GKE backup from the given backup plan.

Parameters:

backup_plan (str) – The fully qualified backup plan name, like projects/roundtable-dev-abe2/locations/us-central1/backupPlans/phalanx-20260123-220839-fd0769e1-2b72-4464-8398-2cfcea696b13

Return type:

str

create_backup_plan(source_cluster)#

Create a backup plan to backup everything in source_cluster.

Volume data for PVs attached to PVCs is backed up.

Parameters:

source_cluster (str) – The GKE cluster to take a backup up of when creating backups from this plan.

Return type:

str

create_pvc_restore(restore_plan, backup)#

Create a PVC-only restore for a GKE cluster.

This will restore PVCs, the data from their backing PVs, and StorageClasses.

Parameters:
  • restore_plan (str) – The fully-qualified name of the restore plan to use when creating the restore.

  • backup (str) – The fully-qualified name of the backup to restore from.

Return type:

str

create_restore_plan(backup_plan, destination_cluster)#

Create a restore plan.

Volume data for PVs attached to PVCs is backed up.

Parameters:
  • backup_plan (str) – The name of the backup plan to restore a backup from.

  • destination_cluster (str) – The GKE cluster to take restore the backup to.

Return type:

str

delete_backup(backup)#

Delete a backup, including all associated volume resources.

Parameters:

backup (str) – The fully-qualified name of the backup.

Return type:

None

delete_backup_plan(backup_plan)#

Delete a backup plan.

If the backup plan still has associated backups, then it will only be deactivated.

Parameters:

backup_plan (str) – The fully-qualified name of the backup plan that took the backups.

Return type:

None

delete_restore(restore)#

Delete a restore and all of its associated VolumeRestores.

Parameters:

restore (str) – The fully-qualified name of the restore.

Return type:

None

delete_restore_plan(restore_plan)#

Delete a restore plan.

If the restore plan still has associated restores, then it will only be deactivated.

Parameters:

restore_plan (str) – The fully-qualified name of the restore plan.

Return type:

None

get_cluster(cluster)#

Get details about a GKE cluster.

Parameters:

cluster (str)

Return type:

Cluster

get_firewall_rule(name)#

Get information about a Google Cloud firewall rule.

Parameters:

name (str)

Return type:

Firewall

list_backup_plans(filter_exp)#

Get backup plans with a specific label value.

Parameters:

filter_exp (str) –

A filter expression to list only specific resources. More information in the docs:

https://docs.cloud.google.com/sdk/gcloud/reference/topic/filters

Return type:

list[BackupPlan]

list_backups(backup_plan, filter_exp)#

Get backups with from a backup plan, filtered by filter_exp.

Parameters:
Return type:

list[Backup]

list_restore_plans(filter_exp)#

Get restore plans with a specific label value.

Parameters:

filter_exp (str) –

A filter expression to list only specific resources. More information in the docs:

https://docs.cloud.google.com/sdk/gcloud/reference/topic/filters

Return type:

list[RestorePlan]

list_restores(restore_plan, filter_exp)#

Get restores from a specific restore plan, filtered with filter_exp.

Parameters:
Return type:

list[Restore]

list_static_ip_addresses()#

List all of the provisioned static IP addresses.

Return type:

list[Address]

wait_for_backup(backup_name, interval=datetime.timedelta(seconds=5), attempts=720)#

Wait for a GKE backup to complete.

Parameters:
  • backup_name (str) – The fully-qualified name of the backup to wait for, like projects/roundtable-dev-abe2/locations/us-central1/backupPlans/phalanx-20260126-175433/backups/phalanx-20260126-175435

  • interval (timedelta, default: datetime.timedelta(seconds=5))

  • attempts (int, default: 720)

Raises:
Return type:

None

wait_for_restore(restore_name, interval=datetime.timedelta(seconds=5), attempts=720)#

Wait for a GKE restore to complete.

Parameters:
  • restore_name (str) – The fully-qualified name of the restore to wait for, like projects/roundtable-dev-abe2/locations/us-central1/restorePlans/phalanx-20260126-175433/restores/phalanx-20260126-175435

  • interval (timedelta, default: datetime.timedelta(seconds=5))

  • attempts (int, default: 720)

Raises:
Return type:

None