RailsApp
Inherits YAML::Serializable / JSON::Serializable / Kubernetes::Serializable / Struct / Value / Object
The RailsApp represents the resource being specified. It is the spec in the Kubernetes YAML.
This resource comprises several different resources:
DeploymentperentrypointServicefor eachentrypointwith aportspecifiedIngressfor eachentrypointwith adomainspecifiedCertificate(via CertManager) for eachentrypointwith adomainspecifiedJobforbefore_create(automatically GCed upon completion)Jobforbefore_update(automatically GCed upon completion)
NOTE: despite this being called a RailsApp, it's not only for Ruby on Rails apps. It was designed for them originally, but it quickly became useful for much more than apps built with that framework.
Example:
---
apiVersion: jgaskins.dev/v1beta1
kind: RailsApp
metadata:
name: my-rails-app
spec:
image: repo/image:tag
env:
- name: RAILS_ENV
value: production
- name: DATABASE_URL
value: postgres://user:password@host/db
- name: REDIS_URL
value: redis://redis
entrypoints:
- name: web # Pods will be called `my-rails-app-web-*-*`
domain: example.com # The domain people will use to reach your app
port: 3000 # What port the server listens on
command: [bin/rails, server] # Run the Rails server
- name: worker # Pods will be called `my-rails-app-worker-*-*`
command: [bin/sidekiq] # Run the Sidekiq job processor
before_create:
command: [bin/rails, db:schema:load]
before_update:
command: [bin/rails, db:migrate]
Constructors
Instance methods
When the RailsApp is created, this job is executed. Usually this is used to provision the database schema.
When the RailsApp is updated, this job is executed. Usually this is used to run database schema and data migrations.
Create directories on the container's filesystem
directories:
- path: /containing/path
name: config
files:
- filename: app.yml
content: |
production:
database: postgres://user:password@host/db_name
redis: redis://redis
The entrypoints for your application — each type of process
you run, such as a Rails server and Sidekiq, is a separate
entrypoint. This is similar to entries in a Procfile.
A list of Env objects representing environment variables.
Either a value or value_from (in YAML: valueFrom)
must be provided.
env:
- name: REDIS_URL
value: redis://redis
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: "postgres-app"
value: "uri"
The source of an environment variable, such as a ConfigMap or Secret.
The image tag to use by default for all entrypoints in this RailsApp
Describes how images are pulled: Always pulls a fresh container image each time and IfNotPresent will pull a container image once and keep it cached. Use Always if your container images use mutable tags, such as latest.
The name of the secret that contains container-registry credentials, allowing Kubernetes to pull the image from its repo. For more information, see the Kubernetes documentation on pulling images from a private registry.
A Hash(String, String) containing label/value pairs —
pods for this RailsApp or Entrypoints will only be assigned
to nodes that have these labels. For example, if you set
kubernetes.io/arch: arm64 here, pods will only be assigned
to nodes running Arm64 processors.
Use the given Kubernetes ServiceAccount to run pods for this app. This is extremely rare to need to set, so if you don't know what to set here, you almost certainly want to leave it blank.