apiVersion: apps/v1 kind: Deployment metadata: name: rails-app namespace: rails-app labels: app: rails-app spec: replicas: 1 selector: matchLabels: app: rails-app template: metadata: labels: app: rails-app spec: containers: - name: rails image: ruby:3.3-slim imagePullPolicy: IfNotPresent command: ["/bin/bash", "-c"] args: - | apt-get update -qq && apt-get install -y build-essential libsqlite3-dev nodejs npm git curl gem install rails -v '8.1.0' --no-document cd /app if [ ! -f config/database.yml ]; then rails new . --force --database=sqlite3 --skip-git --skip-bundle fi bundle install rails db:create db:migrate || true # 创建欢迎页面 cat > app/controllers/welcome_controller.rb <<'RUBY' class WelcomeController < ApplicationController def index @hostname = Socket.gethostname @rails_version = Rails.version @ruby_version = RUBY_VERSION end end RUBY mkdir -p app/views/welcome cat > app/views/welcome/index.html.erb <<'HTML'
Ruby版本: <%= @ruby_version %>
Rails版本: <%= @rails_version %>
数据库: SQLite3
Pod主机名: <%= @hostname %>
访问域名: r1.jpd.net3w.com
部署方式: GitOps (Gitea + ArgoCD)
集群: JPD K3s Cluster
<%= Time.now.strftime("%Y-%m-%d %H:%M:%S") %>