我正在kubernetes上部署pgadmin和postgres。当我查看部署时,我看到2个部署尚未准备就绪。当我查看Pgadmin的日志时,我看到它出现错误,因为它无法连接到postgres。我使用confimap将pgadmin连接到postgres。当我查看postgres的日志时,我看到错误。
日志:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
Bus error (core dumped)
child process exited with exit code 135
initdb: removing contents of data directory "/var/lib/postgresql/data"
running bootstrap script ...
yaml文件:
#configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-configmap
data:
db_url: postgres-service
---
#postgres
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-deployment
labels:
app: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:13.3
ports:
- containerPort: 5432
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-password
---
apiVersion: v1
kind: Service
metadata:
name: postgres-service
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
---
#pgadmin
apiVersion: apps/v1
kind: Deployment
metadata:
name: pgadmin-deployment
labels:
app: pgadmin
spec:
replicas: 1
selector:
matchLabels:
app: pgadmin
template:
metadata:
labels:
app: pgadmin
spec:
containers:
- name: pgadmin
image: dpage/pgadmin4
ports:
- containerPort: 49762
env:
- name: PGADMIN_DEFAULT_EMAIL
value: email@email.com
- name: PGADMIN_DEFAULT_PASSWORD
value: password
- name: PGADMIN_LISTEN_ADDRESS
valueFrom:
configMapKeyRef:
name: postgres-configmap
key: db_url
---
apiVersion: v1
kind: Service
metadata:
name: pgadmin-service
spec:
selector:
app: pgadmin
type: LoadBalancer
ports:
- protocol: TCP
port: 49762
targetPort: 49762
nodePort: 30001
在分析了评论之后,下面的资源似乎有助于解决这个问题:
总而言之,当postgres在容器内运行时编辑/usr/share/postgresql/postgresql. conf.sample
文件可以通过将自定义postgresql.conf
放在容器内的临时文件中并在运行时覆盖默认配置来完成,如下所述。此外,使用“与kubernetes一起玩”网站保留一个虚拟切入点脚本,然后启动容器或尝试将文件复制到容器中可能会很有用。