【问题标题】:Iscsi as persistent storage statefulset kubernetesIscsi 作为持久存储 statefulset kubernetes
【发布时间】:2021-07-01 14:12:23
【问题描述】:

我有一个用例,其中将在几个 pod 中运行电信应用程序(每个 pod 将托管一些已配置的服务,用于为特定客户端计费),这期望服务存储状态,因此显而易见的选择是 statefulset 。 现在的问题是我需要在这些 pod 的后端使用 iscsi 作为存储,请您指出一些对此类用例的参考 - 我正在寻找用于 PV PVC 和 statefulset 的 Yaml 以及如何链接它们。这些 PV PVC 应使用 iscsi 作为存储选项。

【问题讨论】:

标签: kubernetes kubernetes-statefulset


【解决方案1】:

是的,您是对的 statefulset 是选项,但您也可以使用 deployment

您尚未提及您将使用哪个 cloud provider,但仍分享一个 注意iscsi storage 未针对运行 K8s 节点的 GKE cotnainer OS 进行优化,所以如果您不是 GCP GKE 更改操作系统或建议先使用 Ubuntu 映像。

您可以先在Ubuntu上启动iscsi服务。

您也可以使用MinioOpenEBS 作为存储选项。

如果用于 OpenEBS,请分享详细信息

创建 GCP 磁盘以作为挂载附加节点,或者您可以根据需要使用 YAML 动态配置它。

apiVersion: openebs.io/v1alpha1
kind: StoragePoolClaim
metadata:
  name: disk-pool
  annotations:
    cas.openebs.io/config: |
      - name: PoolResourceRequests
        value: |-
            memory: 2Gi
      - name: PoolResourceLimits
        value: |-
            memory: 4Gi
spec:
  name: disk-pool
  type: disk
  poolSpec:
    poolType: striped
  blockDevices:
    blockDeviceList:
- blockdevice-<Number>   
- blockdevice-<Number> 
- blockdevice-<Number>  

仓储类

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: openebs-sc-rep1
  annotations:
    openebs.io/cas-type: cstor
    cas.openebs.io/config: |
      - name: StoragePoolClaim
        value: "disk-pool"
      - name: ReplicaCount
        value: "1"
provisioner: openebs.io/provisioner-iscsi

应用程序工作负载

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: k8s.gcr.io/nginx-slim:0.8
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates: 
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi
      storageClassName: openebs-sc-rep1

如果您使用AWS EBS,请使用iscsi。 对于测试,您还可以结帐

https://cloud.ibm.com/catalog/content/minio

几个链接:

【讨论】:

  • 这种情况下我不需要创建 PV PVC 吗?在 podCreation.yaml 中创建 Pod 我在 yaml conf 下使用。这里不需要这样的映射吗? – apiVersion: v1 kind: PersistentVolume metadata: name: iscsipvName spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce iscsi: targetPortal: :3260 iqn: iqn.1987-02.com.Redhat.iscsi:TargetTest lun: 1 fsType:ext4 只读:false
  • 我在 ubuntu 上设置了 iSCSI 设备,我可以使用 iscsiadm 命令连接这些目标 lun 我想使用 statefulset 将此 iSCSI 存储用于 kubernates pod。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-09-18
  • 1970-01-01
  • 2021-04-22
  • 2019-08-11
  • 1970-01-01
  • 1970-01-01
  • 2018-07-01
相关资源
最近更新 更多