Skip to content

Commit a5799b8

Browse files
authored
feat(CNP-7965): accept env field in extension configuration CRD (#10387)
Allow the CRD schema for Cluster, ImageCatalog, and ClusterImageCatalog to include the env field introduced in 1.29, letting users share a single manifest across clusters running different CNPG versions. Signed-off-by: Marco Nenciarini <[email protected]>
1 parent e4a8f18 commit a5799b8

7 files changed

Lines changed: 191 additions & 0 deletions

‎.wordlist-en-custom.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ EphemeralVolumeSource
161161
EphemeralVolumesSizeLimit
162162
EphemeralVolumesSizeLimitConfiguration
163163
ExtensionConfiguration
164+
ExtensionEnvVar
164165
ExtensionSpec
165166
ExtensionStatus
166167
ExternalCluster
@@ -859,6 +860,7 @@ executables
859860
expirations
860861
extensibility
861862
extensionconfiguration
863+
extensionenvvar
862864
extensionspec
863865
externalCluster
864866
externalClusterName

‎api/v1/cluster_types.go‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,38 @@ type ExtensionConfiguration struct {
14991499
// PostgreSQL process's `PATH` environment variable.
15001500
// +optional
15011501
BinPath []string `json:"bin_path,omitempty"`
1502+
1503+
// Env is a list of custom environment variables to be set in the
1504+
// PostgreSQL process for this extension. It is the responsibility of the
1505+
// cluster administrator to ensure the variables are correct for the
1506+
// specific extension. Note that changes to these variables require
1507+
// a manual cluster restart to take effect.
1508+
// +optional
1509+
// +listType=map
1510+
// +listMapKey=name
1511+
Env []ExtensionEnvVar `json:"env,omitempty"`
1512+
}
1513+
1514+
// ExtensionEnvVar defines an environment variable for a specific extension
1515+
// image volume.
1516+
type ExtensionEnvVar struct {
1517+
// Name of the environment variable to be injected into the
1518+
// PostgreSQL process.
1519+
// +kubebuilder:validation:MinLength=1
1520+
// +kubebuilder:validation:Pattern=`^[a-zA-Z_][a-zA-Z0-9_]*$`
1521+
Name string `json:"name"`
1522+
1523+
// Value of the environment variable. CloudNativePG performs a direct
1524+
// replacement of this value, with support for placeholder expansion.
1525+
// The ${`image_root`} placeholder resolves to the absolute mount path
1526+
// of the extension's volume (e.g., `/extensions/my-extension`). This
1527+
// is particularly useful for allowing applications or libraries to
1528+
// locate specific directories within the mounted image.
1529+
// Unrecognized placeholders are rejected. To include a literal ${...}
1530+
// in the value, escape it as $${...}.
1531+
//
1532+
// +kubebuilder:validation:MinLength=1
1533+
Value string `json:"value"`
15021534
}
15031535

15041536
// BootstrapConfiguration contains information about how to create the PostgreSQL

‎api/v1/zz_generated.deepcopy.go‎

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎config/crd/bases/postgresql.cnpg.io_clusterimagecatalogs.yaml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,45 @@ spec:
7272
items:
7373
type: string
7474
type: array
75+
env:
76+
description: |-
77+
Env is a list of custom environment variables to be set in the
78+
PostgreSQL process for this extension. It is the responsibility of the
79+
cluster administrator to ensure the variables are correct for the
80+
specific extension. Note that changes to these variables require
81+
a manual cluster restart to take effect.
82+
items:
83+
description: |-
84+
ExtensionEnvVar defines an environment variable for a specific extension
85+
image volume.
86+
properties:
87+
name:
88+
description: |-
89+
Name of the environment variable to be injected into the
90+
PostgreSQL process.
91+
minLength: 1
92+
pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
93+
type: string
94+
value:
95+
description: |-
96+
Value of the environment variable. CloudNativePG performs a direct
97+
replacement of this value, with support for placeholder expansion.
98+
The ${`image_root`} placeholder resolves to the absolute mount path
99+
of the extension's volume (e.g., `/extensions/my-extension`). This
100+
is particularly useful for allowing applications or libraries to
101+
locate specific directories within the mounted image.
102+
Unrecognized placeholders are rejected. To include a literal ${...}
103+
in the value, escape it as $${...}.
104+
minLength: 1
105+
type: string
106+
required:
107+
- name
108+
- value
109+
type: object
110+
type: array
111+
x-kubernetes-list-map-keys:
112+
- name
113+
x-kubernetes-list-type: map
75114
extension_control_path:
76115
description: |-
77116
The list of directories inside the image which should be added to extension_control_path.

‎config/crd/bases/postgresql.cnpg.io_clusters.yaml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4381,6 +4381,45 @@ spec:
43814381
items:
43824382
type: string
43834383
type: array
4384+
env:
4385+
description: |-
4386+
Env is a list of custom environment variables to be set in the
4387+
PostgreSQL process for this extension. It is the responsibility of the
4388+
cluster administrator to ensure the variables are correct for the
4389+
specific extension. Note that changes to these variables require
4390+
a manual cluster restart to take effect.
4391+
items:
4392+
description: |-
4393+
ExtensionEnvVar defines an environment variable for a specific extension
4394+
image volume.
4395+
properties:
4396+
name:
4397+
description: |-
4398+
Name of the environment variable to be injected into the
4399+
PostgreSQL process.
4400+
minLength: 1
4401+
pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
4402+
type: string
4403+
value:
4404+
description: |-
4405+
Value of the environment variable. CloudNativePG performs a direct
4406+
replacement of this value, with support for placeholder expansion.
4407+
The ${`image_root`} placeholder resolves to the absolute mount path
4408+
of the extension's volume (e.g., `/extensions/my-extension`). This
4409+
is particularly useful for allowing applications or libraries to
4410+
locate specific directories within the mounted image.
4411+
Unrecognized placeholders are rejected. To include a literal ${...}
4412+
in the value, escape it as $${...}.
4413+
minLength: 1
4414+
type: string
4415+
required:
4416+
- name
4417+
- value
4418+
type: object
4419+
type: array
4420+
x-kubernetes-list-map-keys:
4421+
- name
4422+
x-kubernetes-list-type: map
43844423
extension_control_path:
43854424
description: |-
43864425
The list of directories inside the image which should be added to extension_control_path.

‎config/crd/bases/postgresql.cnpg.io_imagecatalogs.yaml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,45 @@ spec:
7171
items:
7272
type: string
7373
type: array
74+
env:
75+
description: |-
76+
Env is a list of custom environment variables to be set in the
77+
PostgreSQL process for this extension. It is the responsibility of the
78+
cluster administrator to ensure the variables are correct for the
79+
specific extension. Note that changes to these variables require
80+
a manual cluster restart to take effect.
81+
items:
82+
description: |-
83+
ExtensionEnvVar defines an environment variable for a specific extension
84+
image volume.
85+
properties:
86+
name:
87+
description: |-
88+
Name of the environment variable to be injected into the
89+
PostgreSQL process.
90+
minLength: 1
91+
pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
92+
type: string
93+
value:
94+
description: |-
95+
Value of the environment variable. CloudNativePG performs a direct
96+
replacement of this value, with support for placeholder expansion.
97+
The ${`image_root`} placeholder resolves to the absolute mount path
98+
of the extension's volume (e.g., `/extensions/my-extension`). This
99+
is particularly useful for allowing applications or libraries to
100+
locate specific directories within the mounted image.
101+
Unrecognized placeholders are rejected. To include a literal ${...}
102+
in the value, escape it as $${...}.
103+
minLength: 1
104+
type: string
105+
required:
106+
- name
107+
- value
108+
type: object
109+
type: array
110+
x-kubernetes-list-map-keys:
111+
- name
112+
x-kubernetes-list-type: map
74113
extension_control_path:
75114
description: |-
76115
The list of directories inside the image which should be added to extension_control_path.

‎docs/src/cloudnative-pg.v1.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,26 @@ _Appears in:_
990990
| `dynamic_library_path` _string array_ | The list of directories inside the image which should be added to dynamic_library_path.<br />If not defined, defaults to "/lib". | | | |
991991
| `ld_library_path` _string array_ | The list of directories inside the image which should be added to ld_library_path. | | | |
992992
| `bin_path` _string array_ | A list of directories within the image to be appended to the<br />PostgreSQL process's `PATH` environment variable. | | | |
993+
| `env` _[ExtensionEnvVar](#extensionenvvar) array_ | Env is a list of custom environment variables to be set in the<br />PostgreSQL process for this extension. It is the responsibility of the<br />cluster administrator to ensure the variables are correct for the<br />specific extension. Note that changes to these variables require<br />a manual cluster restart to take effect. | | | |
994+
995+
996+
#### ExtensionEnvVar
997+
998+
999+
1000+
ExtensionEnvVar defines an environment variable for a specific extension
1001+
image volume.
1002+
1003+
1004+
1005+
_Appears in:_
1006+
1007+
- [ExtensionConfiguration](#extensionconfiguration)
1008+
1009+
| Field | Description | Required | Default | Validation |
1010+
| --- | --- | --- | --- | --- |
1011+
| `name` _string_ | Name of the environment variable to be injected into the<br />PostgreSQL process. | True | | MinLength: 1 <br />Pattern: `^[a-zA-Z_][a-zA-Z0-9_]*$` <br /> |
1012+
| `value` _string_ | Value of the environment variable. CloudNativePG performs a direct<br />replacement of this value, with support for placeholder expansion.<br />The $\{`image_root`\} placeholder resolves to the absolute mount path<br />of the extension's volume (e.g., `/extensions/my-extension`). This<br />is particularly useful for allowing applications or libraries to<br />locate specific directories within the mounted image.<br />Unrecognized placeholders are rejected. To include a literal $\{...\}<br />in the value, escape it as $$\{...\}. | True | | MinLength: 1 <br /> |
9931013

9941014

9951015
#### ExtensionSpec

0 commit comments

Comments
 (0)