54373
rubyonrailsでmysql5.7とruby:2.4.2でKubernetesをやってみよう思い

database.ymlを

```

      adapter: mysql2
      encoding: utf8
      pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
      database: rails_production
      host: <%= ENV['DATABASE_HOST'] %>
      username: root
      password: <%= ENV['DATABASE_ROOT_PASSWORD'] %>
      port: <%= ENV['DATABASE_PORT'] %>
    
```

に設定し  
mysql5.7でdeploymentするとCrashLoopBackOffがでます

`gcloud compute disks create --size 200GB mysql-data`

```

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: mysql
      labels:
        app: mysql
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mysql
      template:
        metadata:
          labels:
            app: mysql
        spec:
          containers:
            - image: mysql:5.7
              name: mysql
              env:
                - name: MYSQL_ROOT_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: rails
                      key: database_root_password
              ports:
                - containerPort: 3306
                  name: mysql
              volumeMounts:
                - name: mysql-persistent-storage
                  mountPath: /var/lib/mysql
          volumes:
            - name: mysql-persistent-storage
              gcePersistentDisk:
                pdName: mysql-data
                fsType: ext4
    
```

kubectl describe pod

```

    Name:               mysql-55c74486f6-89j7r
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               gke-myrails-default-pool-e9785f10-b4l5/10.140.0.10
    Start Time:         Mon, 04 Mar 2019 20:00:46 +0000
    Labels:             app=mysql
                        pod-template-hash=1173004292
    Annotations:        kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container mysql
    Status:             Running
    IP:                 10.0.0.15
    Controlled By:      ReplicaSet/mysql-55c74486f6
    Containers:
      mysql:
        Container ID:  docker://488be36176d5f260a09159e69a43ac0825da8c9c6c736574df16dc8d91e32504
        Image:         mysql:5.7
        Image ID:      docker-pullable://mysql@sha256:888d433748dbccc8388a665134b1906f13f599753ef190546903181b7312027d
        Port:          3306/TCP
        Host Port:     0/TCP
        Args:
           --ignore-db-dir = lost + found
        State:          Terminated
          Reason:       Error
          Exit Code:    127
          Started:      Mon, 04 Mar 2019 20:01:18 +0000
          Finished:     Mon, 04 Mar 2019 20:01:18 +0000
        Last State:     Terminated
          Reason:       Error
          Exit Code:    127
          Started:      Mon, 04 Mar 2019 20:01:04 +0000
          Finished:     Mon, 04 Mar 2019 20:01:04 +0000
        Ready:          False
        Restart Count:  2
        Requests:
          cpu:  100m
        Environment:
          MYSQL_ROOT_PASSWORD:  <set to the key 'database_root_password' in secret 'rails'>  Optional: false
        Mounts:
          /var/lib/mysql from mysql-persistent-storage (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-7xrkt (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             False
      ContainersReady   False
      PodScheduled      True
    Volumes:
      mysql-persistent-storage:
        Type:       GCEPersistentDisk (a Persistent Disk resource in Google Compute Engine)
        PDName:     mysql-data
        FSType:     ext4
        Partition:  0
        ReadOnly:   false
      default-token-7xrkt:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-7xrkt
        Optional:    false
    QoS Class:       Burstable
    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               36s               default-scheduler                                Successfully assigned default/mysql-55c74486f6-89j7r to gke-myrails-default-pool-e9785f10-b4l5
      Normal   SuccessfulAttachVolume  30s               attachdetach-controller                          AttachVolume.Attach succeeded for volume "mysql-persistent-storage"
      Normal   Pulled                  4s (x3 over 18s)  kubelet, gke-myrails-default-pool-e9785f10-b4l5  Container image "mysql:5.7" already present on machine
      Normal   Created                 4s (x3 over 18s)  kubelet, gke-myrails-default-pool-e9785f10-b4l5  Created container
      Normal   Started                 4s (x3 over 18s)  kubelet, gke-myrails-default-pool-e9785f10-b4l5  Started container
      Warning  BackOff                 4s (x3 over 17s)  kubelet, gke-myrails-default-pool-e9785f10-b4l5  Back-off restarting failed container
    
```

```

    Initializing database
    2019-03-04T19:07:34.627201Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2019-03-04T19:07:34.628690Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
    2019-03-04T19:07:34.628756Z 0 [ERROR] Aborting
    
```

となります。誰かこの直し方知っている方いますでしょうか？  
教えてください。よろしくお願いします。
CC BY-SA 4.0
2019-03-04T20:10:05.787
53197
2019-04-21T17:37:29.030
19329
question
ruby-on-rails kubernetes google-kubernetes-engine
mysql5.7をdeploymentするとエラーがでる
mysql5.6に変更しました。  
mysql5.7ではまずimageをつくらないとだめみたいです
CC BY-SA 4.0
2019-04-21T17:37:29.030
54373
2019-04-21T17:37:29.030
19329
53197
answer