Iscsi 作为持久存储 statefulset kubernetes

问题描述

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

解决方法

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

您没有提到您将使用哪个 cloud provider,但仍然分享一个注意iscsi storage 未在 GKE cotnainer OS 运行时进行优化K8s 节点,因此如果您不是 GCP GKE 更改操作系统或建议先使用 Ubuntu 映像。

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

您也可以使用 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

如果您使用 AWSiscsi EBS 上。 对于测试,您还可以结帐

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

几个链接: