Allow custom Postgres pod environment variables
This commit is contained in:
parent
86803406db
commit
257e0fc0a9
32
README.md
32
README.md
|
|
@ -136,6 +136,38 @@ spec:
|
||||||
|
|
||||||
Please be ware that the taint and toleration only ensures that no other pod gets scheduled to the "postgres" node but not that Postgres pods are placed on such a node. This can be achieved by setting a node affinity rule in the ConfigMap.
|
Please be ware that the taint and toleration only ensures that no other pod gets scheduled to the "postgres" node but not that Postgres pods are placed on such a node. This can be achieved by setting a node affinity rule in the ConfigMap.
|
||||||
|
|
||||||
|
#### Custom Pod Environment Variables
|
||||||
|
|
||||||
|
It is possible to configure a config map which is used by the Postgres pods as an additional provider for environment variables.
|
||||||
|
|
||||||
|
One use case is to customize the Spilo image and configure it with environment variables. The config map with the additional settings is configured in the operator's main config map:
|
||||||
|
|
||||||
|
**postgres-operator ConfigMap**
|
||||||
|
|
||||||
|
```
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: postgres-operator
|
||||||
|
data:
|
||||||
|
# referencing config map with custom settings
|
||||||
|
pod_environment_configmap: postgres-pod-config
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
**referenced ConfigMap `postgres-pod-config`**
|
||||||
|
|
||||||
|
```
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: postgres-pod-config
|
||||||
|
namespace: default
|
||||||
|
data:
|
||||||
|
MY_CUSTOM_VAR: value
|
||||||
|
```
|
||||||
|
|
||||||
|
This ConfigMap is then added as a source of environment variables to the Postgres StatefulSet/pods.
|
||||||
|
|
||||||
# Setup development environment
|
# Setup development environment
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,13 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme
|
||||||
if cloneDescription.ClusterName != "" {
|
if cloneDescription.ClusterName != "" {
|
||||||
envVars = append(envVars, c.generateCloneEnvironment(cloneDescription)...)
|
envVars = append(envVars, c.generateCloneEnvironment(cloneDescription)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
envFromSource := []v1.EnvFromSource{}
|
||||||
|
if c.OpConfig.PodEnvironmentConfigMap != "" {
|
||||||
|
configMapRef := v1.ConfigMapEnvSource{LocalObjectReference: v1.LocalObjectReference{Name: c.OpConfig.PodEnvironmentConfigMap}}
|
||||||
|
envFromSource = append(envFromSource, v1.EnvFromSource{ConfigMapRef: &configMapRef})
|
||||||
|
}
|
||||||
|
|
||||||
privilegedMode := true
|
privilegedMode := true
|
||||||
container := v1.Container{
|
container := v1.Container{
|
||||||
Name: c.containerName(),
|
Name: c.containerName(),
|
||||||
|
|
@ -388,6 +395,7 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Env: envVars,
|
Env: envVars,
|
||||||
|
EnvFrom: envFromSource,
|
||||||
SecurityContext: &v1.SecurityContext{
|
SecurityContext: &v1.SecurityContext{
|
||||||
Privileged: &privilegedMode,
|
Privileged: &privilegedMode,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ type Resources struct {
|
||||||
DefaultCPULimit string `name:"default_cpu_limit" default:"3"`
|
DefaultCPULimit string `name:"default_cpu_limit" default:"3"`
|
||||||
DefaultMemoryLimit string `name:"default_memory_limit" default:"1Gi"`
|
DefaultMemoryLimit string `name:"default_memory_limit" default:"1Gi"`
|
||||||
EOLNodeLabel map[string]string `name:"eol_node_label" default:"eol:true"`
|
EOLNodeLabel map[string]string `name:"eol_node_label" default:"eol:true"`
|
||||||
|
PodEnvironmentConfigMap string `name:"pod_environment_configmap" default:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auth describes authentication specific configuration parameters
|
// Auth describes authentication specific configuration parameters
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue