struct

RailsApp::Entrypoints

Inherits YAML::Serializable / JSON::Serializable / Kubernetes::Serializable / Struct / Value / Object

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.

Constructors

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
new(pull : JSON::PullParser)
new(*, __pull_for_json_serializable pull : JSON::PullParser)
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
new(*, name : String, image : Nil | String = nil, command : Nil | Array(String) = nil, port : Int64 | Nil = nil, domain : Nil | String = nil, domains : Nil | Array(String) = nil, path : String = "/", path_type : String = "Prefix", replicas : Int64 = 1, deployment_strategy : RailsApp::Entrypoints::DeploymentStrategy = {} of String => JSON::Any, resources : RailsApp::Entrypoints::Resources | Nil = nil, node_selector : Hash(String, JSON::Any) = {} of String => JSON::Any, annotations : Hash(String, JSON::Any) = {} of String => JSON::Any, health_check : RailsApp::Entrypoints::HealthCheck | Nil = nil, ingress : RailsApp::Entrypoints::Ingress | Nil = nil, env_from : Array(RailsApp::Entrypoints::EnvFrom) = Array(EnvFrom).new, env : Array(RailsApp::Entrypoints::Env) = Array(Env).new, service_account : Nil | String = nil)
Source

Instance methods

annotations
command

Optional override for the command to run to run this entrypoint if it differs from the CMD directive in your container image. For example, to run Sidekiq:

command: [bundle, exec, sidekiq]
deployment_strategy

The strategy to use when updating this entrypoint, useful for slow canary rollouts.

When you need to deploy your app safely, it can be best to roll it out slowly over several minutes. If your first few pods fail health checks, the deployment will pause. You can then use kubectl rollout undo deployment in your deployment script to roll the deployment back.

How those health checks fail is specific to your app, but a useful pattern is for the pod to track the number of failures (for example, the number of HTTP 500s or exceptions raised in background jobs) as a percentage of all units of work since the pod started and, when that number exceeds some threshold (for example, 5%), return a failure response for the health check.

deployment_strategy:
  duration_minutes: 10
  surge: 5%
  max_unavailable: 0%

WARNING: This is an experimental property and is subject to change.

domain

The domain your app should be accessible on. This will provision Ingress and Certificate resources so that this entrypoint will be reachable via the public internet. Without this property or domains, it will only be accessible via plaintext inside the cluster.

If domain and domains are both provided, domains takes precedence.

domains

The domains your app should be accessible on. This will provision Ingress and Certificate resources so that this entrypoint will be reachable via the public internet. Without this property or domain, it will only be accessible via plaintext inside the cluster.

If domain and domains are both provided, domains takes precedence.

env

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"
env_from

The source of an environment variable, such as a ConfigMap or Secret.

health_check

HTTP health checks to ensure 2 things:

  1. New pods must pass these health checks before old pods are terminated
  2. Pods will be checked on the run_every interval to make sure it's still alive. If it fails failure_threshold times, the pod will be restarted. If it continues to fail, it will enter a CrashLoopBackOff state.
image

Optional override for the container image for this entrypoint if it differs from the rest of your app. This is useful when you want to deploy something to support your app, such as a Prometheus exporter.

ingress

Properties to assign to any Ingress that gets created for this entrypoint.

name

The name of your entrypoint, such as web or worker

node_selector

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.

path

The path matcher for the Ingress resource, defaults to "/". All incoming requests from outside the cluster with this entrypoint's domain and path will be routed to this entrypoint.

path_type

Defines the way the path is matched, defaulting to Prefix.

  • Prefix matches any request path that starts with path
  • Exact matches only that exact path
  • ImplementationSpecific depends on the Kubernetes IngressClass. This operator uses nginx as the IngressClass, which ImplementationSpecific here.
entrypoints:
- name: web
  domain: example.com
  path: /
port

The port your entrypoint will be listening on. This will provision a Service resource so the entrypoint will be reachable from inside the Kubernetes cluster.

replicas

The number of pods to run for this entrypoint, defaulting to 1.

resources

The resources you want to allocate for each pod and/or limit each pod to.

service_account

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.

Nested types