database

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CheckDatabaseHealthError          = "Check database health error"
	CreateDatabaseCrError             = "Create database CR error"
	UpdateDatabaseCrError             = "Update database CR error"
	GenerateDatabaseCrError           = "Generate database CR error"
	GetDatabaseCrError                = "Get database CR error"
	SetOwnerReferenceError            = "Set owner reference error"
	DefaultUnstructuredConverterError = "Default unstructured converter error"
)
View Source
const (
	InClusterDatabasePort              = "5432"
	InClusterDatabasePortInt32   int32 = 5432
	InClusterDatabasePasswordKey       = "password"
)
View Source
const (
	PostgresCRDResourcePlural = "postgresqls"
	// GroupName is the group name for the operator CRDs.
	GroupName  = "acid.zalan.do"
	APIVersion = "v1"
)
View Source
const (
	CoreDatabase         = "core"
	NotaryServerDatabase = "notaryserver"
	NotarySignerDatabase = "notarysigner"
	DefaultDatabaseUser  = "harbor"
	PsqlRunningStatus    = "Running"
)
View Source
const (
	ConfigMaxConnectionsKey       = "postgresql-max-connections"
	DefaultDatabaseReplica        = 3
	DefaultDatabaseMemory         = "1Gi"
	DefaultDatabaseMaxConnections = "1024"
)
View Source
const (
	ComponentName = "cluster-postgresql"
)

Variables

View Source
var (
	SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: APIVersion}
)

Functions

func GenInClusterPasswordSecretName

func GenInClusterPasswordSecretName(user, crName string) string

func GetInitDB

func GetInitDB() map[string]string

func GetPatron

func GetPatron() api.Patroni

func GetPgHba

func GetPgHba() []string

func GetUsers

func GetUsers() map[string]api.UserFlags

func NewDatabaseController

func NewDatabaseController(options ...k8s.Option) lcm.Controller

Types

type Connect

type Connect struct {
	Host     string
	Port     string
	Password string
	Username string
	Database string
}

func (*Connect) GenDatabaseURL

func (c *Connect) GenDatabaseURL() string

GenDatabaseURL returns database connection url.

type PostgreSQLController

type PostgreSQLController struct {
	Log         logr.Logger
	DClient     *k8s.DynamicClientWrapper
	Client      client.Client
	Scheme      *runtime.Scheme
	ConfigStore *configstore.Store
}

func (*PostgreSQLController) Apply

func (p *PostgreSQLController) Apply(ctx context.Context, harborcluster *goharborv1.HarborCluster, _ ...lcm.Option) (*lcm.CRStatus, error)

func (*PostgreSQLController) Delete

func (*PostgreSQLController) Deploy

func (p *PostgreSQLController) Deploy(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*lcm.CRStatus, error)

Deploy reconcile will deploy database cluster if that does not exist. It does: - check postgres.does exist - create any new postgresqls.acid.zalan.do CRs - create postgres connection secret It does not: - perform any postgresqls downscale (left for downscale phase) - perform any postgresqls upscale (left for upscale phase) - perform any pod upgrade (left for rolling upgrade phase).

func (*PostgreSQLController) DeployComponentSecret

func (p *PostgreSQLController) DeployComponentSecret(ctx context.Context, conn *Connect, secretName string, harborcluster *goharborv1.HarborCluster) error

DeployComponentSecret deploy harbor component database secret.

func (*PostgreSQLController) GetDatabaseConn

func (p *PostgreSQLController) GetDatabaseConn(ctx context.Context, ns, secretName string) (*Connect, error)

GetDatabaseConn is getting database connection.

func (*PostgreSQLController) GetDatabaseSecret

func (p *PostgreSQLController) GetDatabaseSecret(conn *Connect, ns, secretName string) *corev1.Secret

GetDatabaseSecret returns database connection secret.

func (*PostgreSQLController) GetDatabases

func (p *PostgreSQLController) GetDatabases(harborcluster *goharborv1.HarborCluster) map[string]string

func (*PostgreSQLController) GetImage

func (p *PostgreSQLController) GetImage(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)

GetImage returns the configured image via configstore or default one.

func (*PostgreSQLController) GetInClusterDatabaseConn

func (p *PostgreSQLController) GetInClusterDatabaseConn(ctx context.Context, harborcluster *goharborv1.HarborCluster, pw string) (*Connect, error)

GetInClusterDatabaseConn returns inCluster database connection info.

func (*PostgreSQLController) GetInClusterDatabaseInfo

func (p *PostgreSQLController) GetInClusterDatabaseInfo(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*Connect, error)

GetInClusterDatabaseInfo returns inCluster database connection client.

func (*PostgreSQLController) GetInClusterDatabasePassword

func (p *PostgreSQLController) GetInClusterDatabasePassword(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)

GetInClusterDatabasePassword is get inCluster postgresql password.

func (*PostgreSQLController) GetInClusterHost

func (p *PostgreSQLController) GetInClusterHost(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)

GetInClusterHost returns the Database master pod ip or service name.

func (*PostgreSQLController) GetMasterPodsIP

func (p *PostgreSQLController) GetMasterPodsIP(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)

GetMasterPodsIP returns postgresql master node ip.

func (*PostgreSQLController) GetPosgresMaxConnections

func (p *PostgreSQLController) GetPosgresMaxConnections() string

func (*PostgreSQLController) GetPostgreParameters

func (p *PostgreSQLController) GetPostgreParameters() map[string]string

func (*PostgreSQLController) GetPostgreReplica

func (p *PostgreSQLController) GetPostgreReplica(harborcluster *goharborv1.HarborCluster) int32

GetPostgreReplica returns postgres replicas.

func (*PostgreSQLController) GetPostgreResource

func (p *PostgreSQLController) GetPostgreResource(harborcluster *goharborv1.HarborCluster) api.Resources

GetPostgreResource returns postgres resource.

func (*PostgreSQLController) GetPostgreStorageSize

func (p *PostgreSQLController) GetPostgreStorageSize(harborcluster *goharborv1.HarborCluster) string

GetPostgreStorageSize returns Postgre storage size.

func (*PostgreSQLController) GetPostgreVersion

func (p *PostgreSQLController) GetPostgreVersion(harborcluster *goharborv1.HarborCluster) (string, error)

func (*PostgreSQLController) GetPostgresCR

func (p *PostgreSQLController) GetPostgresCR(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*unstructured.Unstructured, error)

GetPostgresCR returns PostgreSqls CRs.

func (*PostgreSQLController) GetSecret

func (p *PostgreSQLController) GetSecret(ctx context.Context, ns, secretName string) (map[string][]byte, error)

GetSecret returns the database connection Secret.

func (*PostgreSQLController) GetStatefulSetPods

func (p *PostgreSQLController) GetStatefulSetPods(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*corev1.PodList, error)

GetStatefulSetPods returns the postgresql master pod.

func (*PostgreSQLController) GetStorageClass

func (p *PostgreSQLController) GetStorageClass(harborcluster *goharborv1.HarborCluster) string

GetStorageClass returns the storage class name.

func (*PostgreSQLController) Readiness

func (p *PostgreSQLController) Readiness(ctx context.Context, harborcluster *goharborv1.HarborCluster, curUnstructured *unstructured.Unstructured) (*lcm.CRStatus, error)

Readiness reconcile will check postgre sql cluster if that has available. It does: - create postgre connection pool - ping postgre server - return postgre properties if postgre has available.

func (*PostgreSQLController) SetRefSecretOwner

func (p *PostgreSQLController) SetRefSecretOwner(ctx context.Context, dbName string, harborcluster *goharborv1.HarborCluster) error

SetRefSecretOwner set owner to pg operator created secrets.

func (*PostgreSQLController) Update

func (p *PostgreSQLController) Update(ctx context.Context, harborcluster *goharborv1.HarborCluster, curUnstructured *unstructured.Unstructured) (*lcm.CRStatus, error)

Update reconcile will update PostgreSQL CR.

func (*PostgreSQLController) Upgrade

type SecretsTemplate

type SecretsTemplate string

func GetPostgresSecretsTemplate

func GetPostgresSecretsTemplate() SecretsTemplate

func (*SecretsTemplate) Format

func (f *SecretsTemplate) Format(a ...string) string

Directories

Path Synopsis
+kubebuilder:skip
+kubebuilder:skip

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL