7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

KubernetesでボリュームをマウントしているのにNo such file or directoryになるやつ

7
Last updated at Posted at 2020-01-07

定期的に遭遇するけどなんで発生してるか忘れるので備忘録

このYAMLをデプロイするとPodのデプロイに失敗する。なぜだろうか。

hoge.yaml
apiVersion: v1
kind: Pod
metadata:
  name: init-demo
spec:
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
    - name: workdir
      mountPath: /usr/share/nginx/html
  initContainers:
  - name: install
    image: busybox
    command:
    - "wget -O /work-dir/index.html http://kubernetes.io"
    volumeMounts:
    - name: workdir
      mountPath: "/work-dir"
  volumes:
  - name: workdir
    emptyDir: {}
  dnsPolicy: Default

以下のようにすると動くようになる

fuga.yaml

apiVersion: v1
kind: Pod
metadata:
  name: init-demo
spec:
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
    - name: workdir
      mountPath: /usr/share/nginx/html
  initContainers:
  - name: install
    image: busybox
    command:
    - wget
    - "-O"
    - "/work-dir/index.html"
    - http://kubernetes.io
    volumeMounts:
    - name: workdir
      mountPath: "/work-dir"
  volumes:
  - name: workdir
    emptyDir: {}
  dnsPolicy: Default

diffをとってみるとこうだ。

- 				"wget",
+ 				"wget -O /work-dir/index.html http://kubernetes.io",
- 				"-O",
- 				"/work-dir/index.html",
- 				"http://kubernetes.io",

Linuxのコマンドを実行する際に引数をどう渡すかによって結果が変わるという話だった。詳しくはだいぶ前に調べたんだが忘れてしまったので思い出したら書く。

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?