Documentation ¶
Index ¶
- Constants
- Variables
- func GenInClusterPasswordSecretName(user, crName string) string
- func GetInitDB() map[string]string
- func GetPatron() api.Patroni
- func GetPgHba() []string
- func GetUsers() map[string]api.UserFlags
- func NewDatabaseController(options ...k8s.Option) lcm.Controller
- type Connect
- type PostgreSQLController
- func (p *PostgreSQLController) Apply(ctx context.Context, harborcluster *goharborv1.HarborCluster, _ ...lcm.Option) (*lcm.CRStatus, error)
- func (p *PostgreSQLController) Delete(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
- func (p *PostgreSQLController) Deploy(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*lcm.CRStatus, error)
- func (p *PostgreSQLController) DeployComponentSecret(ctx context.Context, conn *Connect, secretName string, ...) error
- func (p *PostgreSQLController) GetDatabaseConn(ctx context.Context, ns, secretName string) (*Connect, error)
- func (p *PostgreSQLController) GetDatabaseSecret(conn *Connect, ns, secretName string) *corev1.Secret
- func (p *PostgreSQLController) GetDatabases(harborcluster *goharborv1.HarborCluster) map[string]string
- func (p *PostgreSQLController) GetImage(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)
- func (p *PostgreSQLController) GetInClusterDatabaseConn(ctx context.Context, harborcluster *goharborv1.HarborCluster, pw string) (*Connect, error)
- func (p *PostgreSQLController) GetInClusterDatabaseInfo(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*Connect, error)
- func (p *PostgreSQLController) GetInClusterDatabasePassword(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)
- func (p *PostgreSQLController) GetInClusterHost(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)
- func (p *PostgreSQLController) GetMasterPodsIP(ctx context.Context, harborcluster *goharborv1.HarborCluster) (string, error)
- func (p *PostgreSQLController) GetPosgresMaxConnections() string
- func (p *PostgreSQLController) GetPostgreParameters() map[string]string
- func (p *PostgreSQLController) GetPostgreReplica(harborcluster *goharborv1.HarborCluster) int32
- func (p *PostgreSQLController) GetPostgreResource(harborcluster *goharborv1.HarborCluster) api.Resources
- func (p *PostgreSQLController) GetPostgreStorageSize(harborcluster *goharborv1.HarborCluster) string
- func (p *PostgreSQLController) GetPostgreVersion(harborcluster *goharborv1.HarborCluster) (string, error)
- func (p *PostgreSQLController) GetPostgresCR(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*unstructured.Unstructured, error)
- func (p *PostgreSQLController) GetSecret(ctx context.Context, ns, secretName string) (map[string][]byte, error)
- func (p *PostgreSQLController) GetStatefulSetPods(ctx context.Context, harborcluster *goharborv1.HarborCluster) (*corev1.PodList, error)
- func (p *PostgreSQLController) GetStorageClass(harborcluster *goharborv1.HarborCluster) string
- func (p *PostgreSQLController) Readiness(ctx context.Context, harborcluster *goharborv1.HarborCluster, ...) (*lcm.CRStatus, error)
- func (p *PostgreSQLController) SetRefSecretOwner(ctx context.Context, dbName string, harborcluster *goharborv1.HarborCluster) error
- func (p *PostgreSQLController) Update(ctx context.Context, harborcluster *goharborv1.HarborCluster, ...) (*lcm.CRStatus, error)
- func (p *PostgreSQLController) Upgrade(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
- type SecretsTemplate
Constants ¶
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" )
const ( InClusterDatabasePort = "5432" InClusterDatabasePortInt32 int32 = 5432 InClusterDatabasePasswordKey = "password" )
const ( PostgresCRDResourcePlural = "postgresqls" // GroupName is the group name for the operator CRDs. GroupName = "acid.zalan.do" APIVersion = "v1" )
const ( CoreDatabase = "core" NotaryServerDatabase = "notaryserver" NotarySignerDatabase = "notarysigner" DefaultDatabaseUser = "harbor" PsqlRunningStatus = "Running" )
const ( ConfigMaxConnectionsKey = "postgresql-max-connections" DefaultDatabaseReplica = 3 DefaultDatabaseMemory = "1Gi" DefaultDatabaseMaxConnections = "1024" )
const (
ComponentName = "cluster-postgresql"
)
Variables ¶
var (
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: APIVersion}
)
Functions ¶
func NewDatabaseController ¶
func NewDatabaseController(options ...k8s.Option) lcm.Controller
Types ¶
type Connect ¶
func (*Connect) GenDatabaseURL ¶
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 (p *PostgreSQLController) Delete(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
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 ¶
func (p *PostgreSQLController) Upgrade(_ context.Context, _ *goharborv1.HarborCluster) (*lcm.CRStatus, error)
type SecretsTemplate ¶
type SecretsTemplate string
func GetPostgresSecretsTemplate ¶
func GetPostgresSecretsTemplate() SecretsTemplate
func (*SecretsTemplate) Format ¶
func (f *SecretsTemplate) Format(a ...string) string