1

i,m trying to create a persistent Ubuntu Kubernetes deployment
my idea was to mount the entire Ubuntu pod file system to a persistent volume
here is what i tried

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ubuntu
  labels:
    app: ubuntu
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ubuntu
  template:
    metadata:
      labels:
        app: ubuntu
    spec:
      containers:
        - name: ubuntu
          image: ubuntu:latest
          imagePullPolicy: IfNotPresent
          volumeMounts:
           - mountPath: "/"
             name: task-pv-storage
      volumes:
        - name: task-pv-storage
          persistentVolumeClaim:
           claimName: task-pv-claim

but i get the following error

command : kubectl describe pod [Ubuntu-pod]  

output:

Error: Error response from daemon: invalid bind mount spec "/home/moses/test:/:rslave": invalid volume specification: '/home/moses/test:/:rslave': invalid mount config for type "bind": invalid specification: destination can't be '/'  

any ideas on how to achieve this?

moses
  • 83
  • 1
  • 12
  • Why do you want to mount the volume as root? – Nick Rak May 16 '18 at 13:28
  • because i want to save the entire file system of pod to my persistent volume so any changes in pod's file system will be persistent not just one directory – moses May 17 '18 at 06:31

1 Answers1

0

You chose the wrong engine for your task. The best option for you is to use a VM (Virtual Machine). It’s impossible to mount volume as '/'.

Nick Rak
  • 167
  • 7