$ kubectl logs date-tail -c tail -f --tail=10
Start at: Tue Dec 4 16:27:55 UTC 2018
Tue Dec 4 16:27:56 UTC 2018
Tue Dec 4 16:27:57 UTC 2018
Tue Dec 4 16:27:58 UTC 2018
Tue Dec 4 16:27:59 UTC 2018
Tue Dec 4 16:28:00 UTC 2018
Tue Dec 4 16:28:01 UTC 2018
Tue Dec 4 16:28:02 UTC 2018
Tue Dec 4 16:28:03 UTC 2018
Tue Dec 4 16:28:04 UTC 2018
Tue Dec 4 16:28:05 UTC 2018
Tue Dec 4 16:28:06 UTC 2018
^C⏎
この様にファイルに追記されている。Volumeでデータが共有できていることが確認できる。
このコンテナを削除して再作成し、logsでファイルが永続化されているか確認してみる。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ kubectl replace --force -f date-tail.yaml
pod "date-tail" deleted
pod/date-tail replaced
$ kubectl logs date-tail -c tail -f
Start at: Tue Dec 4 16:29:39 UTC 2018
Tue Dec 4 16:29:40 UTC 2018
Tue Dec 4 16:29:41 UTC 2018
Tue Dec 4 16:29:42 UTC 2018
Tue Dec 4 16:29:43 UTC 2018
Tue Dec 4 16:29:44 UTC 2018
Tue Dec 4 16:29:45 UTC 2018
Tue Dec 4 16:29:46 UTC 2018
Tue Dec 4 16:29:47 UTC 2018
Tue Dec 4 16:29:48 UTC 2018
Tue Dec 4 16:29:49 UTC 2018
Tue Dec 4 16:29:50 UTC 2018
^C⏎
$ kubectl logs date-tail -c tail
Start at: Tue Dec 4 16:48:07 UTC 2018
Tue Dec 4 16:48:08 UTC 2018
Tue Dec 4 16:48:09 UTC 2018
Tue Dec 4 16:48:10 UTC 2018
Tue Dec 4 16:48:11 UTC 2018
Tue Dec 4 16:48:12 UTC 2018
Tue Dec 4 16:48:13 UTC 2018
Tue Dec 4 16:48:14 UTC 2018
Tue Dec 4 16:48:15 UTC 2018
ここまでは今までどおり。さて、ここで再作成してみよう。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ kubectl replace --force -f date-tail.yaml
pod "date-tail" deleted
pod/date-tail replaced
$ kubectl logs date-tail -c tail
Tue Dec 4 16:48:42 UTC 2018
Tue Dec 4 16:48:43 UTC 2018
Tue Dec 4 16:48:44 UTC 2018
Tue Dec 4 16:48:45 UTC 2018
Tue Dec 4 16:48:46 UTC 2018
Tue Dec 4 16:48:47 UTC 2018
Start at: Tue Dec 4 16:48:49 UTC 2018
Tue Dec 4 16:48:50 UTC 2018
Tue Dec 4 16:48:51 UTC 2018
Tue Dec 4 16:48:52 UTC 2018
Tue Dec 4 16:48:53 UTC 2018
Tue Dec 4 16:48:54 UTC 2018