Pod volumes lifespan

1 view
Skip to first unread message

Carlos Sanchez

unread,
Oct 11, 2014, 6:20:23 AM10/11/14
to google-c...@googlegroups.com

From Brendan's Kubernetes 101 https://github.com/GoogleCloudPlatform/kubernetes/blob/master/examples/walkthrough/README.md

In Kubernetes, emptyDir Volumes live for the lifespan of the Pod, which is longer than the lifespan of any one container, so if the container fails and is restarted, our persistent storage will live on.

So if I understood correctly, a container started after the one gets killed (with docker kill) or exits (like example below) should have access to the data of the previous one? 
I tried with this example and didn't work, docker logs shows just one line in any container, not having the file created by the previous container in the volume

{
  "id": "test",
  "kind": "Pod",
  "apiVersion": "v1beta1",
  "desiredState": {
    "manifest": {
      "version": "v1beta1",
      "id": "test",
      "containers": [
        {
          "name": "test",
          "image": "busybox",
          "command": ["sh", "-c", "date >> /home/default/date && tail -n 100 /home/default/date && sleep 60"],
          "volumeMounts": [
            {
              "name": "data",
              "mountPath": "/home/default"
            }
          ]
        }
      ],
      "volumes": [
        {
          "name": "data"
        }
      ]
    }
  }
}


CONTAINER ID        IMAGE                     COMMAND                CREATED              STATUS                          PORTS                    NAMES
b7e8e052f073        busybox:latest            "sh -c 'date >> /hom   1 seconds ago        Up Less than a second                                    k8s_test.25b0a5e9_test.etcd_4a714585-512f-11e4-b8e8-0800279696e1_1fecd8d5
b2dccc7370aa        busybox:latest            "sh -c 'date >> /hom   About a minute ago   Exited (0) 9 seconds ago                                 k8s_test.25b0a5e9_test.etcd_4a714585-512f-11e4-b8e8-0800279696e1_38f6c4d5
2d6b38c26caa        busybox:latest            "sh -c 'date >> /hom   2 minutes ago        Exited (0) About a minute ago                            k8s_test.25b0a5e9_test.etcd_4a714585-512f-11e4-b8e8-0800279696e1_83e70e2a
6b44ef0d31fc        busybox:latest            "sh -c 'date >> /hom   3 minutes ago        Exited (0) 2 minutes ago                                 k8s_test.25b0a5e9_test.etcd_4a714585-512f-11e4-b8e8-0800279696e1_c30675dd
d25f6668498f        kubernetes/pause:latest   "/pause"               3 minutes ago        Up 3 minutes                                             k8s_net.fadb6b63_test.etcd_4a714585-512f-11e4-b8e8-0800279696e1_070566b2
909094f4d0f0        google/cadvisor:latest    "/usr/bin/cadvisor /   49 minutes ago       Up 49 minutes                                            k8s_cadvisor.417cd83c_cadvisor-agent.file_0d840555
811d45e7f394        kubernetes/pause:latest   "/pause"               50 minutes ago       Up 50 minutes                   0.0.0.0:4194->8080/tcp   k8s_net.f72d85c8_cadvisor-agent.file_3ee78be2
[vagrant@kubernetes-minion-1 ~]$ docker logs b7e8e052f073
Sat Oct 11 10:17:33 UTC 2014
[vagrant@kubernetes-minion-1 ~]$


Joe Beda

unread,
Oct 11, 2014, 11:29:15 AM10/11/14
to google-c...@googlegroups.com, Dawn Chen
Dawn,  it looks like you are operating in this area most recently.  Do you mind looking at this?

This looks like a great test and I would expect it to work.

Joe

--
You received this message because you are subscribed to the Google Groups "Containers at Google" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-contain...@googlegroups.com.
To post to this group, send email to google-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-containers.
For more options, visit https://groups.google.com/d/optout.

Tim Hockin

unread,
Oct 11, 2014, 11:32:33 PM10/11/14
to google-c...@googlegroups.com, Dawn Chen

Is this the same bug wherein the non-specified volume type was no longer defaulting to emptydir?

Carlos: try defining your volume with source: emptyDir {}

Brendan Burns

unread,
Oct 12, 2014, 1:04:03 AM10/12/14
to google-c...@googlegroups.com, Dawn Chen
This should definitely work the way you suggest.  If it doesn't it's a bug (we should probably add some sort of e2e test for this...)

--brendan

Carlos Sanchez

unread,
Oct 12, 2014, 5:46:28 AM10/12/14
to google-c...@googlegroups.com, dawn...@google.com
Adding emptyDir works, and I've just tried with the latest build 56726 and it works without emptyDir

Seems it was just fixed a couple days ago in https://github.com/GoogleCloudPlatform/kubernetes/issues/1683
Reply all
Reply to author
Forward
0 new messages