Моя цель - запустить postgres на миникубе, где /var/lib/postgresql/data
смонтировано с моего ноутбука. Я следил за многими сообщениями о том, как туда добраться, но пока не получилось, самое близкое, что я получил, это здесь:
Сначала я подключаю свой локальный /data/
к мини-кубу и подтверждаю, что - в моем понимании /data
имеет права root, поэтому мне нужно было сделать sudo mkdir -p /data/postgres-pv
и sudo cp -R <source_path>/data/* /data/postgres-pv
для копирования данных туда.
Мой PV:
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv
namespace: demo
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/postgres-pv
Для отладки я смог запуститьПод модулем busybox и убедитесь, что я вижу правильные данные, мне надоело добавлять файлы на моем ноутбуке по адресу / data / postgres-pv и мгновенно видеть их по пути монтирования busybox, используя следующее утверждение:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-pvc
namespace: demo
labels:
type: local
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
volumeName: postgres-pv
busybox, который я использовал для отладки:
kind: Pod
apiVersion: v1
metadata:
name: busybox
namespace: demo
spec:
containers:
- name: busybox
image: busybox
command:
- sleep
- "3600"
volumeMounts:
- mountPath: "/data"
name: postgres-pvc
volumes:
- name: postgres-pvc
persistentVolumeClaim:
claimName: postgres-pvc
Когда я пытаюсь загрузить ту же самую папку с моего локального ноутбука в модуль, работающий с postgres и переопределить /var/lib/postgresql/data
Я получаю сообщение об ошибке, я пробовал различные варианты следующего, включая переменные subPath и PGDATA, как это снова видно во многих сообщениях (пример здесь )
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: admindb
namespace: demo # should be replaced
spec:
template:
metadata:
labels:
app: admindb
spec:
containers:
- name: postgres
image: postgres:9.6.5
ports:
- containerPort: 5432
env:
# - name: POSTGRES_DB
# valueFrom:
# secretKeyRef:
# name: admindb-secret-config
# key: dbname
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-credentials
key: user
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-credentials
key: password
# - name: PGDATA # overriding the default mount so we can load our own data from PVC
# value: /var/lib/postgresql/data/pgdata/
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-pvc
# subPath: pgdata
volumes:
- name: postgres-pvc
persistentVolumeClaim:
claimName: postgres-pvc
Ошибка, которую я получаю при проверке журнала:
+ kubectl logs -n demo admindb-546d55d9b5-ddr4f
chown: cannot read directory ‘/var/lib/postgresql/data/pg_multixact’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/pgdata/pgdata’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/pgdata’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_wal’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_snapshots’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_commit_ts’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_stat’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/PG_VERSION’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_stat_tmp’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/pg_hba.conf’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/postmaster.pid’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_logical’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_notify’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_subtrans’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_serial’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_replslot’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/postgresql.conf’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/postgres/pgdata’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/postgres’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_tblspc’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/postgresql.auto.conf’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_twophase’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_xact’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/pg_dynshmem’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/postmaster.opts’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/pg_ident.conf’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/global’: Input/output error
chown: cannot read directory ‘/var/lib/postgresql/data/base’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data’: Input/output error
если я изменю развертывание для включения
- name: PGDATA
value: /var/lib/postgresql/data/pgdata/
Затем возникает ошибка:
+ kubectl logs -n demo admindb-6dc94659dd-4kc9t
chown: changing ownership of ‘/var/lib/postgresql/data/pgdata/pgdata’: Input/output error
chown: changing ownership of ‘/var/lib/postgresql/data/pgdata/’: Input/output error
Уверен, я чувствую, что я иду по кругу между разными сообщениями, упуская что-то фундаментальное в процессе, любую помощь или точку вправильное направление очень ценится - чувствую, что мне нужно изменить одну или две строки в моем развертывании, и это сработает! или измените разрешение на моем ноутбуке.