Configure a Pod to Use a Volume for Storage
Last updated
Was this helpful?
Last updated
Was this helpful?
In this exercise, you create a Pod that runs one Container. This Pod has a Volume of type that lasts for the life of the Pod, even if the Container terminates and restarts. Here is the configuration file for the Pod:
Create the Pod:
Verify that the Pod’s Container is running, and then watch for changes to the Pod:
The output looks like this:
In another terminal, get a shell to the running Container:
In your shell, go to /data/redis
, and then create a file:
In your shell, list the running processes:
The output is similar to this:
In your shell, kill the Redis process:
where <pid>
is the Redis process ID (PID).
In your original terminal, watch for changes to the Redis Pod. Eventually, you will see something like this:
Get a shell into the restarted Container:
In your shell, goto /data/redis
, and verify that test-file
is still there.
Delete the Pod that you created for this exercise:
emptyDir 是一種在pod達立的時候便會出現的儲存點,就如其名,它剛開始時空白沒有任何東西。Pod中的所有Container都能夠讀寫內裡的檔案,所以emptyDir有以下用途:
暫存空間
Container的共用空間
At this point, the Container has terminated and restarted. This is because the Redis Pod has a of Always
.