Provide more information about variable conflicts.
They are mentioned in the documentation and the operator will emit a warning each time the variable from the pod environment configmap is ignored because the same variable is defined by the operator. Some minor changes in the variable names to make the code more readable. Per review from Sergey Dudoladov.
This commit is contained in:
parent
da4b66210a
commit
0e255f82c6
|
|
@ -178,6 +178,8 @@ data:
|
||||||
|
|
||||||
This ConfigMap is then added as a source of environment variables to the Postgres StatefulSet/pods.
|
This ConfigMap is then added as a source of environment variables to the Postgres StatefulSet/pods.
|
||||||
|
|
||||||
|
:exclamation: Note that there are environment variables defined by the operator itself in order to pass parameters to the Spilo image. The values from the operator for those variables will take precedence over those defined in the `pod_environment_configmap`.
|
||||||
|
|
||||||
# Setup development environment
|
# Setup development environment
|
||||||
|
|
||||||
The following steps guide you through the setup to work on the operator itself.
|
The following steps guide you through the setup to work on the operator itself.
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme
|
||||||
patroniParameters *spec.Patroni,
|
patroniParameters *spec.Patroni,
|
||||||
cloneDescription *spec.CloneDescription,
|
cloneDescription *spec.CloneDescription,
|
||||||
dockerImage *string,
|
dockerImage *string,
|
||||||
extraEnv map[string]string) *v1.PodTemplateSpec {
|
customPodEnvVars map[string]string) *v1.PodTemplateSpec {
|
||||||
spiloConfiguration := c.generateSpiloJSONConfiguration(pgParameters, patroniParameters)
|
spiloConfiguration := c.generateSpiloJSONConfiguration(pgParameters, patroniParameters)
|
||||||
|
|
||||||
envVars := []v1.EnvVar{
|
envVars := []v1.EnvVar{
|
||||||
|
|
@ -373,14 +373,17 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme
|
||||||
for _, envVar := range envVars {
|
for _, envVar := range envVars {
|
||||||
envVarsMap[envVar.Name] = envVar.Value
|
envVarsMap[envVar.Name] = envVar.Value
|
||||||
}
|
}
|
||||||
for name := range extraEnv {
|
for name := range customPodEnvVars {
|
||||||
if _, ok := envVarsMap[name]; !ok {
|
if _, ok := envVarsMap[name]; !ok {
|
||||||
names = append(names, name)
|
names = append(names, name)
|
||||||
|
} else {
|
||||||
|
c.logger.Warningf("variable %q value from %q is ignored: conflict with the definition from the operator",
|
||||||
|
name, c.OpConfig.PodEnvironmentConfigMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
envVars = append(envVars, v1.EnvVar{Name: name, Value: extraEnv[name]})
|
envVars = append(envVars, v1.EnvVar{Name: name, Value: customPodEnvVars[name]})
|
||||||
}
|
}
|
||||||
|
|
||||||
privilegedMode := true
|
privilegedMode := true
|
||||||
|
|
@ -447,15 +450,15 @@ func (c *Cluster) generateStatefulSet(spec *spec.PostgresSpec) (*v1beta1.Statefu
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not generate resource requirements: %v", err)
|
return nil, fmt.Errorf("could not generate resource requirements: %v", err)
|
||||||
}
|
}
|
||||||
var extraEnv map[string]string
|
var customPodEnvVars map[string]string
|
||||||
if c.OpConfig.PodEnvironmentConfigMap != "" {
|
if c.OpConfig.PodEnvironmentConfigMap != "" {
|
||||||
if cm, err := c.KubeClient.ConfigMaps(c.Namespace).Get(c.OpConfig.PodEnvironmentConfigMap, metav1.GetOptions{}); err != nil {
|
if cm, err := c.KubeClient.ConfigMaps(c.Namespace).Get(c.OpConfig.PodEnvironmentConfigMap, metav1.GetOptions{}); err != nil {
|
||||||
return nil, fmt.Errorf("could not read PodEnvironmentConfigMap: %v", err)
|
return nil, fmt.Errorf("could not read PodEnvironmentConfigMap: %v", err)
|
||||||
} else {
|
} else {
|
||||||
extraEnv = cm.Data
|
customPodEnvVars = cm.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
podTemplate := c.generatePodTemplate(resourceRequirements, &spec.Tolerations, &spec.PostgresqlParam, &spec.Patroni, &spec.Clone, &spec.DockerImage, extraEnv)
|
podTemplate := c.generatePodTemplate(resourceRequirements, &spec.Tolerations, &spec.PostgresqlParam, &spec.Patroni, &spec.Clone, &spec.DockerImage, customPodEnvVars)
|
||||||
volumeClaimTemplate, err := generatePersistentVolumeClaimTemplate(spec.Volume.Size, spec.Volume.StorageClass)
|
volumeClaimTemplate, err := generatePersistentVolumeClaimTemplate(spec.Volume.Size, spec.Volume.StorageClass)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not generate volume claim template: %v", err)
|
return nil, fmt.Errorf("could not generate volume claim template: %v", err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue