单实例有状态应用程序-容器CrashLoopBackOff

时间:2018-09-03 12:10:43

标签: kubernetes persistent-volumes

我正在尝试遵循针对单实例有状态应用程序的kubernetes教程:https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-application/

问题是,应用了此处列出的所有Yaml后,最终我的Pod不可用,如下所示,

kubectl get deployments

NAME                        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
mysql                       1         1         1            0           1h

kubectl get pods
NAME                                        READY     STATUS             RESTARTS   AGE
mysql-fb75876c6-tpdzc                       0/1       CrashLoopBackOff   17         1h

kubectl describe deployment mysql
Name:               mysql
Namespace:          default
CreationTimestamp:  Mon, 03 Sep 2018 10:50:22 +0000
Labels:             <none>
Annotations:        deployment.kubernetes.io/revision=1
Selector:           app=mysql
Replicas:           1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:       Recreate
MinReadySeconds:    0
Pod Template:
  Labels:  app=mysql
  Containers:
   mysql:
    Image:      mysql:5.6
    Port:       3306/TCP
    Host Port:  0/TCP
    Environment:
      MYSQL_ROOT_PASSWORD:  password
    Mounts:
      /var/lib/mysql from mysql-persistent-storage (rw)
  Volumes:
   mysql-persistent-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  mysql-pv-claim
    ReadOnly:   false
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Progressing    True    NewReplicaSetAvailable
  Available      False   MinimumReplicasUnavailable
OldReplicaSets:  <none>
NewReplicaSet:   mysql-fb75876c6 (1/1 replicas created)
Events:          <none>


kubectl describe pods mysql-fb75876c6-tpdzc

Name:               mysql-fb75876c6-tpdzc
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               wombat-dev-kubeadm-worker-1/142.93.56.123
Start Time:         Mon, 03 Sep 2018 10:50:22 +0000
Labels:             app=mysql
                    pod-template-hash=963143272
Annotations:        <none>
Status:             Running
IP:                 192.168.1.14
Controlled By:      ReplicaSet/mysql-fb75876c6
Containers:
  mysql:
    Container ID:   docker://08d630190a83fb5097bf8a98f7bb5f474751e021aec68b1be958c675d3f26f27
    Image:          mysql:5.6
    Image ID:       docker-pullable://mysql@sha256:2e48836690b8416e4890c369aa174fc1f73c125363d94d99cfd08115f4513ec9
    Port:           3306/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    137
      Started:      Mon, 03 Sep 2018 12:04:24 +0000
      Finished:     Mon, 03 Sep 2018 12:04:29 +0000
    Ready:          False
    Restart Count:  19
    Environment:
      MYSQL_ROOT_PASSWORD:  password
    Mounts:
      /var/lib/mysql from mysql-persistent-storage (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-6t8pg (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  mysql-persistent-storage:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  mysql-pv-claim
    ReadOnly:   false
  default-token-6t8pg:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-6t8pg
    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
  ----     ------   ----               ----                                  -------
  Warning  BackOff  1m (x334 over 1h)  kubelet, wombat-dev-kubeadm-worker-1  Back-off restarting failed container

问题是:我该怎么办?运行kubectl logs mysql-fb75876c6-tpdzc根本不返回任何输出。

有帮助吗?

这是kubeadm的版本

kubeadm version: &version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:14:39Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

3 个答案:

答案 0 :(得分:0)

使用kubectl logs -p查看以前的状态日志。

答案 1 :(得分:0)

该容器以退出代码137 退出,这意味着将 SIGTERM (相当于kill -9 <process>)发送到在该容器中执行的进程。通常,这意味着 OOM Killer 会杀死它,因为它使用的内存比可用内存更多。您的计算机上是否有足够的可用内存?

答案 2 :(得分:0)

退出代码mySubClass可能是内存问题。尝试增加专用于机器的ram数量。

Minikube的默认内存仅为1gb,因此,如果您想要更多尝试,可以尝试以下方法:137