Documentation ¶
Overview ¶
Package specs contains the specification of the K8s resources generated by the CloudNativePG operator
Index ¶
- Constants
- Variables
- func AddBarmanEndpointCAToPodSpec(podSpec *corev1.PodSpec, caSecret *apiv1.SecretKeySelector, ...)
- func BuildPrimaryPodDisruptionBudget(cluster *apiv1.Cluster) *policyv1beta1.PodDisruptionBudget
- func BuildReplicasPodDisruptionBudget(cluster *apiv1.Cluster) *policyv1beta1.PodDisruptionBudget
- func CreateAffinitySection(clusterName string, config apiv1.AffinityConfiguration) *corev1.Affinity
- func CreateClusterAnyService(cluster apiv1.Cluster) *corev1.Service
- func CreateClusterReadOnlyService(cluster apiv1.Cluster) *corev1.Service
- func CreateClusterReadService(cluster apiv1.Cluster) *corev1.Service
- func CreateClusterReadWriteService(cluster apiv1.Cluster) *corev1.Service
- func CreateContainerSecurityContext() *corev1.SecurityContext
- func CreateGeneratedAntiAffinity(clusterName string, config apiv1.AffinityConfiguration) *corev1.Affinity
- func CreateManagedSecretsAnnotationValue(imagePullSecretsNames []string) (string, error)
- func CreatePVC(storageConfiguration apiv1.StorageConfiguration, cluster apiv1.Cluster, ...) (*corev1.PersistentVolumeClaim, error)
- func CreatePodMonitor(cluster *apiv1.Cluster) *monitoringv1.PodMonitor
- func CreatePodSecurityContext(user, group int64) *corev1.PodSecurityContext
- func CreatePrimaryJobViaInitdb(cluster apiv1.Cluster, nodeSerial int) *batchv1.Job
- func CreatePrimaryJobViaPgBaseBackup(cluster apiv1.Cluster, nodeSerial int) *batchv1.Job
- func CreatePrimaryJobViaRecovery(cluster apiv1.Cluster, nodeSerial int, backup *apiv1.Backup) *batchv1.Job
- func CreateRole(cluster apiv1.Cluster, backupOrigin *apiv1.Backup) rbacv1.Role
- func CreateRoleBinding(objectMeta metav1.ObjectMeta) rbacv1.RoleBinding
- func CreateSecret(name string, namespace string, hostname string, dbname string, username string, ...) *corev1.Secret
- func DoesPVCBelongToInstance(cluster *apiv1.Cluster, instanceName, resourceName string) bool
- func FilterInstancePVCs(pvcs []corev1.PersistentVolumeClaim, instanceSpec corev1.PodSpec) []corev1.PersistentVolumeClaim
- func GetBootstrapControllerImageName(pod corev1.Pod) (string, error)
- func GetContainerImageName(pod corev1.Pod, containerName string) (string, error)
- func GetInitContainerImageName(pod corev1.Pod, containerName string) (string, error)
- func GetNodeSerial(object metav1.ObjectMeta) (int, error)
- func GetPVCName(cluster apiv1.Cluster, instanceName string, role utils.PVCRole) string
- func GetPostgresImageName(pod corev1.Pod) (string, error)
- func IsPodPrimary(pod corev1.Pod) bool
- func IsPodSpecUsingPVCs(podSpec corev1.PodSpec, pvcNames ...string) bool
- func IsPodStandby(pod corev1.Pod) bool
- func IsServiceAccountAligned(sa *corev1.ServiceAccount, imagePullSecretsNames []string) (bool, error)
- func JoinReplicaInstance(cluster apiv1.Cluster, nodeSerial int) *batchv1.Job
- func PodWithExistingStorage(cluster apiv1.Cluster, nodeSerial int) *corev1.Pod
- func UpdateServiceAccount(imagePullSecretsNames []string, serviceAccount *corev1.ServiceAccount) error
- type PVCUsageStatus
Constants ¶
const ( // MetadataNamespace is the annotation and label namespace used by the operator MetadataNamespace = "cnpg.io" // ClusterSerialAnnotationName is the name of the annotation containing the // serial number of the node ClusterSerialAnnotationName = MetadataNamespace + "/nodeSerial" // ClusterRestartAnnotationName is the name of the annotation containing the // latest required restart time ClusterRestartAnnotationName = "kubectl.kubernetes.io/restartedAt" // ClusterReloadAnnotationName is the name of the annotation containing the // latest required restart time ClusterReloadAnnotationName = MetadataNamespace + "/reloadedAt" // ClusterRoleLabelName label is applied to Pods to mark primary ones ClusterRoleLabelName = "role" // ClusterRoleLabelPrimary is written in labels to represent primary servers ClusterRoleLabelPrimary = "primary" // ClusterRoleLabelReplica is written in labels to represent replica servers ClusterRoleLabelReplica = "replica" // WatchedLabelName label is for Secrets or ConfigMaps that needs to be reloaded WatchedLabelName = MetadataNamespace + "/reload" // ClusterLabelName label is applied to Pods to link them to the owning // cluster. // // Deprecated. // // utils.ClusterLabelName should be used instead where possible. ClusterLabelName = "postgresql" // PostgresContainerName is the name of the container executing PostgreSQL // inside one Pod PostgresContainerName = "postgres" // BootstrapControllerContainerName is the name of the container copying the bootstrap // controller inside the Pod file system BootstrapControllerContainerName = "bootstrap-controller" // PgDataPath is the path to PGDATA variable PgDataPath = "/var/lib/postgresql/data/pgdata" // PgWalPath is the path to the pg_wal directory PgWalPath = PgDataPath + "/pg_wal" // PgWalArchiveStatusPath is the path to the archive status directory PgWalArchiveStatusPath = PgWalPath + "/archive_status" // ReadinessProbePeriod is the period set for the postgres instance readiness probe ReadinessProbePeriod = 10 )
const ( // PVCStatusAnnotationName is an annotation that shows the current status of the PVC. // The status can be "initializing" or "ready" PVCStatusAnnotationName = MetadataNamespace + "/pvcStatus" // PVCStatusInitializing is the annotation value for PVC initializing status PVCStatusInitializing = "initializing" // PVCStatusReady is the annotation value for PVC ready status PVCStatusReady = "ready" // PVCStatusDetached is the annotation value for PVC detached status PVCStatusDetached = "detached" )
const ( // OperatorManagedSecretsName is the name of the annotation containing the secrets // managed by the operator inside the generated service account OperatorManagedSecretsName = "cnpg.io/managedSecrets" // #nosec )
Variables ¶
var ErrorInvalidSize = fmt.Errorf("invalid storage size")
ErrorInvalidSize is raised when the size specified by the user is not valid and can't be specified in a PVC declaration
Functions ¶
func AddBarmanEndpointCAToPodSpec ¶ added in v1.16.1
func AddBarmanEndpointCAToPodSpec( podSpec *corev1.PodSpec, caSecret *apiv1.SecretKeySelector, credentials apiv1.BarmanCredentials, )
AddBarmanEndpointCAToPodSpec adds the required volumes and env variables needed by barman to work correctly
func BuildPrimaryPodDisruptionBudget ¶
func BuildPrimaryPodDisruptionBudget(cluster *apiv1.Cluster) *policyv1beta1.PodDisruptionBudget
BuildPrimaryPodDisruptionBudget creates a pod disruption budget, telling K8s to avoid removing more than one primary instance at a time
func BuildReplicasPodDisruptionBudget ¶
func BuildReplicasPodDisruptionBudget(cluster *apiv1.Cluster) *policyv1beta1.PodDisruptionBudget
BuildReplicasPodDisruptionBudget creates a pod disruption budget telling K8s to avoid removing more than one replica at a time
func CreateAffinitySection ¶
func CreateAffinitySection(clusterName string, config apiv1.AffinityConfiguration) *corev1.Affinity
CreateAffinitySection creates the affinity sections for Pods, given the configuration from the user
func CreateClusterAnyService ¶
CreateClusterAnyService create a service insisting on all the pods
func CreateClusterReadOnlyService ¶
CreateClusterReadOnlyService create a service insisting on all the ready pods
func CreateClusterReadService ¶
CreateClusterReadService create a service insisting on all the ready pods
func CreateClusterReadWriteService ¶
CreateClusterReadWriteService create a service insisting on the primary pod
func CreateContainerSecurityContext ¶
func CreateContainerSecurityContext() *corev1.SecurityContext
CreateContainerSecurityContext initializes container security context
func CreateGeneratedAntiAffinity ¶
func CreateGeneratedAntiAffinity(clusterName string, config apiv1.AffinityConfiguration) *corev1.Affinity
CreateGeneratedAntiAffinity generates the affinity terms the operator is in charge for if enabled, return nil if disabled or an error occurred, as invalid values should be validated before this method is called
func CreateManagedSecretsAnnotationValue ¶
CreateManagedSecretsAnnotationValue creates the value of the annotations that stores the names of the secrets managed by the operator inside a ServiceAccount
func CreatePVC ¶
func CreatePVC( storageConfiguration apiv1.StorageConfiguration, cluster apiv1.Cluster, nodeSerial int, role utils.PVCRole, ) (*corev1.PersistentVolumeClaim, error)
CreatePVC create spec of a PVC, given its name and the storage configuration
func CreatePodMonitor ¶
func CreatePodMonitor(cluster *apiv1.Cluster) *monitoringv1.PodMonitor
CreatePodMonitor create a new podmonitor for cluster
func CreatePodSecurityContext ¶ added in v1.15.3
func CreatePodSecurityContext(user, group int64) *corev1.PodSecurityContext
CreatePodSecurityContext defines the security context under which the containers are running
func CreatePrimaryJobViaInitdb ¶
CreatePrimaryJobViaInitdb creates a new primary instance in a Pod
func CreatePrimaryJobViaPgBaseBackup ¶
CreatePrimaryJobViaPgBaseBackup creates a new primary instance in a Pod
func CreatePrimaryJobViaRecovery ¶
func CreatePrimaryJobViaRecovery(cluster apiv1.Cluster, nodeSerial int, backup *apiv1.Backup) *batchv1.Job
CreatePrimaryJobViaRecovery creates a new primary instance in a Pod
func CreateRole ¶
CreateRole create a role with the permissions needed by the instance manager
func CreateRoleBinding ¶
func CreateRoleBinding(objectMeta metav1.ObjectMeta) rbacv1.RoleBinding
CreateRoleBinding is the binding between the permissions that PGK can use and the ServiceAccount used by the Pod
func CreateSecret ¶
func CreateSecret( name string, namespace string, hostname string, dbname string, username string, password string, ) *corev1.Secret
CreateSecret create a secret with the PostgreSQL and the owner passwords
func DoesPVCBelongToInstance ¶ added in v1.17.0
DoesPVCBelongToInstance returns a boolean indicating if that given PVC belongs to an instance
func FilterInstancePVCs ¶ added in v1.15.4
func FilterInstancePVCs( pvcs []corev1.PersistentVolumeClaim, instanceSpec corev1.PodSpec, ) []corev1.PersistentVolumeClaim
FilterInstancePVCs returns all the corev1.PersistentVolumeClaim that are used inside the podSpec
func GetBootstrapControllerImageName ¶
GetBootstrapControllerImageName get the controller image name used to bootstrap a Pod
func GetContainerImageName ¶
GetContainerImageName get the name of the image used in a container
func GetInitContainerImageName ¶
GetInitContainerImageName get the name of the image used in an init container
func GetNodeSerial ¶
func GetNodeSerial(object metav1.ObjectMeta) (int, error)
GetNodeSerial get the serial number of an object created by the operator for a Cluster
func GetPVCName ¶ added in v1.17.0
GetPVCName builds the name for a given PVC of the instance
func GetPostgresImageName ¶
GetPostgresImageName get the PostgreSQL image name used in this Pod
func IsPodPrimary ¶
IsPodPrimary check if a certain pod belongs to a primary
func IsPodSpecUsingPVCs ¶ added in v1.17.0
IsPodSpecUsingPVCs checks if the given pod spec is using the PVCs
func IsPodStandby ¶
IsPodStandby check if a certain pod belongs to a standby
func IsServiceAccountAligned ¶
func IsServiceAccountAligned(sa *corev1.ServiceAccount, imagePullSecretsNames []string) (bool, error)
IsServiceAccountAligned compares the given list of pull secrets with the ones managed by the operator inside the given ServiceAccount and returns true when everything is aligned
func JoinReplicaInstance ¶
JoinReplicaInstance create a new PostgreSQL node, copying the contents from another Pod
func PodWithExistingStorage ¶
PodWithExistingStorage create a new instance with an existing storage
func UpdateServiceAccount ¶
func UpdateServiceAccount(imagePullSecretsNames []string, serviceAccount *corev1.ServiceAccount) error
UpdateServiceAccount sets the needed values in the ServiceAccount that will be used in every Pod
Types ¶
type PVCUsageStatus ¶
type PVCUsageStatus struct { // List of PVCs that are being initialized (they have a corresponding Job but not a corresponding Pod) Initializing []string // List of PVCs with Resizing condition. Requires a pod restart. // // INFO: https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/ Resizing []string // List of PVCs that are dangling (they don't have a corresponding Job nor a corresponding Pod) Dangling []string // List of PVCs that are used (they have a corresponding Pod) Healthy []string // List of PVCs that are unusable (they are part of an incomplete group) Unusable []string }
PVCUsageStatus is the status of the PVC we generated
func DetectPVCs ¶
func DetectPVCs( ctx context.Context, cluster *apiv1.Cluster, podList []corev1.Pod, jobList []batchv1.Job, pvcList []corev1.PersistentVolumeClaim, ) (result PVCUsageStatus)
DetectPVCs fill the list with the PVCs which are dangling, given that PVC are usually named after Pods nolint: gocognit
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package pgbouncer contains the specification of the K8s resources generated by the CloudNativePG operator related to pgbouncer poolers
|
Package pgbouncer contains the specification of the K8s resources generated by the CloudNativePG operator related to pgbouncer poolers |