« Kubernetesテストベンチへの道 寄り道メモ | トップページ | Kubernetesテストベンチへの道 その3 pv作成テスト »

2020年8月13日 (木)

Kubernetesテストベンチへの道 その2 subnet.envの件

後からメモ:

これはkubeadm init で--pod-network-cidrを指定していなかったこととkube-flannel.ymlの編集を間違えていたことに起因していたと判明。内部エラーからsubnet.envが出力できなかったのだと思う。

早速はまった。
podをrunさせようにもCreatingContainerから先に進まない。

[root@master ~]# kubectl run nginx --image=nginx:1.11.3
pod/nginx created

[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 0/1 ContainerCreating 0 8s

podの状態を見てみる。
[root@master ~]# kubectl describe pod nginx
Name: nginx
Namespace: default
Priority: 0
Node: worker1/192.168.1.132
Start Time: Thu, 13 Aug 2020 16:45:28 +0900
Labels: run=nginx
Annotations: <none>
Status: Pending
IP:
IPs: <none>
Containers:
nginx:
Container ID:
Image: nginx:1.11.3
Image ID:
Port: <none>
Host Port: <none>
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-5ptbc (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-5ptbc:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-5ptbc
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 18s default-scheduler Successfully assigned default/nginx to worker1
Warning FailedCreatePodSandBox 18s kubelet, worker1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "99d3c9e5f10d685372b5d36a17ee032520bbf0d712fd416cf08ea8e4700fba2d" network for pod "nginx": networkPlugin cni failed to set up pod "nginx_default" network: open /run/flannel/subnet.env: no such file or directory

中略(同じメッセージの繰り返しなので)

Warning FailedCreatePodSandBox 10s kubelet, worker1 Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "cda26db8d28e9f46b2abf7c1a65e0222b807d7126470de78cc7b8888e6046a6a" network for pod "nginx": networkPlugin cni failed to set up pod "nginx_default" network: open /run/flannel/subnet.env: no such file or directory
Normal SandboxChanged 6s (x12 over 17s) kubelet, worker1 Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 6s (x4 over 9s) kubelet, worker1 (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "2fc4739b4f2e5c105529507eecee1a71730f63abf87f2e66646f9b4b0b568c72" network for pod "nginx": networkPlugin cni failed to set up pod "nginx_default" network: open /run/flannel/subnet.env: no such file or directory

どうも/run/flannel/subnet.envが無いからネットワークが構成できないといっているようだ。インターネットで調べてみると同じ問題に直面した諸先輩はマニュアルで以下ファイルを作って解決しているようだ。ちなみに私はkubeadm initでDefaultのネットワーク設定にしているので以下を10.96.0.0を設定している。

[root@master ~]# cat /run/flannel/subnet.env
FLANNEL_NETWORK=10.96.0.0/12
FLANNEL_SUBNET=10.96.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
[root@master ~]#

このファイルをMasterに作ったのだが(Masterになかったから)それでは解決しなかった。で、worker1にも同じファイルを作った。それで再実行。

[root@master ~]# kubectl delete pod nginx
pod "nginx" deleted
[root@master ~]# kubectl run nginx --image=nginx:1.11.3
pod/nginx created
[root@master ~]# kubectl describe pod nginx
Name: nginx
Namespace: default
Priority: 0
Node: worker1/192.168.1.132
Start Time: Thu, 13 Aug 2020 16:55:01 +0900
Labels: run=nginx
Annotations: <none>
Status: Running
IP: 10.96.0.3
IPs:
IP: 10.96.0.3
Containers:
nginx:
Container ID: docker://86bb0488af803a07157501380a262204ee3c4d2011de704b360dece11cd3d14f
Image: nginx:1.11.3
Image ID: docker-pullable://docker.io/nginx@sha256:d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6
Port: <none>
Host Port: <none>
State: Running
Started: Thu, 13 Aug 2020 16:55:01 +0900
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-5ptbc (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-5ptbc:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-5ptbc
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 4s default-scheduler Successfully assigned default/nginx to worker1
Normal Pulled 4s kubelet, worker1 Container image "nginx:1.11.3" already present on machine
Normal Created 4s kubelet, worker1 Created container nginx
Normal Started 4s kubelet, worker1 Started container nginx
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 19s
[root@master ~]#

無事podがRunningになった。StatusにあるIPアドレスでアクセスすると確かにnginxが動いている。

Welcomenginx

しかし、一体これはなんなのか。。。。

なお参考にさせていただいたのは以下のURL:
参考URL

 

« Kubernetesテストベンチへの道 寄り道メモ | トップページ | Kubernetesテストベンチへの道 その3 pv作成テスト »

ソフトウエア導入」カテゴリの記事

コメント

コメントを書く

(ウェブ上には掲載しません)

« Kubernetesテストベンチへの道 寄り道メモ | トップページ | Kubernetesテストベンチへの道 その3 pv作成テスト »