---
title: 'Deploy your Laravel App to Kubernetes with Serhii Tonkoshkuryk'
source: 'https://youtube.com/watch?v=JFaHMa0ZPYE'
video_id: 'JFaHMa0ZPYE'
date: 2026-06-30
duration_sec: 2614
---

# Deploy your Laravel App to Kubernetes with Serhii Tonkoshkuryk

> Source: [Deploy your Laravel App to Kubernetes with Serhii Tonkoshkuryk](https://youtube.com/watch?v=JFaHMa0ZPYE)

## Summary

Serhii Tonkoshkuryk presents a beginner-friendly guide to deploying a Laravel application on Kubernetes. The talk covers core Kubernetes concepts, key features like self-healing and scaling, and essential changes needed in a Laravel app for containerization.

### Key Points

- **Audience Knowledge Check** [0:00] — Speaker asks who has tried or knows about Kubernetes; most haven't, but he promises it's easy.
- **Disclaimer: Not Production-Ready** [0:11] — The demo is simplified; not intended for production use.
- **Kubernetes Popularity** [0:57] — Kubernetes is the second most-contributed open-source project globally, built with Go, running millions/billions of containers.
- **Pronunciation & Abbreviation** [1:45] — Explains the abbreviation 'k8s' (eight letters between K and S).
- **Core Functionality** [2:20] — Kubernetes manages complex, cloud-native applications, enabling easy deployment, scaling, rollouts, and rollbacks across clusters.
- **Why Kubernetes?** [3:14] — Described as the top cloud-native tool; the speaker's company has used it in production for over four years, solving scaling problems easily.
- **Auto Rollout & Rollback** [4:15] — Kubernetes automatically checks container readiness; if a health check fails, it rolls back the release transparently, ensuring zero downtime.
- **Service Discovery & Load Balancing** [5:45] — Built-in service discovery and load balancing abstract network details; you name services instead of IPs.
- **Storage Orchestration** [7:58] — Defining persistent volumes is simplified; you specify size in a deployment file, and Kubernetes provisions it.
- **Self-Healing with Horizon Example** [8:48] — A Laravel Horizon issue (stuck queue) was solved by a custom artisan command checking the master process; Kubernetes restarts the container if the probe fails.
- **Secret & Configuration Management** [13:17] — Secrets and configs are defined declaratively; allows easy migration between cloud providers and simplified security patching.
- **Scaling Demo** [15:27] — Shows manually adding a worker node via UI; mentions cluster autoscaling as an option.
- **App Changes for Containerization** [18:29] — Logs must go to stdout/stderr; static files to S3-compatible storage; sessions/cache to Redis (not files).
- **Docker & Deployment Files** [22:00] — Kubernetes works with containers (Docker recommended); you need a Dockerfile and deployment YAML files; recommends starting with docker-compose as a stepping stone.
- **Pre-Caching & Stateless Containers** [22:55] — All Laravel optimizations (views, routes, config) must be cached; the goal is a stateless container that can be deleted/recreated.
- **Ideal Deployment Architecture** [25:00] — Separate containers for web (Nginx + FPM), workers (queue, cron), and CLI; all state goes to external services (S3, Redis, DB).
- **Live Demo: Namespace & Secrets** [26:50] — Creates a namespace, applies secrets, config maps, then deploys Redis, MySQL with persistent volume claim, and finally the app service.
- **Docker Compose vs Kubernetes** [36:30] — Answering an audience question: yes, docker-compose is a good first step; Kubernetes YAML is similar but different syntax.
- **Ingress Creation & Final Deployment** [39:50] — Creates an Ingress with host 'laravel2', deploys the app, then creates a service. The app becomes accessible.
- **Horizontal Pod Autoscaling (HPA)** [41:55] — Shows an HPA configuration based on ingress metrics; can scale from 1 to 10 replicas; demo could not generate enough load to trigger scaling.

### Conclusion

Deploying Laravel on Kubernetes is achievable with some app adjustments (stdout logs, external storage, Redis for sessions/cache) and proper containerization. The talk demonstrates that Kubernetes provides self-healing, scaling, and simplified management for Laravel applications.

## Transcript

has deploy some larel to
kubernetes who is aware about the
kubernetes who tried who knows something
about it except Yanik Samuel you tried
it okay I've always been too afraid to
try Okay um it's easy I will show
you no um maybe a bit of disclaimer
everything I show here it's not a
production ready I try to make it as
simple as possible
because um as you can imagine it's not
enough in 30 minute to show how to
deploy an app and make it production
ready so yeah just a disclaimer uh don't
try it on production but my goal is here
to expire um inspire you to try
kubernetes uh try to deploy
kubernetes uh there are plenty of
options to try
kubernetes uh you can try it with cel or
with any other Cloud company they offer
you some trials so why not to try um
it's a actually the kubernetes is the
second
most
um like the most contributors into the
open- source project in the world so
it's quite huge it's quite huge I'm not
sure what is number one but the
communities is number
two um yeah and it's uh building Google
go uh it's run Million or billion
containers and U it's quite cool I will
explain later what is cool about it so
um yeah so people already ask how you
pronounce
kubernetes uh or um some people say uh
call it
k8s uh which is uh
abbreviation uh results from counting
the eight letters between K and
S don't ask why uh but yeah it's
actually
the uh The Tool uh which help uh manage
uh like the complex application it's a
cloud native tool um it can run on any
uh cloud provider or you can actually
even use it locally there is a mini Cube
version also you can play with it um I
will not go deep into all the components
of the kuber
nities uh but yeah you can check it
later uh but basically it's it's a tool
which allows you
to um deploy your application and scale
your application into the uh clusters
and it's quite easy to scale also it's
quite easy easy to uh roll back roll out
uh your applications um with a lot of
cool features so let me explain about
the features a bit more um yeah why why
the why kubernetes uh first of all it's
uh right now it's like the most
important Cloud native
tool
um I think it's like the top one for
cloud native for deploying the
applications uh it's pretty cool we
already used kubernetes on our
production for more than four years
already so um and to be honest I'm
actually the developer I'm not the
kubernetes expert uh but um the more I
use it the more I like it and sometimes
when we encounter some problems um it's
quite easy to solve also with scuber
niches which you cannot figure out how
to solve especially with the scaling so
yeah I will talk a bit later about the
scaling
part um yeah may just quickly I will uh
tell about the features of the
kubernetes so um the most cool and
important one is to uh automatically
roll out and roll back your application
um it's
uh so when you deploy to kubernetes
kubernetes can uh able to check uh the
liveness or um if your container let's
say is ready to be used in production
also it verifies it if uh like when you
push to production with
kubernetes um you basically have a zero
down time uh it's a I would say it's a
killer feature but it's like for
kubernetes it's a basic
feature uh uh and uh yeah it's how the
Roll Out roll backs also work so for
example if you try to roll out something
and the health check went wrong or there
is no connectivity to some service or um
yeah something else like I will show
later how to use them um it will just
automatically roll back the release so
um the clients will not see the issue
let's say or when you roll out the
kubernetes every time we push uh release
uh on our platform um again nobody see
it uh we have to announce it that we
pushed the
change um yeah also uh out of the box
there is a service Discovery and load
balancing so uh again it's a obstruction
for uh Cloud applications so you can uh
like deploy your app and this app can be
deployed to multiple nodes and have a
like a storage dedicated which can
connect it to this multiple nodes and uh
yeah it's all like automatically work
let's say um and uh for this you need a
service Discovery so for example when
you deploy a cluster of database uh you
don't need to specify the IP address of
your um R server or your MySQL service
you just uh write it in your um service
Discovery you just declare a service
it's ready and please push it to uh to
my kuber niches uh let me show you some
code how it how it actually works so for
example um the r service you basically
say name
report up red this one can be scaled and
uh
that's it in your EnV
file again you don't do this on
production all your secrets and
everything else should be keep uh as
Secrets uh but it's just something
you're familiar with with the EnV uh you
can just specify the here
ready cash cash store ready um the back
connection my SQL so it's a service that
you deploy uh with
kubernetes um we will deploy it so you
will see it the same with uh
database uh yeah here should be a
service
database so you just specify database
and you're ready to
go
um so there is also a storage
orchestration uh
again you it's it's
mostly um a hard topic for us as for a
cloud provider uh to provide you a
storage orchestration but for you it's
just uh you provide a deployment file
you
um you say that you need a persistent
volume how many gigs you apply this uh
file and you have a storage for example
if you need uh 10 gigs or you you need a
increase you you change it you apply the
configuration and that's it uh it just
works I will show
you uh
okay there is also uh selfhealing
functions
um so anybody here familiar with larel
Horizon
cool um Horizon is
cool actually Horizon um kind of solve
the issue with the uh cues like
especially if you need to scale your
cues or if you have some load it can
multiply processes but it's again
Horizon you uh deploy to one
server and
um and for example let's say your server
is infected or uh somebody got access to
your server what will you do
right uh it's a nightmare you don't want
to have this problem or
um or um the self-healing yeah why I'm
talking about self-healing we actually
encoun and in our app we had some
problem with Horizon so at some uh I
didn't find any issue in Internet uh I
upgraded it many times um at some point
the queue just stuck I mean you you open
Horizon you see it's running
but jobs are not
processing so um what you can do here
um uh or what or what we did here uh in
in larel sorry in the kubernetes uh you
can describe some uh command like The
Artisan common uh with the Horizon check
so basically it's a PHP code which
checks uh for the master process of
horizon if it's running if there is some
uh uh if there is a que uh which need to
be processed so that's that's just the
comment that we wrote
and it was actually our solution so um
you just specify to your uh
configuration of your P for Horizon that
you need
U
uh yeah you need to have some Readiness
probe check or livess prop check uh
which check if the container is okay if
it's ready if uh it's
running
um you can specify how often you want to
check this uh etc etc again you you
Google it how to do it but it's it was
our solution uh the kubernetes on the
background just run it before deploy it
to production also it just periodically
checks it and if uh The Horizon is stuck
it just delete the um delete the
container uh and deploy it and
it and it works very fast and it works
very fast so um it was our solution and
till that day it works but again
um we figured out that you don't run
Horizon on
kubernetes that was our also uh lesson
uh learned that you better run um
separate containers for separate cues
and again you can write your own uh
checks if you need them to verify if
it's okay if it's running uh yeah for
example if you see that uh you can also
configure in kubernetes if you have too
many jobs uh you can just
uh uh monitor it and you can Define the
after scaling so kubernetes can scale uh
processes or in in terms of kubernetes
it's containers it can scale containers
and to run multiple containers uh so
they can process uh a spike of
jobs uh when it's again back to normal
it can just reduce these containers and
it just
works uh believe
me again um so it's about self healing
also the secret and configuration
management um yeah um you can Define all
your secrets again you don't do it
uh like this one on
production
uh but there are many options
to um protect your secrets and manage
your SEC secrets with uh kubernetes also
like with the configs so you can have
just uh that many um deployment files
with a secrets with the
configurations and that's it you can
scale you can uh migrate easily to any
other cloud provider uh you don't need
to keep up with a server with a version
let's say that you have
a uh you figured out that ngx
uh no it's
uh X
yeah with a deployment file let's say
you figure out that uh this version of
engine X is uh that's the most recent
one uh the stable one uh if this version
having some security issue you just
update the version you apply it and
that's it that's your
fix uh so the same with u uh with your
app like with a Docker file uh with the
PHP version with any extension with a
composer version uh it's all declarative
so it's all I would say quite easy to to
maintain as
a as
environment
yeah uh what else what else
um also the scaling part um I will show
you a bit later but how you scale in
kuber niches or yeah I can actually show
it right now so here I I already created
a cluster uh just we have limited time
it takes some time to create a cluster
uh with the three worker
nodes um how you can scale it just press
plus uh in a in a pool you press
create
um and that's it and that and then it
that's it let me let me show you oh
sorry here so uh all the
kubernetes you mostly manage with a copl
app
um Let Me Maybe show you another
way so we have a control play node
this one is just to manage the
kubernetes itself and all your workloads
or or your app basically runs on the on
these three nodes and actually even if I
uh have my kuber niches
deployed and let's say something
happened with a with one of the node um
again the kubernetes can heal itself it
can
automatically uh try to spin up new node
or move all the workload to another
node
um it's all it it all works
automatically
um yeah actually it takes some time to
deploy uh Noe but you see it's already
here it's not not
ready but it it will be ready
soon um okay
that's how you scale kubernetes also
there is an option to uh scale you can
configure it and you can uh have out
scaling also not not just for the
containers or for the PS itself also for
the nodes so it also can be as a option
to
scale yeah it's
ready
um else
else um okay maybe let's let's
already um deploy our kubernetes uh our
LEL to
kubernetes um I just brought a few
important points uh what you have to
change in your app to to to have it uh
let's say container or
gr is ready is it
okay now basically you just need to uh
change the
login uh not just logs but actually
everything what uh in your app you you
get used to write to the file for
example SQ light or uh log right you
just most of the time or out of the
boook larel writes into the files
um it's recommended to use estad
out then all the logs or all the
um yeah everything what you have what
you want to log or all the errors will
go to estad out and then uh you can read
it uh from the kubernetes or you can
install
some uh extension to kubernetes let's
say let uh for example the
pruse or data dog uh where you can
basically collect all the logs from all
your apps all your containers and you
can filter by like engine X or fpm or
app1 app2 um Etc but that's quite
important part also
um
yeah so you change it in the
configuration to ested out and and log
channel out that's
it uh also with the static files as I
already mentioned that um for example if
you upload some files to and you put it
in
a within the app some files like I don't
know the picture or the Avatar you
upload it or the some
forms um it's recommended that you can
use some S3
storage um it can be open source like
Mino or uh yeah it can be for example
AWS everybody know knows and within the
larel
documentation there is already driver
it's quite easy just check the
documentation
um yeah and uh cash and
session also uh
by uh out of the box
larel um caches everything try to cat
everything and try
to uh like all the sessions are kept as
files so you need to change it it's also
quite easy to do uh I recommend redis
but it also can be a database uh for
cash it also can be uh if I'm not
mistaken M
cached um but yeah you also have to
change it so for example you install the
PHP redis or PHP extension for
redis and uh yeah you change your
session driver your cach store to
redies um and that's and that's
it um and yeah
uh to deploy it to
kubernetes um actually kubernetes don't
know how to deploy any app is either
it's nodejs or um Java application uh
kuber niches know how to work with
containers so you have to prepare some
Docker file uh you need to um
yeah put your app into container into
Docker I don't recommend
sale uh sale is not for uh production
ready this is one is also not a
production but it works and I will show
you yeah
uh just Google it there are plenty of
options uh how to do
it uh but yeah so also important Point
here uh to mention is uh you need to
um make all the uh dump of to load
optimizations and PR to optimize uh
basically to cach all your uh views uh
all your uh routes everything what's
need to be cached in larel uh you can do
it um with speech pchas unoptimized so
the container itself is
stateless uh the goal is is that your
container you can delete and create
again uh and for example you can
have usually you have multiple
containers for your app uh running at
the same time and in kubernetes there is
the load balancer and the service
Discovery so it automatically load
balance between the containers so if one
container is uh something happened with
one container or you deploy it and it's
not working
um then kuber is just delete it and roll
back so uh yeah there is no State All
State you put into S3 storage or into
regist or into
database yeah that's also quite
important uh so in a container before
you deploy to kubernetes you make all
the optimization and uh caching so it's
just in the container is on read
only uh um that's that's
important um with this one I already
explained and that's actually how the
Horizon check command Works uh it's a
Artisan command which checks for the uh
process uh Master process if it's
running then it's
okay uh it just returns zero if not it
returns one and kubernetes know that I
need to redeploy the
app um and that's actually I would
say ideal picture how you deploy to
kubernetes so you have some code
base uh you build your
frent uh all the static files all what
you have you serve it with engine X
let's say and you build also um like the
back end with a composer you build all
your p packages you uh you use fbm to uh
yeah to have as an En point for
PHP uh so for all your web
requests uh also for all your static
files and for everything else like for
the que or for migrations or like for
all CLI tools
or basically you have the same app as
you do with larel but it's a different
container where you run
all your CLI stuff like like your uh
sker command or uh your Q workers uh the
same with
cron uh it's also recommended to use
um there is a tool in kubernetes for uh
schedular uh and how how this one is
called for
Schuler I think it's just called for
true yeah it's basically it's a Scher in
a kuber niches where you make all your
schedules so you have dedicated logs
separately for each uh job you
run
um that's
it so let's do some real real
deployment
uh yeah let me quickly check something
[Music]
get
um yeah you you first first of all you
need to create a name space um and you
can have multiple name spaces you can
also uh change or Define some policies
like uh within the cluster there can be
a production cluster stage cluster or
something else uh and yeah and you can
give for example developers access just
to the stage
environment and not the production
environment so yeah you can uh that
that's just abstraction within the
kubernetes
so let's create a name
space
l Switzerland
okay and
yeah
what sorry something went
wrong
to okay let's let's switch it let's
switch it here
um what I wanted just to do is to set
the context for my
um um for my CLI tool to know in which
namespace I'm working so I just created
the namespace larel
[Music]
swiland okay and within the let's check
if it works yeah there is no yet any
resource in this name space uh we'll
shortly fix it but before we pick this
one uh let
me quickly run
some quick fix
to
so long story short uh with within the
hour uh kuber
niches um we have very cool uh
enforcements about security
and yeah just to make it simple I want
to uh disable some of them so yeah it it
will go smooth but don't do it in
production it's just uh for example we
will use the latest tag in the docker
within the docker file so it's something
which is not recommended to do on
production because let's say somebody
got access to your Docker Hub and push
uh
vulnerability uh like
the like it happened with the some open
source SSH package um yeah like your app
just pull the re recent tag and uh
nobody see it uh like it just
automatically provision it so it's not
recommend that you have to fix the
version so that's that's like one of the
reason and another is like you don't
need to run the Pudo within the
container but here is just demonstration
Pro uh so yeah we will do
it so yeah
Works
uh basically I already prepared some all
all deployment files
um Let Me Maybe show you it here yeah so
first of all you need to Define all your
secret
um it's just for us to
see um actually other deployments um
rely on these
secrets so I have to apply this uh how
to do it is just with scoop CTL apply
minus F and I just specify the pass for
for the file so it's a secret
yo okay secret is created next I need to
uh uh deploy um
configs so I have a engine X
configuration um it's pretty standard
again it's not recommended for
production but good for us
so yeah the config map is
created um yeah what else
yeah actually we can roll roll out all
the deployments I think um so let's
deploy
radi oopl
[Music]
applyf where
this
appointment okay that's just a warning
it's okay
it's actually it's about security but
it's okay for us get
pods so R is already running as you can
see before I did run this command there
was no any workload now we have a red
running
um for redis we also have to deploy a
service so we have to declare that we
have an app R and and yeah so the app
can Discover it uh within the port and
the name it's like
DNS but internal in the
kubernetes right this this yeah okay
service is
ready um what else we need I guess we
need a database right uh here is my
deployment for my SQL
8 um again here's some secrets you don't
do it in
production um and the service is already
within this
deployment so it will
automatically uh deploy and yeah what
else is important you need to have a
persistent volume so then
your
um your my SQL will have
a will have a storage uh like the
folder let's call it like that where you
can store your data and when you Rec
create my SQL or if you scale my SQL
then uh your data data will be saved uh
it will will not destroy it that's how
you can uh make a persistent volume
claim and it's different within the
different Cloud providers uh you need to
know the storage class name in our case
we have our own uh class for persistent
storages so yeah um that's just
important to mention so again the
same um my
SQL you can see that
it's uh create an app my
SQL uh service is created persistent
volume is created and even some secret
is
created within all the deployment file
actually I you can put it all together
in one file
but yeah you don't do
it um okay what else um it's would sorry
if I dropped but with this with these
files like is that what I have now in my
Docker
compost
like
uh do you get what I'm asking you can
you can even have it in a separate
repository yes but the functionality of
all these services that you defined
there it kind of is a parallel like
because I never worked with kubernetes I
work with Docker right yeah and I see
you use the docker file still to do this
the little step
but I'm I'm trying to understand how
Docker and kubernetes work with each
other right so instead of me having to
write a Docker compost if I'm using
kubernetes I write this kubernetes
directory with the different services in
there um I recommend you to write Docker
compos first yeah okay uh so it's like
more easy and and if you have it all in
the docker compose then it's uh it's
already a good starting point to move to
okay uh kubernetes and then you for
example here I just have a Docker file
uh I I actually already pre-build this
uh Docker file and pushed it to our uh
Docker Hub So within the deployment file
you just sptify that we use this image
sellon a larel latest
okay this is also the reason why we uh
yeah we change the security policy so
it's not recommended to use the
latest
uh yeah so you make your um Docker
compos you prepare all the necessary
Services containers storages Etc and
then it will be much easier for you to
Define all these deployment files um
it's just a different syntax but it's
quite easy I would
say um at
least nothing complicated is here uh
with the I started first with the radius
with my SQL uh because it's U yeah it's
just an engine X image it's it's quite
uh I would say it's like a standard to
use with the LL also the
fpm and
Alpine that's how you do it uh we tried
also Octan I don't know if you tried it
or not uh it's kind of cool
idea
but again with the kubernetes it's much
more reliable so you can use old school
Technologies containerize it scale
it uh and there Works they works like
aain it's much harder to uh especially
if use some other dependencies or
extensions PHP
extensions uh to make it work and yeah
uh to make
it scale the kubernetes you can scale
everything what you can containerize if
your container is
stateless then you good to go I would
say okay sorry um just bit maybe lost
but I deployed already my SQL
Ries uh secret yeah uh I think we
can deploy um the
Ingress uh Ingress it's um it's like a
networking um for your um kubernetes so
I already deployed one of
the uh clusters but I just change it
here the host um maybe I just call it
larel
2 and that's it Port
80 uh the app called LEL yeah think it's
okay okay grace is
created um yeah we can deploy an app
again here is just uh engine
X port a with the already deployed uh
config for engine
X and uh app it's already built and
pushed to dockerhub
uh so we can already use it
yeah appointment is
created let me show
you uh container is
created let's run it again it's already
running
uh what
else it looks like I forget
something here okay maybe let's try just
try it so within engress we use this
URL let's go to the
browser
okay as you can see I missed already
something
um I think I didn't run
the I also need to uh have a service for
my app right
so servic is created let's try
again
works that's what I deployed before it
also works yeah so it's two apps within
the same cluster yeah ah of the scaling
part
um it's a
example how you can horizontally scale
your
app um so normally you are limited by
resources of the server like CPU Ram or
uh storage so you scale B based on that
based on
that um so here I just as an example
specify
that um I use a metric as an Ingress
and if we have too many requests let's
scale it so the minimum we can have one
replica but maximum it can be
10 uh so in case if we have huge traffic
the kubernetes can scale it uh
unfortunately when I tried it I
didn't um make enough load so it to show
you how it really
scales uh but yeah that's actually how
how it works um so so I cannot show it
to you
today uh we had good ideas with Yanik
how to do it by based by CPU but I run
it another problem with that so I just
decided that I better show you how it
works and and I show you as an example
how you can do it but basically it's
again you just Define the some
configuration for your
deployment and like the metric you want
to use and then and that's
it so yeah I think that's it thank you
