LoginSignup
13
4

More than 1 year has passed since last update.

Kubernetesでのtrouble shootingメモ

Last updated at Posted at 2019-10-07

はじめに

個人的にハマったことのメモです。
ハマって解決したことが増えていく度に追記していく予定です。

その1:「CreateContainerConfigError」

Kubernetes実践入門を使ってKubernetesの勉強をしていてCreateContainerConfigErrorでハマった時の解決方法。

$ kubectl get pods の結果が常に

NAME                               READY   STATUS                       RESTARTS   AGE
mysql-0                            0/1     CreateContainerConfigError   0          6s

となって原因は単純なtypoだったのだけど、行き着くまでに結構かかった。

kubectl describe pods とすると、以下のような内容が出力される。そこに原因が記述されている。
今回の原因は、「Error: secrets "common-env" not found」で、Secretを登録した時の名前にtypoがあり、参照する側と名前が一致していなくてエラーになっていた。
 

Name:           mysql-0
Namespace:      default
Priority:       0
Node:           minikube/10.0.2.15
Start Time:     Mon, 07 Oct 2019 11:35:16 +0900
apiVersion: v1
Labels:         app=mysql
                controller-revision-hash=mysql-855bd45454
                statefulset.kubernetes.io/pod-name=mysql-0
Annotations:    <none>
Status:         Pending
IP:             172.17.0.4
IPs:            <none>
Controlled By:  StatefulSet/mysql
Containers:
  mysql:
    Container ID:
    Image:          k8spracticalguide/mysql:5.7.22
    Image ID:
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       CreateContainerConfigError
    Ready:          False
    Restart Count:  0
    Environment Variables from:
      common-env  ConfigMap  Optional: false
      common-env  Secret     Optional: false
    Environment:  <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-qpm4q (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-qpm4q:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-qpm4q
    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  2m52s                 default-scheduler  Successfully assigned default/mysql-0 to minikube
  Normal   Pulling    2m52s                 kubelet, minikube  pulling image "k8spracticalguide/mysql:5.7.22"
  Normal   Pulled     2m41s                 kubelet, minikube  Successfully pulled image "k8spracticalguide/mysql:5.7.22"
  Warning  Failed     35s (x12 over 2m41s)  kubelet, minikube  Error: secrets "common-env" not found
  Normal   Pulled     35s (x11 over 2m40s)  kubelet, minikube  Container image "k8spracticalguide/mysql:5.7.22" already present on machine

修正した後に、kubectl get podを実行すると、

NAME      READY   STATUS    RESTARTS   AGE
mysql-0   1/1     Running   0          34m
mysql-1   1/1     Running   0          4s

となっていました。

その2:「The node was low on resource: ephemeral-storage.」

最初はちゃんと動いていたのに、途中から kubectl describe pod demo-pod-7c59fbcf45-jwwtl の結果が以下のようになる。

~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~
Events:
  Type     Reason     Age    From               Message
  ----     ------     ----   ----               -------
  Normal   Scheduled  3m6s   default-scheduler  Successfully assigned default/demo-pod-7c59fbcf45-jwwtl to ip-10-2-3-249.us-east-2.compute.internal
  Normal   Pulled     2m57s  kubelet            Container image "demo-pod:0.0.1" already present on machine
  Normal   Created    2m57s  kubelet            Created container demo-pod
  Normal   Started    2m57s  kubelet            Started container demo-pod
  Warning  Evicted    94s    kubelet            The node was low on resource: ephemeral-storage. Container demo-pod was using 16Ki, which exceeds its request of 0.
  Normal   Killing    94s    kubelet            Stopping container demo-pod

原因は単純で、このあとに追加した Pod などで大本のディスク容量がなくなってしまっているから。
minikubeDocker Desktop で実行しているならローカルディスクの空き容量を、
AWS や GCP などのクラウドを使っているなら Kubernetes に割り当てているストレージのサイズを
大きくすると解消できる。

13
4
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
13
4