Documentation ¶
Index ¶
- func CreatePVCManifestFromVolumeSnapshot(namespace, vsName, pvcName, storageClass string) (map[string]interface{}, error)
- func CreatePreProvisionedVSC(vscObject map[string]interface{}, postfix string) (map[string]interface{}, error)
- func CreateVolumeSnapshot(namespace string, dryRun bool, vsName string, vsObject map[string]interface{}, ...) error
- func DeleteVolumeSnapshotContent(volumeSnapshotContentName string) error
- func DumpMySQL(namespace string, dryRun bool, config MySQLConfig) error
- func DumpPostgres(namespace string, dryRun bool, config PostgresConfig) error
- func EnsureFreeSpace(namespace, resource, container, dir string, thresholdSpaceUsedPercent int) error
- func EnsureMySQLAvailable(namespace string, config MySQLConfig) error
- func EnsurePVCAvailable(namespace, pvcName string) error
- func EnsurePostgresAvailable(namespace string, config PostgresConfig) error
- func EnsureResourceAvailable(namespace, resource string) error
- func FlockLock(lockFile string, timeout time.Duration, dryRun bool) (func() error, error)
- func FlockShuffleLockFile(dir string, count int) string
- func GenerateRandomStringOrPanic(n int) string
- func GenerateVSAnnotations(bakEnvVars map[string]string) map[string]string
- func GenerateVSLabels(namespace, pvcName string, config LabelVSConfig, now time.Time) map[string]string
- func GenerateVSName(vsNameTemplate string, pvcName string, vsRand string) (string, error)
- func GenerateVSObject(namespace, vsClassName, pvcName, vsName string, ...) map[string]interface{}
- func GenerateVSObjectFromVSC(vscName string, vscObject map[string]interface{}) (map[string]interface{}, error)
- func GetBAKEnvVars() map[string]string
- func GetBackupNsLabelMap(namespace, kind, name string) (map[string]string, error)
- func GetCurrentNamespace() (string, error)
- func GetPodFromResource(namespace, resource string) (string, error)
- func GetRemoteFileTimestamp(namespace, execResource, execContainer, absolutePathToFile string) (time.Time, error)
- func GetSelectorFromResource(namespace, resource string) (string, error)
- func GetVolumeSnapshotContentName(namespace, volumeSnapshotName string) (string, error)
- func GetVolumeSnapshotContentObject(vscName string) (map[string]interface{}, error)
- func KubectlExecCommand(namespace, execResource, execContainer, command string) error
- func KubectlExecTemplate(namespace, execResource, execContainer string, tmpl *template.Template, ...) error
- func PrintConfig(config Config)
- func PrintTimeZone()
- func PruneVolumeSnapshot(namespace, volumeSnapshotName string, wait bool) error
- func RebindVsc(oldVSCName, vsRand string, wait bool, waitTimeout string) error
- func RestoreMySQL(namespace string, dryRun bool, config MySQLConfig) error
- func RestorePostgres(namespace string, dryRun bool, config PostgresConfig) error
- func RestoreVolumeSnapshot(namespace string, vsName string, pvcName string, storageClass string, ...) error
- func SyncVSLabelsToVsc(namespace, vsName string) error
- type Config
- type FlockConfig
- type LabelVSConfig
- type MySQLConfig
- type NamespacedK8sObject
- type PostgresConfig
- type TemplateAtlas
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePVCManifestFromVolumeSnapshot ¶ added in v0.2.0
func CreatePVCManifestFromVolumeSnapshot(namespace, vsName, pvcName, storageClass string) (map[string]interface{}, error)
CreatePVCManifestFromVolumeSnapshot creates a PVC manifest from a VolumeSnapshot
func CreatePreProvisionedVSC ¶
func CreateVolumeSnapshot ¶
func DeleteVolumeSnapshotContent ¶ added in v0.1.1
func DumpMySQL ¶ added in v0.2.0
func DumpMySQL(namespace string, dryRun bool, config MySQLConfig) error
func DumpPostgres ¶ added in v0.2.0
func DumpPostgres(namespace string, dryRun bool, config PostgresConfig) error
func EnsureFreeSpace ¶
func EnsureMySQLAvailable ¶
func EnsureMySQLAvailable(namespace string, config MySQLConfig) error
func EnsurePVCAvailable ¶
func EnsurePostgresAvailable ¶
func EnsurePostgresAvailable(namespace string, config PostgresConfig) error
func EnsureResourceAvailable ¶
func FlockShuffleLockFile ¶
func GenerateVSAnnotations ¶
typically we'll only save the used safe env vars inside the env-config annotation
func GenerateVSLabels ¶
func GenerateVSName ¶
func GenerateVSObject ¶
func GenerateVSObjectFromVSC ¶
func GetBAKEnvVars ¶
GetBAKEnvVars returns all environment variables starting with "BAK_", excluding secrets
func GetBackupNsLabelMap ¶
func GetCurrentNamespace ¶
func GetPodFromResource ¶ added in v0.2.0
func GetRemoteFileTimestamp ¶ added in v0.2.0
func GetSelectorFromResource ¶ added in v0.2.0
Returns a --selector compatible string (e.g. app=postgres) from a resource in the format kind/name
func KubectlExecCommand ¶ added in v0.2.0
func KubectlExecTemplate ¶ added in v0.2.0
func PrintConfig ¶
func PrintConfig(config Config)
func PruneVolumeSnapshot ¶
Dangerous! Delete a VolumeSnapshot, its associated VolumeSnapshotContent and the underlying storage! This is a destructive operation and should be used with caution! This function will set the deletionPolicy of the VolumeSnapshotContent to "Delete" before deleting the VolumeSnapshot, thus ensuring the underlying storage is also deleted.
func RestoreMySQL ¶ added in v0.2.0
func RestoreMySQL(namespace string, dryRun bool, config MySQLConfig) error
func RestorePostgres ¶ added in v0.2.0
func RestorePostgres(namespace string, dryRun bool, config PostgresConfig) error
func RestoreVolumeSnapshot ¶ added in v0.2.0
func RestoreVolumeSnapshot(namespace string, vsName string, pvcName string, storageClass string, wait bool, waitTimeout string) error
RestoreVolumeSnapshot creates a new PVC from a VolumeSnapshot (applies the PVC manifest)
func SyncVSLabelsToVsc ¶
Types ¶
type Config ¶
type Config struct { DryRun bool `json:"BAK_DRY_RUN"` Namespace string `json:"BAK_NAMESPACE"` PVCName string `json:"BAK_PVC_NAME"` VSRand string `json:"BAK_VS_RAND"` LabelVS LabelVSConfig VSNameTemplate string `json:"BAK_VS_NAME_TEMPLATE"` VSClassName string `json:"BAK_VS_CLASS_NAME"` VSWaitUntilReady bool `json:"BAK_VS_WAIT_UNTIL_READY"` VSWaitUntilReadyTimeout string `json:"BAK_VS_WAIT_UNTIL_READY_TIMEOUT"` ThresholdSpaceUsedPercent int `json:"BAK_THRESHOLD_SPACE_USED_PERCENTAGE"` DBSkip bool `json:"BAK_DB_SKIP"` Postgres PostgresConfig MySQL MySQLConfig Flock FlockConfig }
Config holds all the configuration options
func LoadConfig ¶
func LoadConfig() Config
type FlockConfig ¶
type LabelVSConfig ¶
type MySQLConfig ¶
type MySQLConfig struct { Enabled bool `json:"BAK_DB_MYSQL"` ExecResource string `json:"BAK_DB_MYSQL_EXEC_RESOURCE"` ExecContainer string `json:"BAK_DB_MYSQL_EXEC_CONTAINER"` DumpFile string `json:"BAK_DB_MYSQL_DUMP_FILE"` Host string `json:"BAK_DB_MYSQL_HOST"` Port string `json:"BAK_DB_MYSQL_PORT"` User string `json:"BAK_DB_MYSQL_USER"` Password string `json:"-"` // sensitive DB string `json:"BAK_DB_MYSQL_DB"` DefaultCharacterSet string `json:"BAK_DB_MYSQL_DEFAULT_CHARACTER_SET"` }
type NamespacedK8sObject ¶
func GetManagedVolumeSnapshots ¶
func GetManagedVolumeSnapshots() ([]NamespacedK8sObject, error)
We expect all VS that we manage to have to "backup-ns.sh/type" label key.
type PostgresConfig ¶
type PostgresConfig struct { Enabled bool `json:"BAK_DB_POSTGRES"` ExecResource string `json:"BAK_DB_POSTGRES_EXEC_RESOURCE"` ExecContainer string `json:"BAK_DB_POSTGRES_EXEC_CONTAINER"` DumpFile string `json:"BAK_DB_POSTGRES_DUMP_FILE"` Host string `json:"BAK_DB_POSTGRES_HOST"` Port string `json:"BAK_DB_POSTGRES_PORT"` User string `json:"BAK_DB_POSTGRES_USER"` Password string `json:"-"` // sensitive DB string `json:"BAK_DB_POSTGRES_DB"` }
type TemplateAtlas ¶ added in v0.2.0
type TemplateAtlas struct { MySQLCheck *template.Template MySQLDump *template.Template MySQLRestore *template.Template PostgresCheck *template.Template PostgresDump *template.Template PostgresRestore *template.Template TestTrap *template.Template }
func GetTemplateAtlas ¶ added in v0.2.0
func GetTemplateAtlas() TemplateAtlas