Building a basic app
The app.yml file defines what runs when the app is installed. It is a simplified format inspired by Docker Compose, which n5i converts into Kubernetes objects such as Deployments, Services, Secrets and network policies.
A minimal app
version: 1
containers:
main:
image: linkstackorg/linkstack:latest # use a fixed version tag in real apps
ingress_port: 80
mounts:
data:
data: /htdocsThis is enough for a working app:
version: 1is the version of theapp.ymlformat. It is currently always1.containerslists the app's containers by name. A container namedmainwith aningress_portreceives the app's web traffic: when the user adds a domain to the app, requests to that domain are forwarded to port 80 of this container.mounts.datamounts volumedataat/htdocs. Volumes must be declared inmetadata.yml.
Every container that receives traffic gets a Kubernetes Service with the same name as the container, so other containers of the app can reach it by name (here: http://main).
Containers
Each entry under containers is a long-running container (a Deployment by default), a cron job or a job, depending on its fields.
Common fields
| Field | Type | Description |
|---|---|---|
image | string | Container image. Required. |
command, entrypoint | string or string[] | Override the image's command and entrypoint. A string is split like a shell would (quotes are respected). |
environment | map | Environment variables. Values are strings, numbers or booleans, or { secret: <name>, key: <key> } to read the value from one of the app's secrets. |
user | string | uid or uid:gid to run as. |
working_dir | string | Working directory. |
stop_grace_period | string | Time to wait for the container to stop. |
restart | string | Restart policy. |
shm_size | string or number | Size of /dev/shm. |
fs_group | number | Group that owns mounted volumes. |
read_only_rootfs | bool | Mount the container's root filesystem read-only. |
mounts | map | Volumes to mount, see Mounts. |
has_permissions | string[] | Permissions only this container needs, see permissions. |
network_policy | object | Network policy for this container, see Network policies. |
service_account | object | Kubernetes API access for this container (RBAC rules). Anything beyond read-only access in the app's own namespace requires admin permissions. |
cap_add, cap_drop | string[] | Linux capabilities. Adding any capability other than CAP_NET_RAW requires admin permissions. |
privileged, host_network | bool | Run privileged or in the host's network namespace. Both require extra permissions. |
Long-running containers
These fields are only available for long-running containers:
| Field | Type | Description |
|---|---|---|
type | Deployment or StatefulSet | Kubernetes workload type. Default: Deployment. |
ingress_port | number | Port that receives HTTPS traffic from the app's domains. |
http_ingress_port | number | Port that receives plain HTTP traffic, as a fallback. |
path_prefix | string | Serve this container under a path of the app's domain (for example /api). The main container can't have a path prefix. |
strip_prefix | bool | Remove path_prefix before forwarding a request. Default: true. |
enable_http_compression | bool | Let the ingress compress HTTP responses. Default: true. |
auth_exclude | bool | Don't require login for this container when the user protects the app. |
internal_ports | map | Ports other containers and permitted apps can reach. |
public_ports | map | Ports exposed directly on the server, through a LoadBalancer service named <container>-public. Requires the builtin/network/public-port permission. |
use_https_with_hostname, tls_insecure | string, bool | Talk to the container over HTTPS (with this SNI host name) and optionally skip certificate verification. |
plugins | map | Plugins this container implements, see plugins. |
middlewares | map | HTTP middlewares, currently only type: Headers. |
Port maps have the form <service port>: <container port>. A bare port is TCP; use tcp: and udp: keys for explicit protocols:
internal_ports:
8080: 80
udp:
5353: 53Jobs and cron jobs
A container with schedule (a cron expression) becomes a CronJob. A container with job_type becomes a Job: OneTime runs once after installation, OnUpdate runs on every app update.
containers:
migrate:
image: linkstackorg/linkstack:latest
job_type: OnUpdate
command: php artisan migrate --force
cleanup:
image: alpine:3
schedule: "0 3 * * *"
command: ["sh", "-c", "rm -rf /data/tmp/*"]
mounts:
data:
data: /dataMounts
mounts:
data:
data: /htdocs # volume "data" at /htdocs
data/config: /config # sub-path "config" of volume "data"
secrets:
credentials: /run/secrets/credentials
tmp:
cache: /tmp/cache # an empty directory that lives as long as the pod
host_paths:
/dev/dri: /dev/dri # requires admin permissions| Key | Description |
|---|---|
data | Persistent volumes declared in metadata.yml, as <volume>[/<sub-path>]: <mount path>. |
secrets | One of the app's secrets, mounted as files. |
tmp | Temporary empty directories. |
host_paths | Directories of the host. Using them requires the builtin/root permission. |
Services
Services are created automatically for containers with an ingress_port, internal_ports or plugins. Declare a service under services only if you need more control:
services:
web:
type: ClusterIp # or LoadBalancer
target_container: main
ports:
80: 8080Ingress to other apps
The top-level ingress list routes traffic of the app's domains to services of other apps, or adds more routes:
ingress:
- target_app: other-app
target_svc: api
port: 3000
path_prefix: /apiThe app needs a permission of other-app that covers this service and port, see sharing data. Only one route without path_prefix (the primary route) is allowed.
Secrets
secrets:
credentials:
string_data:
password: "{{ derive_entropy(identifier='db-password') }}"
data:
key.bin: aGVsbG8= # base64-encodedGenerate passwords with derive_entropy in an app.yml.jinja template. The values stay the same across reinstalls and updates.
Network policies
By default, every container of an app can reach the internet, DNS and the other containers of the same app, and can only be reached from inside the app (and through its ingress). You can change this with a top-level network_policy or one per container:
network_policy:
egress:
allow_world: false
fqdns:
- match_name: api.example.com
allowed_ports: [443]Set disable_default_network_policy: true to skip the default policy. This applies a default-deny policy, so the app can hardly use the network at all.
Plugin resources
Top-level keys other than the ones above are resources for custom resource plugins, in the form <plugin app>: <plugin id>: <definition>. See custom Kubernetes objects.