Environment returns the environment variables required to invoke PostgreSQL utilities.
(cluster *v1beta1.PostgresCluster)
| 218 | // Environment returns the environment variables required to invoke PostgreSQL |
| 219 | // utilities. |
| 220 | func Environment(cluster *v1beta1.PostgresCluster) []corev1.EnvVar { |
| 221 | return []corev1.EnvVar{ |
| 222 | // - https://www.postgresql.org/docs/current/reference-server.html |
| 223 | { |
| 224 | Name: "PGDATA", |
| 225 | Value: ConfigDirectory(cluster), |
| 226 | }, |
| 227 | |
| 228 | // - https://www.postgresql.org/docs/current/libpq-envars.html |
| 229 | { |
| 230 | Name: "PGHOST", |
| 231 | Value: SocketDirectory, |
| 232 | }, |
| 233 | { |
| 234 | Name: "PGPORT", |
| 235 | Value: fmt.Sprint(*cluster.Spec.Port), |
| 236 | }, |
| 237 | // Setting the KRB5_CONFIG for kerberos |
| 238 | // - https://web.mit.edu/kerberos/krb5-current/doc/admin/conf_files/krb5_conf.html |
| 239 | { |
| 240 | Name: "KRB5_CONFIG", |
| 241 | Value: configMountPath + "/krb5.conf", |
| 242 | }, |
| 243 | // In testing it was determined that we need to set this env var for the replay cache |
| 244 | // otherwise it defaults to the read-only location `/var/tmp/` |
| 245 | // - https://web.mit.edu/kerberos/krb5-current/doc/basic/rcache_def.html#replay-cache-types |
| 246 | { |
| 247 | Name: "KRB5RCACHEDIR", |
| 248 | Value: "/tmp", |
| 249 | }, |
| 250 | // This allows a custom CA certificate to be mounted for Postgres LDAP |
| 251 | // authentication via spec.config.files. |
| 252 | // - https://wiki.postgresql.org/wiki/LDAP_Authentication_against_AD |
| 253 | // |
| 254 | // When setting the TLS_CACERT for LDAP as an environment variable, 'LDAP' |
| 255 | // must be appended as a prefix. |
| 256 | // - https://www.openldap.org/software/man.cgi?query=ldap.conf |
| 257 | // |
| 258 | // Testing with LDAPTLS_CACERTDIR did not work as expected during testing. |
| 259 | { |
| 260 | Name: "LDAPTLS_CACERT", |
| 261 | Value: configMountPath + "/ldap/ca.crt", |
| 262 | }, |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | // ShellPath returns a POSIX shell command that prepends typical Postgres executable paths to the PATH variable. |
| 267 | func ShellPath(postgresVersion int32) string { |
no test coverage detected