Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: failed to generate container "xxx" spec: failed to generate spec: failed to mkdir "/data": mkdir /data: read-only file system #3383

Open
cyberstackover opened this issue May 15, 2024 · 1 comment
Assignees

Comments

@cyberstackover
Copy link

hello, I found a problem with an error like this in Kubernetes. this is my yaml

redisinsight.yaml

apiVersion: v1
kind: Service
metadata:
  name: redisinsight-service
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 5540
  selector:
    app: redisinsight

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redisinsight-pv-claim
  labels:
    app: redisinsight
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: standart

apiVersion: apps/v1
kind: Deployment
metadata:
  name: redisinsight
  labels:
    app: redisinsight
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: redisinsight
  template:
    metadata:
      labels:
        app: redisinsight
    spec:
      volumes:
        - name: redisinsight
          persistentVolumeClaim:
            claimName: redisinsight-pv-claim
      initContainers:
        - name: init
          image: busybox
          command:
            - "sh"
            - "-c"
            - "mkdir -p /data && chown -R 1000 /data"
          resources: {}
          volumeMounts:
            - name: redisinsight
              mountPath: /data
      containers:
        - name: redisinsight
          image: redis/redisinsight:latest
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: redisinsight
              mountPath: /data
          ports:
            - containerPort: 5540
              protocol: TCP

redisinsight-pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: redisinsight-pv
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: standart
  hostPath:
    path: "/data"

error :

Warning Failed 5m18s kubelet Error: failed to generate container "63b59189270b2d2da9498dd08c5de3de4311afc23380c15b55dff7b4eca5aa90" spec: failed to generate spec: failed to mkdir "/data": mkdir /data: read-only file system

@GnaneshKunal
Copy link
Collaborator

Hey @cyberstackover,

The reason could be that the directory mounting the /data folder doesn't have storage space, or you need more permissions. Please mount the path in locations where you have enough space and permissions.

Also, there needs to be a typo in the persistent volume definition. The storage class name should be "standard".

If you already use a cloud provider, we recommend using one of the available storage mediums. For example, you can use AWS EBS or GCE persistent disks.

AWS EBS:

# aws-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redisinsight-aws-pv
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  awsElasticBlockStore:
    volumeID: <your-volume-id>
    fsType: ext4

GCE Persistent Disks:

# gcp-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: redisinsight-gcp-pv
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  gcePersistentDisk:
    pdName: redisinsight-disk
    fsType: ext4

@GnaneshKunal GnaneshKunal self-assigned this Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants