KubernetesでRailsを動かしてみよう! - Qiita

CentOS7とRails5とMySQL5.7で使う(1) - Qiita
DockerのCentOSイメージを取得して、Railsアプリを動かすまで

を参考にまずローカルでrails new sampleapp -d mysqlを作りました。
作り方

mysql5.6

yum remove mariadb-libs
rm -rf /var/lib/mysql/
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
yum repolist all | grep mysql
yum -y install yum-utils
yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql56-community
yum info mysql-community-server
yum -y install mysql-community-server
yum -y install mysql-devel
mysqld --version

ruby2.3

yum remove ruby
yum install -y git
yum install -y libxslt-devel libxml++-devel libxml2-devel

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
cd ~/.rbenv/plugins/ruby-build
./install.sh
rbenv -v
rbenv install -l
yum install -y bzip2 gcc openssl-devel readline-devel make
rbenv install 2.3.0
rbenv rehash
rbenv global 2.3.0
ruby -v

その後

gem update --system
gem install bundler
Overwrite the executable? [yN]  y
rbenv rehash
yum install epel-release
yum install nodejs npm --enablerepo=epel
yum install gcc gcc-c++

で作っています。(ruby2.3、rails5.2.2、mysql5.6です)

その後
KubernetesでRailsを動かしてみよう! - Qiita
(ADD Gemfile /app/GemfileADD Gemfile.lock /app/Gemfile.lockを追加して)

Dockerfileを作り

FROM ruby:2.3

ENV APP_ROOT="/app"

RUN \
    mkdir -p $APP_ROOT

RUN \
    apt-get update -qq && \
    apt-get install -y build-essential nodejs

WORKDIR $APP_ROOT

ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock

RUN \
    bundle config --global build.nokogiri --use-system-libraries


ADD . $APP_ROOT

ENV RAILS_ENV production
WORKDIR $APP_ROOT

ENTRYPOINT \
    bundle install && \
    bin/rails db:create && \
    bin/rails db:migrate && \
    bin/rake assets:precompile && \
    bin/rails server -p 3000 -b 0.0.0.0

でdocker imageを作り実行しました
gcloud docker -- pushして
あとサイトを参考にRuby on RailsをKubernetesでたてようと思っています。
順番通りに進めていきました

mysql-85585d4dc6-sbcck   1/1     Running            0          12m
rails-6fb8956847-x2h2w   0/1     CrashLoopBackOff   3          1m

rails-6fb8956847-x2h2wだけがCrashLoopBackOffになります。

logを見てみたんですが

watch kubectl describe rails-6fb8956847-x2h2w

error: the server doesn't have a resource type "rails-6fb8956847-x2h2w"

kubectl describe pod

Name:           rails-6fb8956847-x2h2w
Namespace:      default
Node:           gke-cluster-1-default-pool-b5850484-j5x4/10.146.0.44
Start Time:     Mon, 14 Jan 2019 19:56:16 +0000
Labels:         app=rails
                pod-template-hash=2964512403
Annotations:    kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container rails
Status:         Running
IP:             10.16.1.11
Controlled By:  ReplicaSet/rails-6fb8956847
Containers:
  rails:
    Container ID:   docker://db2d45dd73f0e5231b8d8c6c94c5a71b69ce45aa9073c47a0fedb19d5c08c744
    Image:          gcr.io/balmy-geography-216916/sampleapp2:v3
    Image ID:       docker-pullable://gcr.io/balmy-geography-216916/sampleapp2@sha256:94148ed4c7b6c4d96b265ffef1c2d4167911272566460bfcdbc7e3651a3001dd
    Port:           3000/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    20
      Started:      Mon, 14 Jan 2019 20:08:14 +0000
      Finished:     Mon, 14 Jan 2019 20:08:14 +0000
    Ready:          False
    Restart Count:  7
    Requests:
      cpu:  100m
    Environment:
      DATABASE_ROOT_PASSWORD:  <set to the key 'database_root_password' in secret 'rails'>  Optional: false
      SECRET_KEY_BASE:         <set to the key 'secret_key_base' in secret 'rails'>         Optional: false
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-86ff7 (ro)
Conditions:
  Type           Status
  Initialized    True
  Ready          False
  PodScheduled   True
Volumes:
  default-token-86ff7:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-86ff7
    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              12m                   default-scheduler                                  Successfully assigned rails-6fb8956847-x2h2w to gke-cluster-1-default-pool-b5850484-j5x4
  Normal   SuccessfulMountVolume  12m                   kubelet, gke-cluster-1-default-pool-b5850484-j5x4  MountVolume.SetUp succeeded for volume "default-token-86ff7"
  Normal   Pulling                11m (x4 over 12m)     kubelet, gke-cluster-1-default-pool-b5850484-j5x4  pulling image "gcr.io/balmy-geography-216916/sampleapp2:v3"
  Normal   Pulled                 11m (x4 over 12m)     kubelet, gke-cluster-1-default-pool-b5850484-j5x4  Successfully pulled image "gcr.io/balmy-geography-216916/sampleapp2:v3"
  Normal   Created                11m (x4 over 12m)     kubelet, gke-cluster-1-default-pool-b5850484-j5x4  Created container
  Normal   Started                11m (x4 over 12m)     kubelet, gke-cluster-1-default-pool-b5850484-j5x4  Started container
  Warning  BackOff                2m36s (x44 over 12m)  kubelet, gke-cluster-1-default-pool-b5850484-j5x4  Back-off restarting failed container

いままでやったこと
・rubyバージョン(2.3と2.4.1)にしてみました。
・n1-standard-2にしてみました。
・selinuxを切ってみました。
・Dockerfileの作り直し(ADD Gemfile /app/GemfileADD Gemfile.lock /app/Gemfile.lock)の追加
・sampleappフォルダのところでgem install bundlerをし、もう一度imageを作り直して
 再実行。
・rubyを実験的2.4.1にあげてみてためしてみました。(下記参照)

kubectl logs <pod名>kubectl logs --previous <pod名>

をしたところ

You must use Bundler 2 or greater with this lockfile.

とでました

rails new sampleapp -d mysql
のgemfileとgemfilelockを書きます。

Gemfile

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.3.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
 # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemlock

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (5.2.2)
      actionpack (= 5.2.2)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailer (5.2.2)
      actionpack (= 5.2.2)
      actionview (= 5.2.2)
      activejob (= 5.2.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.2.2)
      actionview (= 5.2.2)
      activesupport (= 5.2.2)
      rack (~> 2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.2.2)
      activesupport (= 5.2.2)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.2.2)
      activesupport (= 5.2.2)
      globalid (>= 0.3.6)
    activemodel (5.2.2)
      activesupport (= 5.2.2)
    activerecord (5.2.2)
      activemodel (= 5.2.2)
      activesupport (= 5.2.2)
      arel (>= 9.0)
    activestorage (5.2.2)
      actionpack (= 5.2.2)
      activerecord (= 5.2.2)
      marcel (~> 0.3.1)
    activesupport (5.2.2)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    addressable (2.5.2)
      public_suffix (>= 2.0.2, < 4.0)
    archive-zip (0.11.0)
      io-like (~> 0.3.0)
    arel (9.0.0)
    bindex (0.5.0)
    bootsnap (1.3.2)
      msgpack (~> 1.0)
    builder (3.2.3)
      byebug (10.0.2)
    capybara (3.12.0)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (~> 1.2)
      xpath (~> 3.2)
    childprocess (0.9.0)
      ffi (~> 1.0, >= 1.0.11)
    chromedriver-helper (2.1.0)
      archive-zip (~> 0.10)
      nokogiri (~> 1.8)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.1.4)
    crass (1.0.4)
    erubi (1.8.0)
    execjs (2.7.0)
    ffi (1.10.0)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    i18n (1.5.2)
      concurrent-ruby (~> 1.0)
    io-like (0.3.0)
    jbuilder (2.8.0)
      activesupport (>= 4.2.0)
      multi_json (>= 1.2)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.2.3)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    marcel (0.3.3)
      mimemagic (~> 0.3.2)
    method_source (0.9.2)
    mimemagic (0.3.3)
    mini_mime (1.0.1)
     mini_portile2 (2.4.0)
    minitest (5.11.3)
    msgpack (1.2.6)
    multi_json (1.13.1)
    mysql2 (0.5.2)
    nio4r (2.3.1)
    nokogiri (1.10.1)
      mini_portile2 (~> 2.4.0)
    public_suffix (3.0.3)
    puma (3.12.0)
    rack (2.0.6)
    rack-test (1.1.0)
      rack (>= 1.0, < 3)
    rails (5.2.2)
      actioncable (= 5.2.2)
      actionmailer (= 5.2.2)
      actionpack (= 5.2.2)
      actionview (= 5.2.2)
      activejob (= 5.2.2)
      activemodel (= 5.2.2)
      activerecord (= 5.2.2)
      activestorage (= 5.2.2)
      activesupport (= 5.2.2)
      bundler (>= 1.3.0)
      railties (= 5.2.2)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.0.4)
      loofah (~> 2.2, >= 2.2.2)
    railties (5.2.2)
      actionpack (= 5.2.2)
      activesupport (= 5.2.2)
      method_source
      rake (>= 0.8.7)
       rb-fsevent (0.10.3)
    rb-inotify (0.10.0)
      ffi (~> 1.0)
    regexp_parser (1.3.0)
    ruby_dep (1.5.0)
    rubyzip (1.2.2)
    sass (3.7.3)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (5.0.7)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    selenium-webdriver (3.141.0)
      childprocess (~> 0.5)
      rubyzip (~> 1.2, >= 1.2.2)
    spring (2.0.2)
      activesupport (>= 4.2)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (3.7.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    thor (0.20.3)
    thread_safe (0.3.6)
    tilt (2.0.9)
    turbolinks (5.2.0)
      turbolinks-source (~> 5.2)
    turbolinks-source (5.2.0)
    tzinfo (1.2.5)
      thread_safe (~> 0.1)
    uglifier (4.1.20)
      execjs (>= 0.3.0, < 3)
    web-console (3.7.0)
      actionview (>= 5.0)
      activemodel (>= 5.0)
      bindex (>= 0.4.0)
      railties (>= 5.0)
    websocket-driver (0.7.0)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)
    xpath (3.2.0)
      nokogiri (~> 1.8)
  PLATFORMS
  ruby

DEPENDENCIES
  bootsnap (>= 1.1.0)
  byebug
  capybara (>= 2.15)
  chromedriver-helper
  coffee-rails (~> 4.2)
  jbuilder (~> 2.5)
  listen (>= 3.0.5, < 3.2)
  mysql2 (>= 0.4.4, < 0.6.0)
  puma (~> 3.11)
  rails (~> 5.2.2)
  sass-rails (~> 5.0)
  selenium-webdriver
  spring
  spring-watcher-listen (~> 2.0.0)
  turbolinks (~> 5)
  tzinfo-data
  uglifier (>= 1.3.0)
  web-console (>= 3.3.0)

RUBY VERSION
   ruby 2.3.0p0

BUNDLED WITH
   2.0.1

-ruby2.4.1
にあげたときのDockerfileでは

FROM ruby:2.4.1-alpine

ENV APP_ROOT="/app"

RUN \
    mkdir -p $APP_ROOT

RUN \
    apk update && apk upgrade && apk add --update --no-cache alpine-sdk tzdata mysql-dev nodejs

WORKDIR $APP_ROOT

ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock

RUN \
    bundle config --global build.nokogiri --use-system-libraries


ADD . $APP_ROOT

ENV RAILS_ENV production
WORKDIR $APP_ROOT

ENTRYPOINT \
    bundle install && \
    bin/rails db:create && \
    bin/rails db:migrate && \
    bin/rake assets:precompile && \
    bin/rails server -p 3000 -b 0.0.0.0

でimageを作りました。
その後実行したら下記のエラーがでました

You must use Bundler 2 or greater with this lockfile.

すいません。手詰まりです。ruby2.3でも2.4でもどちらでもかまいません。
CrashLoopBackOffエラーをなんとか直してRunningにかえたいです。
どうか教えてください。

またKubernetesでRailsを起動しようといろいろなサイトみているんですが、

これでもかって言うくらいコピペでKubernetes(Google Kubernetes Engine)に環境変数の設定からRailsアプリケーションのmigrateも考慮したデプロイが動くコマンドを書いていく- Qiita

GKEにRailsをデプロイしてみる

など参考にしているんですがなかなかうまくいきません。
これ動いたよっていうサイトあればすいませんが是非教えてください。
こちらもお願いします。