定期的に遭遇するけどなんで発生してるか忘れるので備忘録
この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のコマンドを実行する際に引数をどう渡すかによって結果が変わるという話だった。詳しくはだいぶ前に調べたんだが忘れてしまったので思い出したら書く。