Skip to content

Commit

Permalink
testing extension_destdir patch
Browse files Browse the repository at this point in the history
Signed-off-by: Niccolò Fei <[email protected]>
  • Loading branch information
NiccoloFei committed Dec 18, 2024
1 parent e22e7e9 commit 6ea5a33
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .wordlist-en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ EnvVar
EphemeralVolumeSource
EphemeralVolumesSizeLimit
EphemeralVolumesSizeLimitConfiguration
ExtensionConfiguration
ExtensionConfigurationList
ExternalCluster
ExternalClusterList
FQDN
Expand Down
5 changes: 5 additions & 0 deletions api/v1/cluster_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,11 @@ func (cluster *Cluster) IsPodMonitorEnabled() bool {
return false
}

// UsesExtensions checks if Extensions are requested
func (cluster *Cluster) UsesExtensions() bool {
return len(cluster.Spec.Extensions) != 0
}

// IsMetricsTLSEnabled checks if the metrics endpoint should use TLS
func (cluster *Cluster) IsMetricsTLSEnabled() bool {
if cluster.Spec.Monitoring != nil && cluster.Spec.Monitoring.TLSConfig != nil {
Expand Down
23 changes: 23 additions & 0 deletions api/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,29 @@ type ClusterSpec struct {
// in the PostgreSQL Pods.
// +optional
Probes *ProbesConfiguration `json:"probes,omitempty"`

// The configuration of the extensions to be added
// +optional
Extensions ExtensionConfigurationList `json:"extensions,omitempty"`
}

// ExtensionConfigurationList is a list of ExtensionConfiguration
type ExtensionConfigurationList []ExtensionConfiguration

// ExtensionConfiguration is the configuration used to add
// a PostgreSQL extensions to the Cluster
type ExtensionConfiguration struct {
// The name of the extension, required
Name string `json:"name"`

// The image containing the extension, required
ImageVolumeSource corev1.ImageVolumeSource `json:"image"`

// The path to the directory containing the extension files
ShareDirectoryPath string `json:"shareDirectoryPath,omitempty"`

// The path to the directory containing the libraries
LibDirectoryPath string `json:"libDirectoryPath,omitempty"`
}

// ProbesConfiguration represent the configuration for the probes
Expand Down
40 changes: 40 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions config/crd/bases/postgresql.cnpg.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2549,6 +2549,49 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
extensions:
description: The configuration of the extensions to be added
items:
description: |-
ExtensionConfiguration is the configuration used to add
a PostgreSQL extensions to the Cluster
properties:
image:
description: The image containing the extension, required
properties:
pullPolicy:
description: |-
Policy for pulling OCI objects. Possible values are:
Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails.
Never: the kubelet never pulls the reference and only uses a local image or artifact. Container creation will fail if the reference isn't present.
IfNotPresent: the kubelet pulls if the reference isn't already present on disk. Container creation will fail if the reference isn't present and the pull fails.
Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
type: string
reference:
description: |-
Required: Image or artifact reference to be used.
Behaves in the same way as pod.spec.containers[*].image.
Pull secrets will be assembled in the same way as for the container image by looking up node credentials, SA image pull secrets, and pod spec image pull secrets.
More info: https://kubernetes.io/docs/concepts/containers/images
This field is optional to allow higher level config management to default or override
container images in workload controllers like Deployments and StatefulSets.
type: string
type: object
libDirectoryPath:
description: The path to the directory containing the libraries
type: string
name:
description: The name of the extension, required
type: string
shareDirectoryPath:
description: The path to the directory containing the extension
files
type: string
required:
- image
- name
type: object
type: array
externalClusters:
description: The list of external clusters which are used in the configuration
items:
Expand Down
21 changes: 21 additions & 0 deletions docs/src/cloudnative-pg.v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,13 @@ any plugin to be loaded with the corresponding configuration</p>
in the PostgreSQL Pods.</p>
</td>
</tr>
<tr><td><code>extensions</code><br/>
<a href="#postgresql-cnpg-io-v1-ExtensionConfigurationList"><i>ExtensionConfigurationList</i></a>
</td>
<td>
<p>The configuration of the extensions to be added</p>
</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -2712,6 +2719,20 @@ storage</p>
</tbody>
</table>

## ExtensionConfigurationList {#postgresql-cnpg-io-v1-ExtensionConfigurationList}

(Alias of `[]github.com/cloudnative-pg/cloudnative-pg/api/v1.ExtensionConfiguration`)

**Appears in:**

- [ClusterSpec](#postgresql-cnpg-io-v1-ClusterSpec)


<p>ExtensionConfigurationList is a list of ExtensionConfiguration</p>




## ImageCatalogRef {#postgresql-cnpg-io-v1-ImageCatalogRef}


Expand Down
26 changes: 26 additions & 0 deletions pkg/specs/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ func createPostgresVolumes(cluster *apiv1.Cluster, podName string) []corev1.Volu
if cluster.ShouldCreateProjectedVolume() {
result = append(result, createProjectedVolume(cluster))
}

if cluster.UsesExtensions() {
for _, extension := range cluster.Spec.Extensions {
result = append(result,
corev1.Volume{
Name: extension.Name,
VolumeSource: corev1.VolumeSource{
Image: &extension.ImageVolumeSource,
},
},
)
}
}

return result
}

Expand Down Expand Up @@ -270,6 +284,18 @@ func createPostgresVolumeMounts(cluster apiv1.Cluster) []corev1.VolumeMount {
)
}
}

if cluster.UsesExtensions() {
for _, extension := range cluster.Spec.Extensions {
volumeMounts = append(volumeMounts,
corev1.VolumeMount{
Name: extension.Name,
MountPath: "/extensions",
},
)
}
}

return volumeMounts
}

Expand Down

0 comments on commit 6ea5a33

Please sign in to comment.