Documentation
¶
Index ¶
- Constants
- Variables
- func BackupToYAML(backup Backup) string
- func RestoreToYAML(restore Restore) string
- func ServiceBindingToYAML(binding ServiceBinding) string
- func ServiceInstanceToYAML(instance ServiceInstance) string
- type Backup
- type PgManager
- func (pgm *PgManager) ApplySQLFileToPGServiceInstance(unattendedMode bool, namespace, serviceInstanceName, sqlFileToUpload string, ...)
- func (pgm *PgManager) ApplySQLStatementToPGServiceInstance(unattendedMode bool, namespace, serviceInstanceName, sqlStatement string)
- func (pgm *PgManager) DoesBackupExist(namespace, backupName string) bool
- func (pgm *PgManager) DoesServiceInstanceExist(namespace, name string) bool
- func (pgm *PgManager) ExecuteSQLFileWithinPod(unattendedMode bool, namespace, serviceInstanceName, remoteSQLFilePath string) error
- func (pgm *PgManager) ExecuteSQLStatementWithinPod(unattendedMode bool, namespace, serviceInstanceName, sqlStatement string) (*exec.Cmd, []byte, error)
- func (pgm *PgManager) FindPrimaryPodOfServiceInstance(namespace, serviceInstanceName string) string
- func (pgm *PgManager) WaitForPGBackupResourceToBecomeReady(namespace, name string, resource string) error
- func (pgm *PgManager) WaitForPGBackupToBecomeReady(namespace, name string)
- func (pgm *PgManager) WaitForPGRestoreToBecomeReady(namespace, name string)
- func (pgm *PgManager) WaitForPGServiceBindingToBecomeReady(binding ServiceBinding) error
- type Restore
- type ServiceBinding
- type ServiceInstance
Constants ¶
const A8sPGBackupAPIGroup = "backups.anynines.com"
Backup
const A8sPGBackupKind = "Backup"
const A8sPGBackupKindPlural = "backups"
const A8sPGLabelPrimary = "a8s.a9s/replication-role=master"
const A8sPGRestoreKind = "Restore"
Restore
const A8sPGServiceBindingAPIGroup = "servicebindings.anynines.com"
const A8sPGServiceBindingKind = "ServiceBinding"
Service Binding
const A8sPGServiceInstanceAPIGroup = "postgresql.anynines.com"
Instance
const A8sPGServiceInstanceAPIGroupLabel = "a8s.a9s/dsi-group=" + A8sPGServiceInstanceAPIGroup
const A8sPGServiceInstanceKind = "Postgresql"
const A8sPGServiceInstanceKindLabel = "a8s.a9s/dsi-kind=" + A8sPGServiceInstanceKind
const A8sPGServiceInstanceKindPlural = "postgresqls"
const A8sPGServiceInstanceNameLabelKey = "a8s.a9s/dsi-name"
const DefaultPGAPIVersion = "v1beta3"
const RemoteUploadContainerName = "postgres"
Name of the container within the target pod to upload the file to.
const RemoteUploadDir = "/tmp"
Variables ¶
var SQLFilename = ""
Filename when used with option --file or -f
Functions ¶
func BackupToYAML ¶
Creates a backup YAML manifest for the given service instance name.
Returns a string.
func RestoreToYAML ¶
Creates a restore YAML manifest to restore a backup.
func ServiceBindingToYAML ¶
func ServiceBindingToYAML(binding ServiceBinding) string
func ServiceInstanceToYAML ¶
func ServiceInstanceToYAML(instance ServiceInstance) string
Types ¶
type PgManager ¶ added in v0.14.0
type PgManager struct {
K8s *k8s.KubeClient
}
func NewPgManager ¶ added in v0.14.0
NewPgManager returns a PgManager for the given kube context. If the context is empty, it is ignored.
func (*PgManager) ApplySQLFileToPGServiceInstance ¶ added in v0.14.0
func (pgm *PgManager) ApplySQLFileToPGServiceInstance(unattendedMode bool, namespace, serviceInstanceName, sqlFileToUpload string, noDelete bool)
Upload and execute psql for the given file on the primary of the given service instance.
If noDelete is set to true, the uploaded file won't be deleted after a successful apply. Not that, if errors occur, the process will be stopped and hence, an uploaded file will remain in the pod and not be deleted, in case its execution failed.
Example kubectl command: kubectl exec -n default clustered-0 -c postgres -- psql -U postgres -d a9s_apps_default_db -f demo_data.sql
func (*PgManager) ApplySQLStatementToPGServiceInstance ¶ added in v0.14.0
func (pgm *PgManager) ApplySQLStatementToPGServiceInstance(unattendedMode bool, namespace, serviceInstanceName, sqlStatement string)
TODO Reduce code duplication with ApplySQLFileToPGServiceInstance
func (*PgManager) DoesBackupExist ¶ added in v0.14.0
func (*PgManager) DoesServiceInstanceExist ¶ added in v0.14.0
func (*PgManager) ExecuteSQLFileWithinPod ¶ added in v0.14.0
func (pgm *PgManager) ExecuteSQLFileWithinPod(unattendedMode bool, namespace, serviceInstanceName, remoteSQLFilePath string) error
Executes a SQL file within a Pod using PSQL. Both the sql file and the psql command must be present in the target pod.
Example: kubectl exec -n default clustered-0 -c postgres -- psql -U postgres -d a9s_apps_default_db -f demo_data.sql
func (*PgManager) ExecuteSQLStatementWithinPod ¶ added in v0.14.0
func (pgm *PgManager) ExecuteSQLStatementWithinPod(unattendedMode bool, namespace, serviceInstanceName, sqlStatement string) (*exec.Cmd, []byte, error)
TODO Remove code duplication with ExecuteSQLFileWithinPod
func (*PgManager) FindPrimaryPodOfServiceInstance ¶ added in v0.14.0
Identifies the current primary of the given PG service instance.
Executes: kubectl get pods -n default -l 'a8s.a9s/replication-role=master,a8s.a9s/dsi-group=postgresql.anynines.com,a8s.a9s/dsi-kind=Postgresql,a8s.a9s/dsi-name=clustered' -o=jsonpath='{.items[*].metadata.name}'
func (*PgManager) WaitForPGBackupResourceToBecomeReady ¶ added in v0.14.0
func (pgm *PgManager) WaitForPGBackupResourceToBecomeReady(namespace, name string, resource string) error
Similar to kubectl watch ... Needed: Namespace and name of the resource to be observed.
func (*PgManager) WaitForPGBackupToBecomeReady ¶ added in v0.14.0
func (*PgManager) WaitForPGRestoreToBecomeReady ¶ added in v0.14.0
func (*PgManager) WaitForPGServiceBindingToBecomeReady ¶ added in v0.14.0
func (pgm *PgManager) WaitForPGServiceBindingToBecomeReady(binding ServiceBinding) error