Postgres数据库未在Kubernetes Pod中迁移

发布于 2025-01-21 06:50:49 字数 917 浏览 1 评论 0原文

我正在尝试将我的ROR应用程序部署在Kubernetes上。我正在使用PostgreSQL作为数据库。我正在分别部署前端和后端,并且正在使用ConfigMap注入环境变量。但是,我注意到一种奇怪的行为。有时,数据库正在迁移,有时不是。有时,该应用程序正常工作,而有时数据库不会迁移。我真的无法弄清楚是什么问题。日志还说您有1个未决的迁移。

这是我的dockerfile fron-end:

FROM ruby:3.0.3
RUN apt-get update && apt-get install -y \
  curl vim wget \
  build-essential \
  libpq-dev &&\
  curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
  curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
  echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

COPY . .
RUN bundle install &&\ 
  gem install rails 
ENTRYPOINT ["bash" , "commands.sh"]

命令

#!/bin/bash
bundle install
rails db:create
rails db:migrate
rails db:seed
rails db:migrate
rails server -b 0.0.0.0

这 。 有人可以帮我弄清楚发生了什么事吗?

I'm trying to deploy my RoR application on Kubernetes. I'm using PostgreSQL as the database. I'm deploying both the front-end and back-end separately and I'm using configmap to inject the environment variables. However, I'm noticing a strange behaviour. Sometimes, the database is getting migrated and sometimes it isn't. Sometimes, the app works fine whereas sometimes the database isn't getting migrated. I really can't figure out what's the issue. The logs also says you have 1 pending migration.

Here's my Dockerfile for the fron-end:

FROM ruby:3.0.3
RUN apt-get update && apt-get install -y \
  curl vim wget \
  build-essential \
  libpq-dev &&\
  curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
  curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
  echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

COPY . .
RUN bundle install &&\ 
  gem install rails 
ENTRYPOINT ["bash" , "commands.sh"]

here's commands.sh

#!/bin/bash
bundle install
rails db:create
rails db:migrate
rails db:seed
rails db:migrate
rails server -b 0.0.0.0

I'm using postrSQL latest image for my database.
Can someone help me figure out what's happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文