Kubernetes 持久卷在自己的机架上



我将 kubernetes 从 Google GKE 转移到 Own in house rack。我应该使用什么持久存储?

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

我已经看到了很多选择:- https://kubernetes.io/docs/concepts/storage/persistent-volumes/#types-of-persistent-volumes

不知道我应该选择什么。GKE部署文件会解决问题吗?

在 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
    

    您可以通过链接查看有关使用 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
    

    您可以通过链接查看有关使用GlusterFS的更多信息。

可以在此处找到有关持久卷和持久卷声明的详细信息。

相关内容

最新更新