如何在k8清单上导入外部文件



我有一个docker-compose.yml文件,它有我在导入外部文件时的配置,该文件在为Postgres、创建docker映像时安装postgis配置

这是docker文件

services:
postgres:
container_name: postgres_db
build:
context: .
dockerfile: Dockerfile-db
image: postgres
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
ports:
- "5454:5454"
networks:
- postgres

正在导入的文件被称为CCD_ 1。

FROM postgres:14.1

RUN apt-get update && apt-get  install -y postgresql-14-postgis-3  

CMD ["/usr/local/bin/docker-entrypoint.sh","postgres"]

如何在K8清单文件上执行相同的导入。这是我添加数据库的地方

spec:
serviceName: zone-service-db-service
selector:
matchLabels:
app: zone-service-db
replicas: 1
template:
metadata:
labels:
app: zone-service-db
spec:
tolerations:
- key: "podType"
operator: "Equal"
value: "isDB"
effect: "NoSchedule"
containers:
- name: postgres
image: postgres:latest
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: zone-service-db
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
resources:
requests:
memory: '256Mi'
cpu: '100m'
limits:
memory: '256Mi'
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: zone-service-pv-claim

如何在k8清单文件中导入Dockerfile-db,并在创建Postgres容器时被调用,并在docker映像中提供扩展名?感谢提供的任何帮助

我相信你收到了这个错误

ERROR:  type "geometry" does not exist

您在上面添加的文件将主要用于docker-compose,但对于Kubernetes,要让Postgress和Postgis协同工作,您必须向我们提供Postgis图像,而不是像这样的postgres图像

spec:
serviceName: zone-service-db-service
selector:
matchLabels:
app: zone-service-db
replicas: 1
template:
metadata:
labels:
app: zone-service-db
spec:
tolerations:
- key: "podType"
operator: "Equal"
value: "isDB"
effect: "NoSchedule"
containers:
- name: postgres
image: postgis/postgis:latest
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: zone-service-db
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
resources:
requests:
memory: '256Mi'
cpu: '100m'
limits:
memory: '256Mi'
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: zone-service-pv-claim

试试这个并提出建议。无需导入外部文件。

相关内容

  • 没有找到相关文章

最新更新