v1

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package v1 contains API Schema definitions for the database v1 API group +kubebuilder:object:generate=true +groupName=database.fits.cloud

Index

Constants

View Source
const (
	// UIDLabelName Name of the label referencing the owning Postgres resource uid in the control cluster
	UIDLabelName string = "postgres.database.fits.cloud/uid"
	// NameLabelName Name of the label referencing the owning Postgres resource name in the control cluster (which might not be unique)
	NameLabelName string = "postgres.database.fits.cloud/name"
	// TenantLabelName Name of the tenant label
	TenantLabelName string = "postgres.database.fits.cloud/tenant"
	// ProjectIDLabelName Name of the ProjectID label
	ProjectIDLabelName string = "postgres.database.fits.cloud/project-id"
	// ManagedByLabelName Name of the managed-by label
	ManagedByLabelName string = "postgres.database.fits.cloud/managed-by"
	// ManagedByLabelValue Value of the managed-by label
	ManagedByLabelValue string = "postgreslet"
	// PostgresFinalizerName Name of the finalizer to use
	PostgresFinalizerName string = "postgres.finalizers.database.fits.cloud"
	// CreatedByAnnotationKey is used to store who in person created this database
	CreatedByAnnotationKey string = "postgres.database.fits.cloud/created-by"
	// BackupConfigLabelName if set to true, this secret stores the backupConfig
	BackupConfigLabelName string = "postgres.database.fits.cloud/is-backup"
	// BackupConfigKey defines the key under which the BackupConfig is stored in the data map.
	BackupConfigKey = "config"
	// SharedBufferParameterKey defines the key under which the shared buffer size is stored in the parameters map. Defined by the postgres-operator/patroni
	SharedBufferParameterKey = "shared_buffers"
	// StandbyKey defines the key under which the standby configuration is stored in the CR.  Defined by the postgres-operator/patroni
	StandbyKey    = "standby"
	StandbyMethod = "streaming_host"
	// PartitionIDLabelName Name of the managed-by label
	PartitionIDLabelName string = "postgres.database.fits.cloud/partition-id"

	ApplicationLabelName             = "application"
	ApplicationLabelValue            = "spilo"
	SpiloRoleLabelName               = "spilo-role"
	SpiloRoleLabelValueMaster        = "master"
	SpiloRoleLabelValueStandbyLeader = "standby_leader"
	StatefulsetPodNameLabelName      = "statefulset.kubernetes.io/pod-name"

	DefaultPatroniParamValueLoopWait     uint32 = 10
	DefaultPatroniParamValueRetryTimeout uint32 = 60

	// PostgresAutoAssignedIPNamePrefix a prefix to add to the generated random name
	PostgresAutoAssignedIPNamePrefix = "pgaas-autoassign-"
	// PostgresAutoAssignedIPLabelKey tag to identify ips auto-assigned for a postgres
	PostgresAutoAssignedIPLabelKey = "postgres.database.fits.cloud/auto-assigned-ip"
	// PostgresAutoAssignedIPLabel tag to identify ips auto-assigned for a postgres
	PostgresAutoAssignedIPLabel = PostgresAutoAssignedIPLabelKey + "=true"

	PostresConfigSuperUsername        = "postgres"
	PostgresConfigReplicationUsername = "standby"
	PostgresConfigAuditorUsername     = "auditor"
	PostgresConfigMonitoringUsername  = "monitoring"
)

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	GroupVersion = schema.GroupVersion{Group: "database.fits.cloud", Version: "v1"}

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

	// AddToScheme adds the types in this group-version to the given scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)
View Source
var SvcLoadBalancerLabel = map[string]string{
	ManagedByLabelName: ManagedByLabelValue,
}
View Source
var (
	ZalandoPostgresqlTypeMeta = metav1.TypeMeta{
		APIVersion: "acid.zalan.do/v1",
		Kind:       "postgresql",
	}
)

Functions

This section is empty.

Types

type AccessList

type AccessList struct {
	// SourceRanges defines a list of prefixes in CIDR Notation e.g. 1.2.3.0/24 or fdaa::/104
	SourceRanges []string `json:"sourceRanges,omitempty"`
}

AccessList defines the type of restrictions to access the database

func (*AccessList) DeepCopy

func (in *AccessList) DeepCopy() *AccessList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AccessList.

func (*AccessList) DeepCopyInto

func (in *AccessList) DeepCopyInto(out *AccessList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type BackupConfig

type BackupConfig struct {
	// ID of this backupConfig
	ID string `json:"id"`
	// Name is a user defined description
	Name string `json:"name"`
	// ProjectID the project this backup is mapped to
	ProjectID string `json:"project"`
	// Tenant the tenant of the backup
	Tenant string `json:"tenant"`
	// CreatedBy is the name of the person or technical account which created this backupConfig
	CreatedBy string `json:"createdBy"`
	// Retention defines how many versions should be held in s3
	Retention string `json:"retention"`
	// Schedule in cron syntax when to run the backup periodically
	Schedule string `json:"schedule"`

	// S3Endpoint the url of the s3 endpoint
	S3Endpoint string `json:"s3endpoint"`
	// S3BucketName is the name of the bucket where the backup should be stored.
	S3BucketName string `json:"s3bucketname"`
	// S3Region the region of the aws s3
	S3Region string `json:"s3region"`
	// S3AccessKey is the accesskey which must have write access
	S3AccessKey string `json:"s3accesskey"`
	// S3SecretKey is the secretkey which must match to the accesskey
	S3SecretKey string `json:"s3secretkey"`
	// S3EncryptionKey if set, server side s3 encryption is used.
	S3EncryptionKey *string `json:"s3encryptionkey,omitempty"`
}

BackupConfig defines all properties to configure backup of a database. This config is stored in the data section under the key BackupConfigKey as json payload.

func (*BackupConfig) DeepCopy

func (in *BackupConfig) DeepCopy() *BackupConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackupConfig.

func (*BackupConfig) DeepCopyInto

func (in *BackupConfig) DeepCopyInto(out *BackupConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Postgres

type Postgres struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   PostgresSpec   `json:"spec,omitempty"`
	Status PostgresStatus `json:"status,omitempty"`
}

Postgres is the Schema for the postgres API

func (*Postgres) AddFinalizer

func (p *Postgres) AddFinalizer(finalizerName string)

func (*Postgres) DeepCopy

func (in *Postgres) DeepCopy() *Postgres

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Postgres.

func (*Postgres) DeepCopyInto

func (in *Postgres) DeepCopyInto(out *Postgres)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Postgres) DeepCopyObject

func (in *Postgres) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*Postgres) EnableDedicatedSVCLB added in v0.14.0

func (p *Postgres) EnableDedicatedSVCLB() bool

func (*Postgres) EnableSharedSVCLB added in v0.14.0

func (p *Postgres) EnableSharedSVCLB(enableForceSharedIP bool) bool

func (*Postgres) HasFinalizer

func (p *Postgres) HasFinalizer(finalizerName string) bool

func (*Postgres) HasSourceRanges

func (p *Postgres) HasSourceRanges() bool

HasSourceRanges returns true if SourceRanges are set

func (*Postgres) IsBeingDeleted

func (p *Postgres) IsBeingDeleted() bool

IsBeingDeleted returns true if the deletion-timestamp is set

func (*Postgres) IsReplicationPrimaryOrStandalone added in v0.16.0

func (p *Postgres) IsReplicationPrimaryOrStandalone() bool

func (*Postgres) IsReplicationTarget added in v0.12.1

func (p *Postgres) IsReplicationTarget() bool

func (*Postgres) RemoveFinalizer

func (p *Postgres) RemoveFinalizer(finalizerName string)

func (*Postgres) ToBackupSecretName

func (p *Postgres) ToBackupSecretName() string

ToBackupSecretName returns the name of the secret containing backup credentials

func (*Postgres) ToCWNP

func (p *Postgres) ToCWNP(port int) (*firewall.ClusterwideNetworkPolicy, error)

ToCWNP returns CRD ClusterwideNetworkPolicy derived from CRD Postgres

func (*Postgres) ToDNSName added in v0.14.0

func (p *Postgres) ToDNSName(tlsSubDomain string) string

func (*Postgres) ToDedicatedSvcLB added in v0.12.0

func (p *Postgres) ToDedicatedSvcLB(lbIP string, lbPort int32, standbyClustersSourceRanges []string, sharedSvcLbAlsoEnabled bool) *corev1.Service

func (*Postgres) ToDedicatedSvcLBName added in v0.12.0

func (p *Postgres) ToDedicatedSvcLBName() string

ToSharedSvcLBName returns the name of the peripheral resource Service LoadBalancer. It's different from all other peripheral resources because the operator already generates one service with that name.

func (*Postgres) ToDedicatedSvcLBNamespacedName added in v0.12.0

func (p *Postgres) ToDedicatedSvcLBNamespacedName() *types.NamespacedName

func (*Postgres) ToKey

func (p *Postgres) ToKey() *types.NamespacedName

func (*Postgres) ToPeripheralResourceLookupKey

func (p *Postgres) ToPeripheralResourceLookupKey() types.NamespacedName

func (*Postgres) ToPeripheralResourceName

func (p *Postgres) ToPeripheralResourceName() string

func (*Postgres) ToPeripheralResourceNamespace

func (p *Postgres) ToPeripheralResourceNamespace() string

func (*Postgres) ToSharedSvcLB added in v0.12.0

func (p *Postgres) ToSharedSvcLB(lbIP string, lbPort int32, enableStandbyLeaderSelector bool, enableLegacyStandbySelector bool, standbyClustersSourceRanges []string) *corev1.Service

func (*Postgres) ToSharedSvcLBName added in v0.12.0

func (p *Postgres) ToSharedSvcLBName() string

ToSharedSvcLBName returns the name of the peripheral resource Service LoadBalancer. It's different from all other peripheral resources because the operator already generates one service with that name.

func (*Postgres) ToSharedSvcLBNamespacedName added in v0.12.0

func (p *Postgres) ToSharedSvcLBNamespacedName() *types.NamespacedName

func (*Postgres) ToStandbyClusterEgresCWNPName added in v0.4.0

func (p *Postgres) ToStandbyClusterEgresCWNPName() string

func (*Postgres) ToStandbyClusterEgressCWNP added in v0.4.0

func (p *Postgres) ToStandbyClusterEgressCWNP() (*firewall.ClusterwideNetworkPolicy, error)

func (*Postgres) ToStandbyClusterIngresCWNPName added in v0.4.0

func (p *Postgres) ToStandbyClusterIngresCWNPName() string

func (*Postgres) ToStandbyClusterIngressCWNP added in v0.4.0

func (p *Postgres) ToStandbyClusterIngressCWNP(sourceCIDRs []string) (*firewall.ClusterwideNetworkPolicy, error)

func (*Postgres) ToTLSSecretName added in v0.14.0

func (p *Postgres) ToTLSSecretName() string

func (*Postgres) ToUnstructuredZalandoPostgresql

func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *corev1.ConfigMap, sc string, pgParamBlockList map[string]bool, rbs *BackupConfig, srcDB *Postgres, patroniTTL, patroniLoopWait, patroniRetryTimeout uint32, dboIsSuperuser bool, enableTlsCert bool) (*unstructured.Unstructured, error)

func (*Postgres) ToUserPasswordSecretMatchingLabels

func (p *Postgres) ToUserPasswordSecretMatchingLabels() map[string]string

func (*Postgres) ToUserPasswordsSecret

func (p *Postgres) ToUserPasswordsSecret(src *corev1.SecretList, scheme *runtime.Scheme) (*corev1.Secret, error)

ToUserPasswordsSecret returns the secret containing user password pairs

func (*Postgres) ToUserPasswordsSecretListOption

func (p *Postgres) ToUserPasswordsSecretListOption() []client.ListOption

ToUserPasswordsSecretListOption returns the argument for listing secrets

func (*Postgres) ToUserPasswordsSecretName

func (p *Postgres) ToUserPasswordsSecretName() string

ToUserPasswordsSecretName returns the name of the secret containing user password pairs

func (*Postgres) ToZalandoPostgresqlMatchingLabels

func (p *Postgres) ToZalandoPostgresqlMatchingLabels() client.MatchingLabels

type PostgresConnection added in v0.4.0

type PostgresConnection struct {
	// ConnectedPostgresID internal ID of the connected Postgres instance
	ConnectedPostgresID string `json:"postgresID,omitempty"`
	// ConnectionSecretName name of the internal secret used to connect to the remote postgres
	ConnectionSecretName string `json:"secretName,omitempty"`
	// ConnectionIP IP of the remote postgres
	ConnectionIP string `json:"ip,omitempty"`
	// ConnectionPort port of the remote postgres
	ConnectionPort uint16 `json:"port,omitempty"`
	// SynchronousReplication determines if async  or sync replication is used for the standby postgres
	SynchronousReplication bool `json:"synchronous,omitempty"`
	// ReplicationPrimary determines if THIS side of the connection is the primary or the standby side
	ReplicationPrimary bool `json:"localSideIsPrimary,omitempty"`
}

PostgresConnection A remote postgres instance this one is linked to, e.g. for standby purpouses.

func (*PostgresConnection) DeepCopy added in v0.4.0

func (in *PostgresConnection) DeepCopy() *PostgresConnection

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgresConnection.

func (*PostgresConnection) DeepCopyInto added in v0.4.0

func (in *PostgresConnection) DeepCopyInto(out *PostgresConnection)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PostgresList

type PostgresList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Postgres `json:"items"`
}

PostgresList contains a list of Postgres

func (*PostgresList) DeepCopy

func (in *PostgresList) DeepCopy() *PostgresList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgresList.

func (*PostgresList) DeepCopyInto

func (in *PostgresList) DeepCopyInto(out *PostgresList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*PostgresList) DeepCopyObject

func (in *PostgresList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type PostgresRestore added in v0.5.0

type PostgresRestore struct {
	// SourcePostgresID internal ID of the Postgres instance to whose backup to restore
	SourcePostgresID string `json:"postgresID,omitempty"`
	// Timestamp The point in time to recover. Must be set, or the clone with switch from WALs from the S3 to a basebackup via direct sql connection (which won't work when the source db is managed by another posgres-operator)
	Timestamp string `json:"timestamp,omitempty"`
}

Restore defines what to restore from where

func (*PostgresRestore) DeepCopy added in v0.5.0

func (in *PostgresRestore) DeepCopy() *PostgresRestore

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgresRestore.

func (*PostgresRestore) DeepCopyInto added in v0.5.0

func (in *PostgresRestore) DeepCopyInto(out *PostgresRestore)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PostgresSpec

type PostgresSpec struct {

	// Description
	Description string `json:"description,omitempty"`
	// ProjectID metal project ID
	ProjectID string `json:"projectID,omitempty"`
	// Tenant metal tenant
	Tenant string `json:"tenant,omitempty"`
	// PartitionID the partition where the database is created
	PartitionID string `json:"partitionID,omitempty"`

	// NumberOfInstances number of replicas
	// +kubebuilder:validation:Minimum=1
	// +kubebuilder:default=1
	NumberOfInstances int32 `json:"numberOfInstances,omitempty"`

	// Version is the version of Postgre-as-a-Service
	Version string `json:"version,omitempty"`

	// Size of the database
	Size *Size `json:"size,omitempty"`

	// todo: add default
	// Maintenance defines automatic maintenance of the database
	Maintenance []string `json:"maintenance,omitempty"`

	// AccessList defines access restrictions
	AccessList *AccessList `json:"accessList,omitempty"`

	// BackupSecretRef reference to the secret where the backup credentials are stored
	BackupSecretRef string `json:"backupSecretRef,omitempty"`

	// PostgresRestore
	PostgresRestore *PostgresRestore `json:"restore,omitempty"`

	// PostgresConnection Connection info of a streaming host, independent of the current role (leader or standby)
	PostgresConnection *PostgresConnection `json:"connection,omitempty"`

	// AuditLogs enable or disable default audit logs
	AuditLogs *bool `json:"auditLogs,omitempty"`

	// PostgresParams additional parameters that are passed along to the postgres config
	PostgresParams map[string]string `json:"postgresParams,omitempty"`

	// DedicatedLoadBalancerIP The ip to use for the load balancer
	DedicatedLoadBalancerIP *string `json:"dedicatedLoadBalancerIP,omitempty"`

	// DedicatedLoadBalancerPort The port to use for the load balancer
	DedicatedLoadBalancerPort *int32 `json:"dedicatedLoadBalancerPort,omitempty"`
}

PostgresSpec defines the desired state of Postgres

func (*PostgresSpec) DeepCopy

func (in *PostgresSpec) DeepCopy() *PostgresSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgresSpec.

func (*PostgresSpec) DeepCopyInto

func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PostgresStatus

type PostgresStatus struct {
	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
	// Important: Run "make" to regenerate code after modifying this file
	Description string `json:"description,omitempty"`

	Socket Socket `json:"socket,omitempty"`

	AdditionalSockets []Socket `json:"additionalSockets,omitempty"`

	ChildName string `json:"childName,omitempty"`
}

PostgresStatus defines the observed state of Postgres

func (*PostgresStatus) DeepCopy

func (in *PostgresStatus) DeepCopy() *PostgresStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PostgresStatus.

func (*PostgresStatus) DeepCopyInto

func (in *PostgresStatus) DeepCopyInto(out *PostgresStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Size

type Size struct {
	// CPU is in the format as pod.spec.resource.request.cpu
	CPU string `json:"cpu,omitempty"`
	// Memory is in the format as pod.spec.resource.request.memory
	Memory string `json:"memory,omitempty"`
	// SharedBuffer of the database
	SharedBuffer string `json:"sharedBuffer,omitempty"`

	// StorageSize the amount of Storage this database will get
	// +kubebuilder:default="1Gi"
	// +kubebuilder:validation:Pattern=^[1-9][0-9]*Gi
	StorageSize string `json:"storageSize,omitempty"`
}

Todo: Add defaults Size defines the size aspects of the database

func (*Size) DeepCopy

func (in *Size) DeepCopy() *Size

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Size.

func (*Size) DeepCopyInto

func (in *Size) DeepCopyInto(out *Size)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Socket

type Socket struct {
	IP   string `json:"ip,omitempty"`
	Port int32  `json:"port,omitempty"`
}

Socket represents load-balancer socket of Postgres

func (*Socket) DeepCopy

func (in *Socket) DeepCopy() *Socket

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Socket.

func (*Socket) DeepCopyInto

func (in *Socket) DeepCopyInto(out *Socket)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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