[英]mount azure disk to azure Kubernetes for PostgreSQL pod
I want mount azure disk to azure Kubernetes for PostgreSQL pod.我想将 azure 磁盘安装到 azure Kubernetes 以用于 Z399BD1EE5872458EAC6F39BEAA99。 My yml files
我的 yml 文件
postgres-storage.yaml postgres-storage.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-pv
spec:
capacity:
storage: 80Gi
storageClassName: manual
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
azureDisk:
kind: Managed
diskName: es-us-dev-core-test
diskURI: /subscriptions/id/resourceGroups/kubernetes_resources_group/providers/Microsoft.Compute/disks/dev-test
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 80Gi
postgres-configmap.yaml postgres-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
data:
POSTGRES_DB: dev-test
POSTGRES_USER: admintpost
POSTGRES_PASSWORD: ada3dassasa
StatefulSet.yml StatefulSet.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres-statefulset
labels:
app: postgres
spec:
serviceName: "postgres"
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:12
envFrom:
- configMapRef:
name: postgres-config
ports:
- containerPort: 5432
name: postgresdb
volumeMounts:
- name: pv-data
mountPath: /var/lib/postgresql/data
volumes:
- name: pv-data
persistentVolumeClaim:
claimName: postgres-pv-claim
Instruction for create disk https://docs.microsoft.com/en-us/azure/aks/azure-disk-volume创建磁盘说明https://docs.microsoft.com/en-us/azure/aks/azure-disk-volume
I get an error that it cannot connect to the disk, could you please tell me how to add Azure Disk to the pod.Thanks.我收到无法连接到磁盘的错误,请告诉我如何将 Azure 磁盘添加到 pod。谢谢。
Looking at the file postgres-storage.yaml
:查看文件
postgres-storage.yaml
:
in spec.azureDisk.diskURI
I see that you have created the disk in the resource group kubernetes_resources_group
.在
spec.azureDisk.diskURI
我看到你已经在资源组kubernetes_resources_group
中创建了磁盘。 However, you should create the disk inside a resource group whose name is something like this: MC_kubernetes_resources_group_<your cluster name>_<region of the cluster>
但是,您应该在名称如下的资源组内创建磁盘:
MC_kubernetes_resources_group_<your cluster name>_<region of the cluster>
Make sure that you create the disk in the same availability zone as your cluster .确保在与集群相同的可用区中创建磁盘。
In the file postgres-storage.yaml
:在文件
postgres-storage.yaml
:
set spec.azureDisk.cachingMode
to None
将
spec.azureDisk.cachingMode
设置为None
StatefulSet.yml
StatefulSet.yml
的定义If you're using Azure Disks then in the file StatefulSet.yml
:如果您使用的是 Azure 磁盘,则在文件
StatefulSet.yml
中:
in spec.template.spec
you should replace the following:在
spec.template.spec
你应该替换以下内容:
volumeMounts:
- name: pv-data
mountPath: /var/lib/postgresql/data
with the this:有了这个:
volumeMounts:
- name: pv-data
mountPath: /var/lib/postgresql/data
subPath: pgdata
EDIT: fixed some mistakes in the last part.编辑:修正了最后一部分的一些错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.