How to deploy a Laravel for Rust app on Cloider Kubernetes Engine
Deploy a Laravel for Rust app with PostgreSQL to a Cloider Kubernetes cluster: build and push the image to the Cloider registry, write the manifests, run migrations as a Job, and expose it on a free HTTPS subdomain, with a screenshot of every step.

On this page
Key takeaways
- Push the image to registry.cloider.com and pull it with a Pull only token stored as an imagePullSecret.
- Keep APP_KEY and DATABASE_URL in a Secret created with kubectl, and the rest in a ConfigMap.
- Run migrations as a Job with the same image, then let the Deployment probe /up.
- Pods reach the managed PostgreSQL database on its private host with sslmode=require.
- A target exposes a Service on a free cloider.app subdomain with HTTPS, no Ingress needed.
Cloider App Engine is the shortest way to run a web app, but sometimes you want Kubernetes itself: your own manifests, Jobs, private Services, or the same setup you run elsewhere. Cloider Kubernetes gives you a managed cluster in a couple of minutes, with no control plane or nodes to look after.
In this guide you deploy a Laravel for Rust app with a PostgreSQL database to a Cloider Kubernetes cluster, three ways:
The classic way, from the dashboard: dockerize the app, build the image, create the database, write the Kubernetes manifests, and verify it works.
With the cloider CLI: build and push to the Cloider container registry, deploy the app, then expose it on a free subdomain with HTTPS.
With an AI coding agent: "using cloider cli deploy this app to cloider kubernetes engine".
Options 1 and 2 show every step with a screenshot. The finished app is live at laravel-rust-k8s.cloider.app, and the code and manifests are on GitHub at mareimorsy/laravel-rust-blog. If you only need the app running, the App Engine guide is shorter.
What you need
A Cloider account. New accounts get a welcome credit.
Docker with buildx, and
kubectl.The app:
git clone https://github.com/mareimorsy/laravel-rust-blog.git.
The repository's k8s/ folder holds four manifests. Secrets are not in it: you create them with kubectl, so they never land in git.
File | What it creates |
|---|---|
k8s/config.yaml | ConfigMap laravel-config: APP_ENV, APP_DEBUG, APP_URL, LOG_CHANNEL |
k8s/migrate.yaml | Job laravel-migrate: runs ./myapp migrate --force once |
k8s/deployment.yaml | Deployment laravel: 2 replicas on port 8080, probes on /up |
k8s/service.yaml | Service laravel: port 80 to the pods' port 8080 |
Option 1: the classic way, from the dashboard
Step 1: Dockerize the app
Laravel for Rust compiles your whole application, migrations included, into one binary. At runtime it still reads three folders next to it: public/ (the Vite build), resources/views/ (the root view) and storage/. The Dockerfile in the repository builds all of that in three stages:
assets:
npm ciandnpm run buildwrite the Inertia + React frontend topublic/build.server:
cargo build --release --lockedbuilds the binary. The two cache mounts keep the Cargo registry and the build folder between builds, so a rebuild only compiles what changed.runtime: a slim Debian image with the binary,
public/,resources/views/and a writablestorage/, running as a non-rootappuser.
# syntax=docker/dockerfile:1
FROM node:24-slim AS assets
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY vite.config.ts tsconfig.json ./
COPY resources ./resources
COPY public ./public
RUN npm run build
FROM rust:1.100-slim-trixie AS server
WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/build \
cargo build --release --locked \
&& cp target/release/myapp /usr/local/bin/myapp
FROM debian:trixie-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --system --no-create-home app
WORKDIR /app
COPY --from=server /usr/local/bin/myapp ./myapp
COPY --from=assets /app/public ./public
COPY resources/views ./resources/views
RUN mkdir -p storage/app storage/logs && chown -R app:app storage
ENV SERVER_HOST=0.0.0.0 \
SERVER_PORT=8080
USER app
EXPOSE 8080
CMD ["./myapp"]
Two settings matter on any platform. The server listens on 127.0.0.1:8000 by default, which nothing outside the container can reach, so the image sets SERVER_HOST=0.0.0.0 and SERVER_PORT=8080. And Cloider terminates HTTPS in front of your app, so src/app.rs trusts the proxy, which makes the URLs the app generates start with https://:
.with_middleware(|middleware, _| {
// Cloider's load balancer terminates HTTPS, and apps are only reachable through it
middleware.trust_proxies(["*"]);
// ...
})The framework also answers GET /up with a 200 once it has started, which is what Cloider and Kubernetes use as the health check.
Step 2: Build the image
Kubernetes pulls images from a registry, so push yours to the Cloider container registry. Open Registry, click Create Project and name it. Project names are shared by everyone on registry.cloider.com, so pick your own, here laravel-rust.


On the Tokens tab, click Create Token. Name it laptop, limit it to the laravel-rust project and give it Pull & push:

The secret is shown once, with a ready docker login command and a ready Kubernetes pull secret command. Copy it now.

Log docker in with the username and secret from that dialog (doe.cloider is this account's), then build the image for linux/amd64, the platform Cloider's nodes run, and push it:
echo "$REGISTRY_TOKEN" | docker login registry.cloider.com -u doe.cloider --password-stdin
docker buildx build --platform linux/amd64 -t registry.cloider.com/laravel-rust/blog:v1 --push .


Step 3: Create the database
Open Databases, click Create Database, name it laravel-k8s with the user laravel, pick PostgreSQL v18 and the Hobby plan, and create it.

Once it is Ready, copy the DSN from the Private tab of Quick Connect on its page, as in the App Engine guide. Pods in your Cloider clusters reach the database on its private host, ...db.cloider.internal.
Step 4: Create the cluster and the Kubernetes manifests
Open Kubernetes and click Create Cluster. A name is all it needs:


When it is ready, click it. The cluster page lists your workloads, and has Apply YAML, a Terminal with kubectl, and a button to download the kubeconfig.

Connect kubectl to it. Download the kubeconfig from the cluster page, or let the CLI merge it into yours:
cloider cluster kubeconfig laravel --merge --use
kubectl get nodes
Create the namespace and the two Secrets: the app's APP_KEY and DATABASE_URL, and the registry login the pods pull the image with. Use a Pull only registry token for the cluster:
export APP_KEY="base64:$(openssl rand -base64 32)"
export DATABASE_URL="postgres://laravel:PASSWORD@laravel-k8s-xgdoy3.db.cloider.internal:20611/laravel-k8s?sslmode=require" # the private DSN
export PULL_TOKEN="..." # the secret of a Pull only token for the laravel-rust project
kubectl create namespace laravel
kubectl -n laravel create secret generic laravel-secrets \
--from-literal=APP_KEY="$APP_KEY" --from-literal=DATABASE_URL="$DATABASE_URL"
kubectl -n laravel create secret docker-registry cloider-registry \
--docker-server=registry.cloider.com --docker-username=doe.cloider --docker-password="$PULL_TOKEN"
Now the manifests. The ConfigMap holds the settings that aren't secret:
# Settings that aren't secret. APP_KEY and DATABASE_URL live in the Secret
# laravel-secrets, created with kubectl so they never land in git.
apiVersion: v1
kind: ConfigMap
metadata:
name: laravel-config
namespace: laravel
data:
APP_ENV: production
APP_DEBUG: "false"
APP_URL: https://laravel-rust-k8s.cloider.app
LOG_CHANNEL: stderrA Job runs the migrations once, with the same image, settings and secrets as the app:
# Runs the migrations once, before the new version serves traffic.
# Delete and apply it again on every deploy that adds a migration.
apiVersion: batch/v1
kind: Job
metadata:
name: laravel-migrate
namespace: laravel
spec:
backoffLimit: 3
ttlSecondsAfterFinished: 86400
template:
spec:
restartPolicy: Never
imagePullSecrets:
- name: cloider-registry
containers:
- name: migrate
image: registry.cloider.com/laravel-rust/blog:v1
command: ["./myapp", "migrate", "--force"]
envFrom:
- configMapRef:
name: laravel-config
- secretRef:
name: laravel-secretsThe Deployment runs two replicas, pulls the image with the cloider-registry secret, and uses the framework's /up route for its readiness and liveness probes:
apiVersion: apps/v1
kind: Deployment
metadata:
name: laravel
namespace: laravel
labels:
app: laravel
spec:
replicas: 2
selector:
matchLabels:
app: laravel
template:
metadata:
labels:
app: laravel
spec:
imagePullSecrets:
- name: cloider-registry
containers:
- name: web
image: registry.cloider.com/laravel-rust/blog:v1
ports:
- name: http
containerPort: 8080
envFrom:
- configMapRef:
name: laravel-config
- secretRef:
name: laravel-secrets
readinessProbe:
httpGet:
path: /up
port: http
periodSeconds: 5
livenessProbe:
httpGet:
path: /up
port: http
initialDelaySeconds: 10
periodSeconds: 10
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256MiAnd a ClusterIP Service in front of them:
apiVersion: v1
kind: Service
metadata:
name: laravel
namespace: laravel
spec:
selector:
app: laravel
ports:
- name: http
port: 80
targetPort: httpApply all four with Apply YAML on the cluster page: paste them one after the other, separated by ---, and click Apply. kubectl apply -f k8s/ does the same from your terminal.


Step 5: Verify it works
Within a minute the migration Job completes and both replicas are running:
kubectl -n laravel get jobs,pods
kubectl -n laravel logs job/laravel-migrate


Then talk to the Service through a port-forward. In production the app only answers requests for its APP_URL host, so send that as the Host header:
kubectl -n laravel port-forward svc/laravel 8080:80 &
curl -s -o /dev/null -w "%{http_code}\n" localhost:8080/up
curl -s -o /dev/null -w "%{http_code}\n" -H "Host: laravel-rust-k8s.cloider.app" localhost:8080/posts
The app is running in your cluster. Option 2 shows how to put it on the internet with HTTPS.
Option 2: deploy with the cloider CLI and get a free HTTPS subdomain
This time every step is in the terminal. Install the CLI and log in first: curl -fsSL https://cloider.com/install.sh | sh, then cloider login.
Step 1: Dockerize the app
The Dockerfile from option 1 is already in the repository.
Step 2: Build and push to the Cloider container registry
Create a registry project, and let the CLI log docker in. cloider registry login makes a token for this machine and hands its secret to docker on stdin, so you never copy it:
cloider registry create laravel-rust-cli
cloider registry login

docker buildx build --platform linux/amd64 -t registry.cloider.com/laravel-rust-cli/blog:v1 --push .
Step 3: Deploy the app
Create the cluster and a database that only the cluster may reach:
cloider cluster create laravel-cli --wait
cloider db create laravel-cli-db --engine postgresql --trusted-source cluster:laravel-cli --wait

Point kubectl at the cluster and create the namespace:
cloider cluster kubeconfig laravel-cli --merge --use
kubectl create namespace laravel
Create the Secrets straight from the CLI's output, so neither the database password nor the registry token is ever printed:
DB=$(cloider db get laravel-cli-db -o json)
kubectl -n laravel create secret generic laravel-secrets \
--from-literal=APP_KEY="base64:$(openssl rand -base64 32)" \
--from-literal=DATABASE_URL="postgres://$(jq -r .database_user <<<$DB):$(cloider db password laravel-cli-db)@$(jq -r .private_host <<<$DB):$(jq -r .database_port <<<$DB)/$(jq -r .database_name <<<$DB)?sslmode=require"
TOKEN=$(cloider registry token create --label laravel-cli --project laravel-rust-cli --read-only -o json)
kubectl -n laravel create secret docker-registry cloider-registry --docker-server=registry.cloider.com \
--docker-username="$(jq -r .token.username <<<$TOKEN)" --docker-password="$(jq -r .secret <<<$TOKEN)"
Point the manifests at your image (your project name differs from the one in the repository), apply them and wait for the rollout:
sed -i '' 's#laravel-rust/blog#laravel-rust-cli/blog#' k8s/deployment.yaml k8s/migrate.yaml # on Linux: sed -i
kubectl apply -f k8s/
kubectl -n laravel rollout status deployment/laravel
Step 4: Expose it and get a free SSL subdomain
You don't need an Ingress controller or a load balancer. Claim a free cloider.app subdomain and add a target that routes it to the Service. Cloider serves it over HTTPS:
cloider cluster services laravel-cli
cloider domain create laravel-rust-k8s.cloider.app
cloider target create laravel-rust-k8s.cloider.app --cluster laravel-cli --service laravel/laravel

Open https://laravel-rust-k8s.cloider.app and write a post:


To ship a new version, push the image with a new tag, update it in the manifests and apply them again, after re-running the migration Job if you added a migration (kubectl -n laravel delete job laravel-migrate, then apply).
Option 3: let an AI coding agent deploy it
With the CLI installed and logged in, open the project in your AI coding agent and ask:
using cloider cli deploy this app to cloider kubernetes enginecloider --help points agents to docs.cloider.com/llms.txt, the deployment strategy they follow on Cloider. It tells them to start with cloider whoami, to use managed databases rather than running PostgreSQL in the cluster, and to use Kubernetes when you ask for it, as this prompt does. The commands are the ones in option 2, and the same commands are available as tools through the Cloider MCP server, cloider mcp. See AI coding agents in the docs.
Troubleshooting
ImagePullBackOff: the
cloider-registrysecret is missing from thelaravelnamespace, or its token can't read the project. Create a Pull only token for that project.exec format error: the image was built for arm64. Build with
--platform linux/amd64.400 Bad Request: the request's host isn't the
APP_URLink8s/config.yaml. Set it to the domain you route to the Service.500 on every page, with
relation "posts" does not existin the logs: the migration Job hasn't run, or failed. Checkkubectl -n laravel logs job/laravel-migrate.
What it costs
A cluster is billed for the CPU and memory its workloads use (and volumes or load balancers, if you add them), the registry by the gigabyte stored ($0.20 per GB a month), and the Hobby database plan is $3.99 a month. Everything is charged by the hour, and targets on a free subdomain cost nothing extra. A new account's welcome credit covers this guide. Delete the cluster, the database and the registry project when you're done.
Frequently asked questions
How do I run Laravel for Rust migrations on Kubernetes?
Run the binary's migrate command once as a Job (command ./myapp migrate --force) with the same image, ConfigMap and Secret as the Deployment, before or alongside the rollout.
How do pods in a Cloider cluster pull private images?
Create a Pull only token in the Cloider registry, store it as a kubernetes.io/dockerconfigjson Secret in the namespace, and reference it in imagePullSecrets.
Do I need an Ingress controller on Cloider Kubernetes?
No. Claim a domain or a free cloider.app subdomain and add a target that routes it to your Service. Cloider terminates HTTPS for you.
Which platform should I build the image for?
linux/amd64. On an Apple silicon Mac, build with docker buildx build --platform linux/amd64.

Comments