mysql 建立pod 状态CrashLoopBackOff 的解决

时间:2024-03-30 14:25:12

1今天发现我的pod 建后:状态是 CrashLoopBackOff

[[email protected] ~]# oc get pod
NAME                      READY     STATUS             RESTARTS   AGE
mysql01-1-qs0n7           0/1       CrashLoopBackOff   9          31m

2: 查看一些pod 的状态:

[[email protected] ~]# oc describe pod mysql01-1-qs0n7

 21m    1s    96    {kubelet test3}                    Warning    FailedSync    Error syncing pod, skipping: failed to "StartContainer" for "mysql01" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=mysql01 pod=mysql01-1-qs0n7_shp(0a37825a-2624-11ea-b48a-525400e21bea)"

  27m    1s    123    {kubelet test3}    spec.containers{mysql01}    Warning    BackOff    Back-off restarting failed docker container

3: 登入到openshift 的console 上面看event log, 发现报错: back-off fafiled:

mysql 建立pod 状态CrashLoopBackOff 的解决

我看了一些, image 都push 成功啦阿,container 也是create 成功啦,为什么会back-off failed 呢。下面看一些log:

4:  发现原来是参数没有设全:

[[email protected] ~]# oc log mysql01-1-qs0n7
W1224 03:19:22.089457   22103 cmd.go:357] log is DEPRECATED and will be removed in a future version. Use logs instead.
=> sourcing 20-validate-variables.sh ...
You must either specify the following environment variables:
  MYSQL_USER (regex: '^[a-zA-Z0-9_]+$')
  MYSQL_PASSWORD (regex: '^[[email protected]#$%^&*()-=<>,.?;:|]+$')
  MYSQL_DATABASE (regex: '^[a-zA-Z0-9_]+$')
Or the following environment variable:
  MYSQL_ROOT_PASSWORD (regex: '^[[email protected]#$%^&*()-=<>,.?;:|]+$')
Or both.

5: 下面进行增加参数:

mysql 建立pod 状态CrashLoopBackOff 的解决

进入deployment 页面里面,进入这个deployment: mysql01, 然后点右上角的action --> edit, 出现如下界面:

mysql 建立pod 状态CrashLoopBackOff 的解决

增加上面的"Environment Variables" 添加:MYSQL_USER , MYSQL_PASSWORD, MYSQL_DATABASE, 然后保存。就可以看到pod 运行正常啦。