[英]Can we create Multiple databases in Same Persistent Volume in kubernetes ?
status=ContainerCreating
.status=ContainerCreating
。VM
only Supports data-disks
.VM
只支持data-disks
。 So i thought why not use PVC
of earlier deployment in current service like:所以我想为什么不在当前服务中使用早期部署的
PVC
,例如:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: third-postgres
labels:
name: third-postgres
spec:
replicas: 1
template:
metadata:
labels:
name: third-postgres
spec:
containers:
- name: third-postgres
image: postgres
env:
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: POSTGRES_USER
value: third-user
- name: POSTGRES_PASSWORD
value: <password>
- name: POSTGRES_DB
value: third_service_db
ports:
- containerPort: 5432
volumeMounts:
- name: third-postgresdata
mountPath: /var/lib/postgresql/data
volumes:
- name: third-postgresdata
persistentVolumeClaim:
claimName: <second-postgres-data>
third_service_db
third_service_db
PVC
was already exists so it skips the Db create part ?PVC
已经存在所以它跳过了 Db 创建部分?PVC
for my all services and same PVC
can have multiple databases.PVC
,并且相同的PVC
可以有多个数据库。 So that when I run kubectl create -f <path-to-thirst-postgres.yaml>
it takes name Database configuration from env Variables and create DB in same PVC
kubectl create -f <path-to-thirst-postgres.yaml>
它从环境变量中获取名称数据库配置并在同一个PVC
创建数据库 You have to create one PVC per Deployment. 您必须为每个部署创建一个PVC。 Once a PVC has been claimed , it must be released before it can be used again.
一旦PVC一直声称 ,它必须被释放后才能再次使用。
In the case of AzureDisk, the auto-created volumes can only be mounted by a single node ( ReadWriteOnce access mode) so there's one more constraint: each of your Deployments can have at most 1 replica. 对于AzureDisk,自动创建的卷只能由单个节点( ReadWriteOnce访问模式)安装,因此还有一个约束:每个部署最多只能有1个副本。
Yes you can create as much databas as you want on the same Persistent Volume.是的,您可以在同一个 Persistent Volume 上创建任意数量的数据库。 You have to change the
path
value to store different database.您必须更改
path
值以存储不同的数据库。 See the example below.请参阅下面的示例。
apiVersion: v1
kind: PersistentVolume
metadata:
name: ...
namespace: ...
labels:
type: ...
spec:
storageClassName: ...
capacity:
storage: ...
accessModes:
- ...
hostPath:
path: "/mnt/data/DIFFERENT_PATH_FOR_EACH_DATABASE"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.