Kubernetes自有机架上的持久音量

问题描述 投票:2回答:1

我将kubernetes从谷歌GKE转移到内部机架。我应该使用什么持久存储?

Kubernetes Local Persistent在2018年4月13日成为beta版,只有https://kubernetes.io/blog/2018/04/13/local-persistent-volumes-beta/

我见过很多选择: - https://kubernetes.io/docs/concepts/storage/persistent-volumes/#types-of-persistent-volumes

不确定我应该选择什么。使用GKE部署文件可以解决问题吗?

kubernetes block-storage
1个回答
3
投票

在GKE的部署文件中,您需要根据持久卷设置更改spec.volumes设置。

我建议您选择以下选项之一:

  1. 最简单的方法是使用HostPath。它将文件或目录从主机节点的文件系统安装到Pod中。请注意,在这种情况下,如果没有其他配置,则无法从另一个节点访问一个节点上的数据。 Kubernetes中的使用示例: apiVersion: v1 kind: Pod metadata: name: test-pd spec: containers: - image: k8s.gcr.io/test-webserver name: test-container volumeMounts: - mountPath: /test-pd name: test-volume volumes: - name: test-volume hostPath: # directory location on host path: /data # this field is optional type: Directory
  2. 你可以使用NFS。您需要配置NFS服务器,然后可以通过持久卷声明在“部署”中使用其卷。 Kubernetes中的使用示例: apiVersion: v1 kind: Deployment metadata: name: nfs-busybox spec: replicas: 2 selector: name: nfs-busybox template: metadata: labels: name: nfs-busybox spec: containers: - image: busybox command: - sh - -c - 'while true; do date > /mnt/index.html; hostname >> /mnt/index.html; sleep $(($RANDOM % 5 + 5)); done' imagePullPolicy: IfNotPresent name: busybox volumeMounts: # name must match the volume name below - name: nfs mountPath: "/mnt" volumes: - name: nfs persistentVolumeClaim: claimName: nfs 您可以查看link以获取有关使用NFS的更多信息。
  3. 你可以使用GlusterFS。您需要配置自己的GlusterFS安装,然后可以在“部署”中使用其卷。 Kubernetes中的使用示例: apiVersion: v1 kind: Deployment metadata: name: nfs-busybox spec: replicas: 2 selector: name: nfs-busybox template: metadata: labels: name: nfs-busybox spec: containers: - image: busybox command: - sh - -c - 'while true; do date > /mnt/index.html; hostname >> /mnt/index.html; sleep $(($RANDOM % 5 + 5)); done' imagePullPolicy: IfNotPresent name: busybox volumeMounts: # name must match the volume name below - name: nfs mountPath: "/mnt" volumes: - name: glusterfsvol glusterfs: endpoints: glusterfs-cluster path: kube_vol readOnly: true 您可以查看link以获取有关使用GlusterFS的更多信息。

您可以找到有关持久性卷和持久性卷索赔here的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.