节点上的StatefulSet副本具有共享内存

问题描述

我正在尝试在三个Kubernetes工作节点(基于此IPFS)上部署repo个有状态副本集。前三个副本可以正常工作,但是当涉及到第四个副本时,persistentVolumeClaims似乎指向共享的物理内存。因此,第四节点无法获取锁。在Kubernetes中部署许多IPFS副本的标准方法是什么?

第四个节点打印了以下日志:

08:44:19.785 DEBUG   cmd/ipfs: config path is /data/ipfs main.go:257
08:44:19.785  INFO   cmd/ipfs: IPFS_PATH /data/ipfs main.go:301
08:44:19.785 DEBUG   cmd/ipfs: Command cannot run on daemon. Checking if daemon is locked main.go:434
08:44:19.785 DEBUG       lock: Checking lock lock.go:32
08:44:19.785 DEBUG       lock: Can't lock file: /data/ipfs/repo.lock.
 reason: cannot acquire lock: Lock FcntlFlock of /data/ipfs/repo.lock Failed: resource temporarily unavailable lock.go:44
08:44:19.785 DEBUG     fsrepo: (true)<->Lock is held at /data/ipfs fsrepo.go:302
Error: ipfs daemon is running. please stop it to run this command
Use 'ipfs daemon --help' for information about this command

这是有状态集的yaml文件


apiVersion: apps/v1
kind: StatefulSet
Metadata:
  name: ipfs
  namespace: ipfs
spec:
  selector:
    matchLabels:
      app: ipfs
  serviceName: ipfs
  replicas: 6
  template:
    Metadata:
      labels:
        app: ipfs
    spec:
      initContainers:
      - name: init-repo
        image: ipfs/go-ipfs:v0.4.11@sha256:e977e1560b960933061efc694c937d711ce1a51aa4a5239acfdff01504b11054
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldpath: spec.nodeName
        command: ['/bin/sh','/etc/ipfs-config/init.sh']
        volumeMounts:
        - name: www
          mountPath: /data/ipfs
        - name: secrets
          mountPath: /etc/ipfs-secrets
        - name: config
          mountPath: /etc/ipfs-config
      - name: init-peers
        image: ipfs/go-ipfs:v0.4.11@sha256:e977e1560b960933061efc694c937d711ce1a51aa4a5239acfdff01504b11054
        command: ['/bin/sh','/etc/ipfs-config/peers-kubernetes-refresh.sh']
        volumeMounts:
        - name: www
          mountPath: /data/ipfs
        - name: config
          mountPath: /etc/ipfs-config
      containers:
      - name: ipfs
        image: ipfs/go-ipfs:v0.4.11@sha256:e977e1560b960933061efc694c937d711ce1a51aa4a5239acfdff01504b11054
        env:
        - name: IPFS_LOGGING
          value: debug
        command:
        - ipfs
        - daemon
        ports:
        - containerPort: 4001
          name: swarm
        - containerPort: 5001
          name: api
        - containerPort: 8080
          name: readonly
        volumeMounts:
        - name: www
          mountPath: /data/ipfs
      volumes:
      - name: secrets
        secret:
          secretName: ipfs
      - name: config
        configMap:
          name: ipfs-config
      - name: www
        persistentVolumeClaim:
          claimName: ipfs-pvc

这是持久卷的定义

apiVersion: v1
kind: PersistentVolume
Metadata:
  name: ipfs-pv
  namespace: ipfs
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 200Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"

持久卷声明定义:

vapiVersion: v1
kind: PersistentVolumeClaim
Metadata:
  name: ipfs-pvc
  namespace: ipfs
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 200Mi
发生故障的节点的

kubectl describe如下:

Name:         ipfs-3
Namespace:    ipfs
Priority:     0
Node:         swift-153/10.70.20.153
Start Time:   Tue,27 Oct 2020 14:38:11 -0400
Labels:       app=ipfs
              controller-revision-hash=ipfs-74bb88dbb6
              statefulset.kubernetes.io/pod-name=ipfs-3
Annotations:  <none>
Status:       Running
IP:           10.244.3.43
IPs:
  IP:           10.244.3.43
Controlled By:  StatefulSet/ipfs
Containers:
  ipfs:
    Container ID:  docker://81349e969be9ffcafeb4d65adf9d0b2de7311e46068e36dd4f227f169f6dfcab
    Image:         ipfs/go-ipfs:v0.4.11@sha256:e977e1560b960933061efc694c937d711ce1a51aa4a5239acfdff01504b11054
    Image ID:      docker-pullable://ipfs/go-ipfs@sha256:e977e1560b960933061efc694c937d711ce1a51aa4a5239acfdff01504b11054
    Ports:         4001/TCP,5001/TCP,8080/TCP
    Host Ports:    0/TCP,0/TCP,0/TCP
    Command:
      ipfs
      daemon
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Tue,27 Oct 2020 14:39:51 -0400
      Finished:     Tue,27 Oct 2020 14:39:51 -0400
    Ready:          False
    Restart Count:  4
    Environment:
      IPFS_LOGGING:  debug
    Mounts:
      /data/ipfs from www (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-hb785 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  secrets:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  ipfs
    Optional:    false
  config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      ipfs-config
    Optional:  false
  www:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  ipfs-pvc
    ReadOnly:   false
  default-token-hb785:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-hb785
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age                    From               Message
  ----     ------            ----                   ----               -------
  normal   Scheduled         2m24s                  default-scheduler  Successfully assigned ipfs/ipfs-3 to swift-153
  normal   Pulled            2m2s (x3 over 2m21s)   kubelet            Container image "ipfs/go-ipfs:v0.4.11@sha256:e977e1560b960933061efc694c937d711ce1a51aa4a5239acfdff01504b11054" already present on machine
  normal   Created           2m (x3 over 2m19s)     kubelet            Created container ipfs
  normal   Started           2m (x3 over 2m19s)     kubelet            Started container ipfs
  Warning  DNSConfigForming  103s (x10 over 2m24s)  kubelet            Search Line limits were exceeded,some search paths have been omitted,the applied search line is: ipfs.svc.cluster.local svc.cluster.local cluster.local search syslab.sandBox cs.toronto.edu
  Warning  BackOff           103s (x6 over 2m15s)   kubelet            Back-off restarting Failed container

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...