我正在我的 kubernetes 集群上使用 terraform 安装 postgresql。
我正在使用 bitnami https://artifacthub.io/packages/helm/bitnami/postgresql/11.6.19 这个图表。
我的地形资源如下所示
resource "helm_release" "postgres" {
chart = "postgresql"
name = "postgresql-postgresql"
version = "11.6.19"
timeout = 600
repository = "https://charts.bitnami.com/bitnami"
namespace = "default"
values = [
file("${path.module}/postgresql-persistence/values.yaml")
]
}
我使用 values.yaml 文件覆盖一些设置,如下所示。
primary:
extendedConfiguration: |
max_connections = 400
initdb:
scripts:
my_init_script.sql: |
CREATE DATABASE iam;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO sales;
但是当我运行这个时,我在控制台中收到以下错误。
rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: namespace: default, name: postgresql-postgresql-extended-configuration, existing_kind: /v1, Kind=ConfigMap, new_kind: /v1, Kind=ConfigMap
有人可以告诉我如何使用 terraform 和 bitnami 图表设置 max_connection 吗?
谢谢
您可以尝试以下方法
您已经创建了 postgresql-postgresql-extended-configuration configMap。
将以下内容添加到您的值中。YAML
extendedConfiguration: |
max_connections = 400
它将尝试使用相同的 postgresql-postgresql-extend-configuration
创建一个新的 configMap您可以列出所有配置映射并删除postgresql-postgresql-extended-configuration
kubectl get configmap -n kubernetes-namespace
kubectl delete configmap config-map-name -n kubernetes-namespace
在您的情况下,配置映射名称是 postgresql-postgresql-extended-configuration
尝试重新安装这对我有用
我遇到了同样的问题,发现here在版本11.0.0中postgresqlMaxConnections被标记为已弃用。
值文件中的此设置对我有帮助:
postgresql:
primary:
extraEnvVars:
- name: POSTGRESQL_MAX_CONNECTIONS
value: "400"
当我查看容器时,我看到:
kubectl exec -it postgresql -- /bin/bash
psql -d mydb -U myuser
mydb=> show max_connections;
max_connections
-----------------
400
(1 row)