struct
RailsApp::Entrypoints
- RailsApp::Entrypoints
- Struct
- Value
- Object
Overview
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.
Included Modules
- JSON::Serializable
- Kubernetes::Serializable
- YAML::Serializable
Defined in:
rails_app_operator.crConstructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(pull : JSON::PullParser)
- .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)
Instance Method Summary
- #annotations : Hash(String, JSON::Any)
-
#command : Array(String) | Nil
Optional override for the command to run to run this entrypoint if it differs from the
CMDdirective in your container image. -
#deployment_strategy : DeploymentStrategy
The strategy to use when updating this entrypoint, useful for slow canary rollouts.
-
#domain : String | Nil
The domain your app should be accessible on.
-
#domains : Array(String) | Nil
The domains your app should be accessible on.
-
#env : Array(Env)
A list of
Envobjects representing environment variables. -
#env_from : Array(EnvFrom)
The source of an environment variable, such as a
ConfigMaporSecret. -
#health_check : HealthCheck | Nil
HTTP health checks to ensure 2 things:
-
#image : String | Nil
Optional override for the container image for this entrypoint if it differs from the rest of your app.
-
#ingress : Ingress | Nil
Properties to assign to any
Ingressthat gets created for this entrypoint. -
#name : String
The name of your entrypoint, such as
weborworker -
#node_selector : Hash(String, JSON::Any)
A
Hash(String, String)containing label/value pairs — pods for thisRailsApporEntrypointswill only be assigned to nodes that have these labels. -
#path : String
The path matcher for the
Ingressresource, defaults to"/". -
#path_type : String
Defines the way the
#pathis matched, defaulting toPrefix. -
#port : Int64 | Nil
The port your entrypoint will be listening on.
-
#replicas : Int64
The number of pods to run for this entrypoint, defaulting to
1. -
#resources : Resources | Nil
The resources you want to allocate for each pod and/or limit each pod to.
-
#service_account : String | Nil
Use the given Kubernetes
ServiceAccountto run pods for this app.
Constructor Detail
Instance Method Detail
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]
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.
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.
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.
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.
HTTP health checks to ensure 2 things:
- New pods must pass these health checks before old pods are terminated
- Pods will be checked on the
run_everyinterval to make sure it's still alive. If it failsfailure_thresholdtimes, the pod will be restarted. If it continues to fail, it will enter aCrashLoopBackOffstate.
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.
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.
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.
Defines the way the #path is matched, defaulting to Prefix.
Prefixmatches any request path that starts with#pathExactmatches only that exact pathImplementationSpecificdepends on the KubernetesIngressClass. This operator usesnginxas theIngressClass, whichImplementationSpecifichere.
entrypoints:
- name: web
domain: example.com
path: /
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.
The resources you want to allocate for each pod and/or limit each pod to.
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.