Давайте запустим Rails с Kubernetes (этот сайт японский (я упомянул вышеупомянутый сайт))
Я хочу запустить Rails с Kubernetes для справки
Использование с CentOS 7, Rails 5 и MySQL 5.7 (1) - Qiita
Получить образ CentOS докера и запустить приложение Rails
все, я сделал rails new sampleapp -d mysql локально.
Создать 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
Я создал образ докера и запустил его gcloud docker - нажмите его Я постараюсь сделать Ruby on Railsс Kubernetes после ссылки на сайт.Я действовал по порядку
mysql-85585d4dc6-sbcck 1/1 Running 0 12m
rails-6fb8956847-x2h2w 0/1 CrashLoopBackOff 3 1m
Только rails-6-fb8956847-x2h2w будет CrashLoopBackOff.
kubectl описать 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
kubectl logs <pod名>
и kubectl logs --previous <pod名>
You must use Bundler 2 or greater with this lockfile.
Я получил ошибку
Извините.Это застряло.Можно использовать ruby 2.3 или 2.4.Я хочу исправить ошибку CrashLoopBackOff и изменить ее на Running.будь добр, научи меня.