TubeSum ← Transcribe a video

Deploy your Laravel App to Kubernetes with Serhii Tonkoshkuryk

0h 43m video Transcribed Jun 30, 2026 S Swiss Laravel Association
Beginner 12 min read For: PHP/Laravel developers new to Kubernetes who want a practical, hands-on introduction to deploying a Laravel app in a containerized environment.
1.5K
Views
28
Likes
10
Comments
0
Dislikes
2.5%
📈 Moderate

AI 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.

[0:00]
Audience Knowledge Check

Speaker asks who has tried or knows about Kubernetes; most haven't, but he promises it's easy.

[0:11]
Disclaimer: Not Production-Ready

The demo is simplified; not intended for production use.

[0:57]
Kubernetes Popularity

Kubernetes is the second most-contributed open-source project globally, built with Go, running millions/billions of containers.

[1:45]
Pronunciation & Abbreviation

Explains the abbreviation 'k8s' (eight letters between K and S).

[2:20]
Core Functionality

Kubernetes manages complex, cloud-native applications, enabling easy deployment, scaling, rollouts, and rollbacks across clusters.

[3:14]
Why Kubernetes?

Described as the top cloud-native tool; the speaker's company has used it in production for over four years, solving scaling problems easily.

[4:15]
Auto Rollout & Rollback

Kubernetes automatically checks container readiness; if a health check fails, it rolls back the release transparently, ensuring zero downtime.

[5:45]
Service Discovery & Load Balancing

Built-in service discovery and load balancing abstract network details; you name services instead of IPs.

[7:58]
Storage Orchestration

Defining persistent volumes is simplified; you specify size in a deployment file, and Kubernetes provisions it.

[8:48]
Self-Healing with Horizon Example

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.

[13:17]
Secret & Configuration Management

Secrets and configs are defined declaratively; allows easy migration between cloud providers and simplified security patching.

[15:27]
Scaling Demo

Shows manually adding a worker node via UI; mentions cluster autoscaling as an option.

[18:29]
App Changes for Containerization

Logs must go to stdout/stderr; static files to S3-compatible storage; sessions/cache to Redis (not files).

[22:00]
Docker & Deployment Files

Kubernetes works with containers (Docker recommended); you need a Dockerfile and deployment YAML files; recommends starting with docker-compose as a stepping stone.

[22:55]
Pre-Caching & Stateless Containers

All Laravel optimizations (views, routes, config) must be cached; the goal is a stateless container that can be deleted/recreated.

[25:00]
Ideal Deployment Architecture

Separate containers for web (Nginx + FPM), workers (queue, cron), and CLI; all state goes to external services (S3, Redis, DB).

[26:50]
Live Demo: Namespace & Secrets

Creates a namespace, applies secrets, config maps, then deploys Redis, MySQL with persistent volume claim, and finally the app service.

[36:30]
Docker Compose vs Kubernetes

Answering an audience question: yes, docker-compose is a good first step; Kubernetes YAML is similar but different syntax.

[39:50]
Ingress Creation & Final Deployment

Creates an Ingress with host 'laravel2', deploys the app, then creates a service. The app becomes accessible.

[41:55]
Horizontal Pod Autoscaling (HPA)

Shows an HPA configuration based on ingress metrics; can scale from 1 to 10 replicas; demo could not generate enough load to trigger scaling.

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.

Clickbait Check

85% Legit

"The title promises deploying a Laravel app to Kubernetes, and the talk delivers a full explanation and live demo, though it includes many disclaimers and the demo was slightly incomplete (scaling didn't trigger)."

Mentioned in this Video

Tutorial Checklist

1 0:00 Prepare a Dockerfile for your Laravel application and push the image to a registry (e.g., Docker Hub).
2 18:29 Change logging to stdout/stderr in Laravel config (set LOG_CHANNEL to stdout).
3 20:05 Move static file uploads to external S3-compatible storage (e.g., AWS S3 or MinIO).
4 20:55 Change session and cache drivers to Redis (install phpredis extension and set SESSION_DRIVER=redis, CACHE_STORE=redis).
5 22:55 Run Laravel optimization commands: php artisan optimize, config:cache, route:cache, view:cache.
6 25:00 Create separate containers for web (Nginx + FPM), workers (queue commands), and CLI/scheduler tasks.
7 26:50 Define Kubernetes secrets, config maps, and deployments for Redis, MySQL (with persistent volume claim), and your Laravel app.
8 27:00 Use kubectl apply -f <file> to create the namespace, secrets, config maps, and deployments in sequence.
9 39:10 Define an Ingress resource to expose your app externally with proper host and port.
10 41:55 Optionally define a HorizontalPodAutoscaler (HPA) for automatic scaling based on metrics (e.g., ingress requests).
11 36:10 Start with docker-compose to validate the setup before migrating to Kubernetes YAML files.

Study Flashcards (6)

What is the abbreviation for Kubernetes and why is it called that?

easy Click to reveal answer

K8s; because there are eight letters between 'K' and 's'.

1:45

What happens if a health check fails during a Kubernetes rollout?

medium Click to reveal answer

Kubernetes automatically rolls back the release, so clients see no downtime.

4:15

How does service discovery work in Kubernetes?

medium Click to reveal answer

You declare a service by name, and Kubernetes provides internal DNS resolution so apps can connect without IP addresses.

5:45

What are three crucial changes needed in a Laravel app for Kubernetes?

medium Click to reveal answer

1) Log to stdout/stderr, 2) Use external storage for uploads (e.g., S3), 3) Use Redis for sessions and cache.

18:29

Why should a container be stateless for Kubernetes?

medium Click to reveal answer

So it can be deleted and recreated freely; all state is stored externally (S3, Redis, database).

22:55

What is the recommended first step before writing Kubernetes YAML files?

easy Click to reveal answer

Create a docker-compose file to validate the setup; it's easier and provides a good starting point.

36:10

💡 Key Takeaways

💡

Zero-Downtime Rollouts & Auto-Rollback

Demonstrates a key operational benefit of Kubernetes: automated health checks and rollbacks prevent user-facing issues.

4:15
🔧

Self-Healing with Horizon

Shows a real-world Laravel problem (stuck queues) solved by Kubernetes probes, illustrating the practical value of container orchestration.

8:48
🔧

Essential App Modifications for Containerization

Provides a clear, actionable checklist for adapting a typical Laravel app to run in containers (stdout logs, S3 storage, Redis).

18:29
💡

Ideal Deployment Architecture

Outlines a clean separation of web, worker, and CLI containers with external state, a best practice for scalable and maintainable deployments.

25:00
💡

Docker Compose as a Stepping Stone

Recommends starting with docker-compose before migrating to Kubernetes, reducing the learning curve for newcomers.

36:30

✂️ Creator Tools: Viral Hooks

AI-generated clip ideas for Shorts based on the transcript

Deploy Laravel to Kubernetes? It's easy!

46s

Opens with a bold claim that Kubernetes is easy, hooking developers who are afraid to try it.

▶ Play Clip

Kubernetes Auto-Heals a Stuck Laravel Queue

55s

A real-world problem (Horizon queue stuck) solved by Kubernetes self-healing, showcasing practical value.

▶ Play Clip

Scaling Kubernetes Clusters in Seconds

50s

Live demo of adding a node with one click, visually demonstrating ease of scaling.

▶ Play Clip

Essential Changes for Laravel on Kubernetes

60s

Clear, actionable tips (logs to stdout, stateless containers) that every Laravel developer needs.

▶ Play Clip

Deploying Laravel to Kubernetes – It Works!

60s

Successful deployment demo with a live URL, providing satisfying proof that the process works.

▶ Play Clip

[00:00] has deploy some larel to

[00:03] kubernetes who is aware about the

[00:05] kubernetes who tried who knows something

[00:09] about it except Yanik Samuel you tried

[00:12] it okay I've always been too afraid to

[00:16] try Okay um it's easy I will show

[00:20] you no um maybe a bit of disclaimer

[00:23] everything I show here it's not a

[00:25] production ready I try to make it as

[00:28] simple as possible

[00:31] because um as you can imagine it's not

[00:34] enough in 30 minute to show how to

[00:36] deploy an app and make it production

[00:38] ready so yeah just a disclaimer uh don't

[00:42] try it on production but my goal is here

[00:46] to expire um inspire you to try

[00:50] kubernetes uh try to deploy

[00:52] kubernetes uh there are plenty of

[00:54] options to try

[00:56] kubernetes uh you can try it with cel or

[01:00] with any other Cloud company they offer

[01:03] you some trials so why not to try um

[01:07] it's a actually the kubernetes is the

[01:09] second

[01:11] most

[01:12] um like the most contributors into the

[01:16] open- source project in the world so

[01:20] it's quite huge it's quite huge I'm not

[01:22] sure what is number one but the

[01:24] communities is number

[01:26] two um yeah and it's uh building Google

[01:30] go uh it's run Million or billion

[01:33] containers and U it's quite cool I will

[01:38] explain later what is cool about it so

[01:42] um yeah so people already ask how you

[01:45] pronounce

[01:46] kubernetes uh or um some people say uh

[01:51] call it

[01:53] k8s uh which is uh

[01:56] abbreviation uh results from counting

[01:59] the eight letters between K and

[02:01] S don't ask why uh but yeah it's

[02:05] actually

[02:07] the uh The Tool uh which help uh manage

[02:13] uh like the complex application it's a

[02:16] cloud native tool um it can run on any

[02:22] uh cloud provider or you can actually

[02:25] even use it locally there is a mini Cube

[02:29] version also you can play with it um I

[02:33] will not go deep into all the components

[02:37] of the kuber

[02:38] nities uh but yeah you can check it

[02:42] later uh but basically it's it's a tool

[02:46] which allows you

[02:47] to um deploy your application and scale

[02:52] your application into the uh clusters

[02:55] and it's quite easy to scale also it's

[02:59] quite easy easy to uh roll back roll out

[03:04] uh your applications um with a lot of

[03:07] cool features so let me explain about

[03:11] the features a bit more um yeah why why

[03:15] the why kubernetes uh first of all it's

[03:18] uh right now it's like the most

[03:19] important Cloud native

[03:22] tool

[03:24] um I think it's like the top one for

[03:27] cloud native for deploying the

[03:30] applications uh it's pretty cool we

[03:32] already used kubernetes on our

[03:34] production for more than four years

[03:37] already so um and to be honest I'm

[03:41] actually the developer I'm not the

[03:43] kubernetes expert uh but um the more I

[03:49] use it the more I like it and sometimes

[03:51] when we encounter some problems um it's

[03:54] quite easy to solve also with scuber

[03:56] niches which you cannot figure out how

[03:59] to solve especially with the scaling so

[04:02] yeah I will talk a bit later about the

[04:04] scaling

[04:05] part um yeah may just quickly I will uh

[04:10] tell about the features of the

[04:12] kubernetes so um the most cool and

[04:16] important one is to uh automatically

[04:19] roll out and roll back your application

[04:23] um it's

[04:26] uh so when you deploy to kubernetes

[04:29] kubernetes can uh able to check uh the

[04:33] liveness or um if your container let's

[04:38] say is ready to be used in production

[04:41] also it verifies it if uh like when you

[04:46] push to production with

[04:48] kubernetes um you basically have a zero

[04:51] down time uh it's a I would say it's a

[04:55] killer feature but it's like for

[04:56] kubernetes it's a basic

[04:58] feature uh uh and uh yeah it's how the

[05:02] Roll Out roll backs also work so for

[05:04] example if you try to roll out something

[05:07] and the health check went wrong or there

[05:09] is no connectivity to some service or um

[05:13] yeah something else like I will show

[05:15] later how to use them um it will just

[05:19] automatically roll back the release so

[05:22] um the clients will not see the issue

[05:25] let's say or when you roll out the

[05:27] kubernetes every time we push uh release

[05:31] uh on our platform um again nobody see

[05:36] it uh we have to announce it that we

[05:39] pushed the

[05:41] change um yeah also uh out of the box

[05:45] there is a service Discovery and load

[05:47] balancing so uh again it's a obstruction

[05:52] for uh Cloud applications so you can uh

[05:57] like deploy your app and this app can be

[06:01] deployed to multiple nodes and have a

[06:04] like a storage dedicated which can

[06:06] connect it to this multiple nodes and uh

[06:11] yeah it's all like automatically work

[06:13] let's say um and uh for this you need a

[06:18] service Discovery so for example when

[06:20] you deploy a cluster of database uh you

[06:24] don't need to specify the IP address of

[06:26] your um R server or your MySQL service

[06:31] you just uh write it in your um service

[06:35] Discovery you just declare a service

[06:37] it's ready and please push it to uh to

[06:41] my kuber niches uh let me show you some

[06:44] code how it how it actually works so for

[06:47] example um the r service you basically

[06:52] say name

[06:54] report up red this one can be scaled and

[06:59] uh

[07:00] that's it in your EnV

[07:03] file again you don't do this on

[07:07] production all your secrets and

[07:09] everything else should be keep uh as

[07:12] Secrets uh but it's just something

[07:15] you're familiar with with the EnV uh you

[07:19] can just specify the here

[07:21] ready cash cash store ready um the back

[07:26] connection my SQL so it's a service that

[07:30] you deploy uh with

[07:32] kubernetes um we will deploy it so you

[07:34] will see it the same with uh

[07:38] database uh yeah here should be a

[07:44] service

[07:46] database so you just specify database

[07:50] and you're ready to

[07:51] go

[07:54] um so there is also a storage

[07:58] orchestration uh

[08:00] again you it's it's

[08:03] mostly um a hard topic for us as for a

[08:08] cloud provider uh to provide you a

[08:11] storage orchestration but for you it's

[08:14] just uh you provide a deployment file

[08:18] you

[08:19] um you say that you need a persistent

[08:23] volume how many gigs you apply this uh

[08:27] file and you have a storage for example

[08:30] if you need uh 10 gigs or you you need a

[08:34] increase you you change it you apply the

[08:37] configuration and that's it uh it just

[08:41] works I will show

[08:43] you uh

[08:46] okay there is also uh selfhealing

[08:50] functions

[08:52] um so anybody here familiar with larel

[08:57] Horizon

[09:01] cool um Horizon is

[09:04] cool actually Horizon um kind of solve

[09:08] the issue with the uh cues like

[09:11] especially if you need to scale your

[09:15] cues or if you have some load it can

[09:18] multiply processes but it's again

[09:20] Horizon you uh deploy to one

[09:24] server and

[09:27] um and for example let's say your server

[09:31] is infected or uh somebody got access to

[09:35] your server what will you do

[09:38] right uh it's a nightmare you don't want

[09:42] to have this problem or

[09:45] um or um the self-healing yeah why I'm

[09:50] talking about self-healing we actually

[09:52] encoun and in our app we had some

[09:55] problem with Horizon so at some uh I

[09:59] didn't find any issue in Internet uh I

[10:02] upgraded it many times um at some point

[10:06] the queue just stuck I mean you you open

[10:09] Horizon you see it's running

[10:12] but jobs are not

[10:14] processing so um what you can do here

[10:19] um uh or what or what we did here uh in

[10:24] in larel sorry in the kubernetes uh you

[10:28] can describe some uh command like The

[10:32] Artisan common uh with the Horizon check

[10:36] so basically it's a PHP code which

[10:39] checks uh for the master process of

[10:41] horizon if it's running if there is some

[10:46] uh uh if there is a que uh which need to

[10:51] be processed so that's that's just the

[10:53] comment that we wrote

[10:56] and it was actually our solution so um

[11:01] you just specify to your uh

[11:04] configuration of your P for Horizon that

[11:08] you need

[11:09] U

[11:11] uh yeah you need to have some Readiness

[11:14] probe check or livess prop check uh

[11:16] which check if the container is okay if

[11:20] it's ready if uh it's

[11:22] running

[11:24] um you can specify how often you want to

[11:27] check this uh etc etc again you you

[11:31] Google it how to do it but it's it was

[11:34] our solution uh the kubernetes on the

[11:37] background just run it before deploy it

[11:40] to production also it just periodically

[11:44] checks it and if uh The Horizon is stuck

[11:48] it just delete the um delete the

[11:53] container uh and deploy it and

[11:56] it and it works very fast and it works

[12:00] very fast so um it was our solution and

[12:05] till that day it works but again

[12:09] um we figured out that you don't run

[12:13] Horizon on

[12:15] kubernetes that was our also uh lesson

[12:18] uh learned that you better run um

[12:21] separate containers for separate cues

[12:25] and again you can write your own uh

[12:28] checks if you need them to verify if

[12:31] it's okay if it's running uh yeah for

[12:34] example if you see that uh you can also

[12:37] configure in kubernetes if you have too

[12:39] many jobs uh you can just

[12:43] uh uh monitor it and you can Define the

[12:47] after scaling so kubernetes can scale uh

[12:52] processes or in in terms of kubernetes

[12:55] it's containers it can scale containers

[12:58] and to run multiple containers uh so

[13:02] they can process uh a spike of

[13:07] jobs uh when it's again back to normal

[13:11] it can just reduce these containers and

[13:13] it just

[13:14] works uh believe

[13:17] me again um so it's about self healing

[13:20] also the secret and configuration

[13:24] management um yeah um you can Define all

[13:29] your secrets again you don't do it

[13:33] uh like this one on

[13:37] production

[13:39] uh but there are many options

[13:42] to um protect your secrets and manage

[13:46] your SEC secrets with uh kubernetes also

[13:49] like with the configs so you can have

[13:53] just uh that many um deployment files

[13:58] with a secrets with the

[14:00] configurations and that's it you can

[14:03] scale you can uh migrate easily to any

[14:07] other cloud provider uh you don't need

[14:10] to keep up with a server with a version

[14:14] let's say that you have

[14:16] a uh you figured out that ngx

[14:20] uh no it's

[14:25] uh X

[14:29] yeah with a deployment file let's say

[14:31] you figure out that uh this version of

[14:34] engine X is uh that's the most recent

[14:37] one uh the stable one uh if this version

[14:41] having some security issue you just

[14:45] update the version you apply it and

[14:49] that's it that's your

[14:51] fix uh so the same with u uh with your

[14:56] app like with a Docker file uh with the

[15:00] PHP version with any extension with a

[15:03] composer version uh it's all declarative

[15:07] so it's all I would say quite easy to to

[15:12] maintain as

[15:13] a as

[15:16] environment

[15:19] yeah uh what else what else

[15:24] um also the scaling part um I will show

[15:29] you a bit later but how you scale in

[15:32] kuber niches or yeah I can actually show

[15:34] it right now so here I I already created

[15:37] a cluster uh just we have limited time

[15:40] it takes some time to create a cluster

[15:43] uh with the three worker

[15:46] nodes um how you can scale it just press

[15:50] plus uh in a in a pool you press

[15:55] create

[15:57] um and that's it and that and then it

[16:00] that's it let me let me show you oh

[16:05] sorry here so uh all the

[16:11] kubernetes you mostly manage with a copl

[16:15] app

[16:17] um Let Me Maybe show you another

[16:25] way so we have a control play node

[16:29] this one is just to manage the

[16:32] kubernetes itself and all your workloads

[16:36] or or your app basically runs on the on

[16:40] these three nodes and actually even if I

[16:44] uh have my kuber niches

[16:46] deployed and let's say something

[16:48] happened with a with one of the node um

[16:52] again the kubernetes can heal itself it

[16:55] can

[16:56] automatically uh try to spin up new node

[17:00] or move all the workload to another

[17:02] node

[17:04] um it's all it it all works

[17:08] automatically

[17:10] um yeah actually it takes some time to

[17:13] deploy uh Noe but you see it's already

[17:18] here it's not not

[17:20] ready but it it will be ready

[17:26] soon um okay

[17:29] that's how you scale kubernetes also

[17:31] there is an option to uh scale you can

[17:35] configure it and you can uh have out

[17:37] scaling also not not just for the

[17:40] containers or for the PS itself also for

[17:44] the nodes so it also can be as a option

[17:49] to

[17:50] scale yeah it's

[17:54] ready

[17:56] um else

[18:00] else um okay maybe let's let's

[18:06] already um deploy our kubernetes uh our

[18:11] LEL to

[18:12] kubernetes um I just brought a few

[18:16] important points uh what you have to

[18:21] change in your app to to to have it uh

[18:26] let's say container or

[18:29] gr is ready is it

[18:35] okay now basically you just need to uh

[18:39] change the

[18:40] login uh not just logs but actually

[18:44] everything what uh in your app you you

[18:47] get used to write to the file for

[18:49] example SQ light or uh log right you

[18:53] just most of the time or out of the

[18:55] boook larel writes into the files

[18:59] um it's recommended to use estad

[19:04] out then all the logs or all the

[19:10] um yeah everything what you have what

[19:13] you want to log or all the errors will

[19:15] go to estad out and then uh you can read

[19:19] it uh from the kubernetes or you can

[19:22] install

[19:23] some uh extension to kubernetes let's

[19:26] say let uh for example the

[19:29] pruse or data dog uh where you can

[19:34] basically collect all the logs from all

[19:36] your apps all your containers and you

[19:39] can filter by like engine X or fpm or

[19:43] app1 app2 um Etc but that's quite

[19:48] important part also

[19:52] um

[19:53] yeah so you change it in the

[19:56] configuration to ested out and and log

[19:59] channel out that's

[20:02] it uh also with the static files as I

[20:06] already mentioned that um for example if

[20:10] you upload some files to and you put it

[20:13] in

[20:14] a within the app some files like I don't

[20:18] know the picture or the Avatar you

[20:20] upload it or the some

[20:22] forms um it's recommended that you can

[20:26] use some S3

[20:29] storage um it can be open source like

[20:33] Mino or uh yeah it can be for example

[20:36] AWS everybody know knows and within the

[20:40] larel

[20:41] documentation there is already driver

[20:44] it's quite easy just check the

[20:48] documentation

[20:51] um yeah and uh cash and

[20:55] session also uh

[21:00] by uh out of the box

[21:03] larel um caches everything try to cat

[21:07] everything and try

[21:10] to uh like all the sessions are kept as

[21:15] files so you need to change it it's also

[21:18] quite easy to do uh I recommend redis

[21:22] but it also can be a database uh for

[21:26] cash it also can be uh if I'm not

[21:29] mistaken M

[21:31] cached um but yeah you also have to

[21:35] change it so for example you install the

[21:39] PHP redis or PHP extension for

[21:44] redis and uh yeah you change your

[21:46] session driver your cach store to

[21:50] redies um and that's and that's

[21:55] it um and yeah

[22:00] uh to deploy it to

[22:02] kubernetes um actually kubernetes don't

[22:05] know how to deploy any app is either

[22:09] it's nodejs or um Java application uh

[22:14] kuber niches know how to work with

[22:16] containers so you have to prepare some

[22:20] Docker file uh you need to um

[22:25] yeah put your app into container into

[22:29] Docker I don't recommend

[22:32] sale uh sale is not for uh production

[22:36] ready this is one is also not a

[22:38] production but it works and I will show

[22:42] you yeah

[22:45] uh just Google it there are plenty of

[22:47] options uh how to do

[22:50] it uh but yeah so also important Point

[22:54] here uh to mention is uh you need to

[22:59] um make all the uh dump of to load

[23:03] optimizations and PR to optimize uh

[23:07] basically to cach all your uh views uh

[23:10] all your uh routes everything what's

[23:14] need to be cached in larel uh you can do

[23:17] it um with speech pchas unoptimized so

[23:21] the container itself is

[23:24] stateless uh the goal is is that your

[23:27] container you can delete and create

[23:30] again uh and for example you can

[23:34] have usually you have multiple

[23:37] containers for your app uh running at

[23:40] the same time and in kubernetes there is

[23:43] the load balancer and the service

[23:45] Discovery so it automatically load

[23:47] balance between the containers so if one

[23:51] container is uh something happened with

[23:54] one container or you deploy it and it's

[23:57] not working

[23:59] um then kuber is just delete it and roll

[24:02] back so uh yeah there is no State All

[24:06] State you put into S3 storage or into

[24:09] regist or into

[24:11] database yeah that's also quite

[24:13] important uh so in a container before

[24:16] you deploy to kubernetes you make all

[24:19] the optimization and uh caching so it's

[24:23] just in the container is on read

[24:27] only uh um that's that's

[24:30] important um with this one I already

[24:33] explained and that's actually how the

[24:36] Horizon check command Works uh it's a

[24:40] Artisan command which checks for the uh

[24:45] process uh Master process if it's

[24:48] running then it's

[24:50] okay uh it just returns zero if not it

[24:54] returns one and kubernetes know that I

[24:58] need to redeploy the

[25:00] app um and that's actually I would

[25:05] say ideal picture how you deploy to

[25:09] kubernetes so you have some code

[25:12] base uh you build your

[25:14] frent uh all the static files all what

[25:17] you have you serve it with engine X

[25:21] let's say and you build also um like the

[25:25] back end with a composer you build all

[25:28] your p packages you uh you use fbm to uh

[25:34] yeah to have as an En point for

[25:37] PHP uh so for all your web

[25:40] requests uh also for all your static

[25:43] files and for everything else like for

[25:46] the que or for migrations or like for

[25:49] all CLI tools

[25:51] or basically you have the same app as

[25:54] you do with larel but it's a different

[25:57] container where you run

[25:58] all your CLI stuff like like your uh

[26:03] sker command or uh your Q workers uh the

[26:08] same with

[26:09] cron uh it's also recommended to use

[26:14] um there is a tool in kubernetes for uh

[26:18] schedular uh and how how this one is

[26:22] called for

[26:25] Schuler I think it's just called for

[26:28] true yeah it's basically it's a Scher in

[26:31] a kuber niches where you make all your

[26:34] schedules so you have dedicated logs

[26:36] separately for each uh job you

[26:40] run

[26:42] um that's

[26:44] it so let's do some real real

[26:51] deployment

[26:53] uh yeah let me quickly check something

[26:58] [Music]

[27:03] get

[27:04] um yeah you you first first of all you

[27:07] need to create a name space um and you

[27:11] can have multiple name spaces you can

[27:13] also uh change or Define some policies

[27:17] like uh within the cluster there can be

[27:20] a production cluster stage cluster or

[27:24] something else uh and yeah and you can

[27:29] give for example developers access just

[27:31] to the stage

[27:32] environment and not the production

[27:34] environment so yeah you can uh that

[27:39] that's just abstraction within the

[27:41] kubernetes

[27:42] so let's create a name

[27:50] space

[27:55] l Switzerland

[28:03] okay and

[28:11] yeah

[28:15] what sorry something went

[28:19] wrong

[28:23] to okay let's let's switch it let's

[28:26] switch it here

[28:31] um what I wanted just to do is to set

[28:34] the context for my

[28:37] um um for my CLI tool to know in which

[28:42] namespace I'm working so I just created

[28:45] the namespace larel

[28:47] [Music]

[28:49] swiland okay and within the let's check

[28:54] if it works yeah there is no yet any

[28:57] resource in this name space uh we'll

[29:01] shortly fix it but before we pick this

[29:04] one uh let

[29:06] me quickly run

[29:09] some quick fix

[29:12] to

[29:14] so long story short uh with within the

[29:18] hour uh kuber

[29:21] niches um we have very cool uh

[29:25] enforcements about security

[29:28] and yeah just to make it simple I want

[29:31] to uh disable some of them so yeah it it

[29:35] will go smooth but don't do it in

[29:37] production it's just uh for example we

[29:41] will use the latest tag in the docker

[29:45] within the docker file so it's something

[29:48] which is not recommended to do on

[29:50] production because let's say somebody

[29:52] got access to your Docker Hub and push

[29:55] uh

[29:56] vulnerability uh like

[29:59] the like it happened with the some open

[30:02] source SSH package um yeah like your app

[30:07] just pull the re recent tag and uh

[30:10] nobody see it uh like it just

[30:14] automatically provision it so it's not

[30:16] recommend that you have to fix the

[30:18] version so that's that's like one of the

[30:21] reason and another is like you don't

[30:23] need to run the Pudo within the

[30:25] container but here is just demonstration

[30:28] Pro uh so yeah we will do

[30:34] it so yeah

[30:38] Works

[30:42] uh basically I already prepared some all

[30:45] all deployment files

[30:48] um Let Me Maybe show you it here yeah so

[30:55] first of all you need to Define all your

[30:57] secret

[31:00] um it's just for us to

[31:04] see um actually other deployments um

[31:08] rely on these

[31:10] secrets so I have to apply this uh how

[31:13] to do it is just with scoop CTL apply

[31:16] minus F and I just specify the pass for

[31:20] for the file so it's a secret

[31:24] yo okay secret is created next I need to

[31:31] uh uh deploy um

[31:35] configs so I have a engine X

[31:38] configuration um it's pretty standard

[31:41] again it's not recommended for

[31:43] production but good for us

[31:51] so yeah the config map is

[31:54] created um yeah what else

[32:00] yeah actually we can roll roll out all

[32:03] the deployments I think um so let's

[32:07] deploy

[32:10] radi oopl

[32:13] [Music]

[32:16] applyf where

[32:18] this

[32:21] appointment okay that's just a warning

[32:25] it's okay

[32:30] it's actually it's about security but

[32:33] it's okay for us get

[32:37] pods so R is already running as you can

[32:41] see before I did run this command there

[32:45] was no any workload now we have a red

[32:48] running

[32:49] um for redis we also have to deploy a

[32:53] service so we have to declare that we

[32:56] have an app R and and yeah so the app

[32:59] can Discover it uh within the port and

[33:03] the name it's like

[33:06] DNS but internal in the

[33:17] kubernetes right this this yeah okay

[33:22] service is

[33:25] ready um what else we need I guess we

[33:28] need a database right uh here is my

[33:31] deployment for my SQL

[33:35] 8 um again here's some secrets you don't

[33:40] do it in

[33:42] production um and the service is already

[33:45] within this

[33:47] deployment so it will

[33:49] automatically uh deploy and yeah what

[33:52] else is important you need to have a

[33:55] persistent volume so then

[33:58] your

[34:00] um your my SQL will have

[34:04] a will have a storage uh like the

[34:08] folder let's call it like that where you

[34:11] can store your data and when you Rec

[34:13] create my SQL or if you scale my SQL

[34:16] then uh your data data will be saved uh

[34:20] it will will not destroy it that's how

[34:22] you can uh make a persistent volume

[34:25] claim and it's different within the

[34:29] different Cloud providers uh you need to

[34:31] know the storage class name in our case

[34:34] we have our own uh class for persistent

[34:38] storages so yeah um that's just

[34:42] important to mention so again the

[34:50] same um my

[34:55] SQL you can see that

[34:58] it's uh create an app my

[35:01] SQL uh service is created persistent

[35:04] volume is created and even some secret

[35:08] is

[35:08] created within all the deployment file

[35:12] actually I you can put it all together

[35:14] in one file

[35:16] but yeah you don't do

[35:19] it um okay what else um it's would sorry

[35:26] if I dropped but with this with these

[35:29] files like is that what I have now in my

[35:32] Docker

[35:34] compost

[35:35] like

[35:37] uh do you get what I'm asking you can

[35:40] you can even have it in a separate

[35:43] repository yes but the functionality of

[35:45] all these services that you defined

[35:47] there it kind of is a parallel like

[35:50] because I never worked with kubernetes I

[35:52] work with Docker right yeah and I see

[35:54] you use the docker file still to do this

[35:56] the little step

[35:58] but I'm I'm trying to understand how

[35:59] Docker and kubernetes work with each

[36:01] other right so instead of me having to

[36:04] write a Docker compost if I'm using

[36:06] kubernetes I write this kubernetes

[36:09] directory with the different services in

[36:11] there um I recommend you to write Docker

[36:16] compos first yeah okay uh so it's like

[36:20] more easy and and if you have it all in

[36:22] the docker compose then it's uh it's

[36:26] already a good starting point to move to

[36:30] okay uh kubernetes and then you for

[36:33] example here I just have a Docker file

[36:37] uh I I actually already pre-build this

[36:42] uh Docker file and pushed it to our uh

[36:45] Docker Hub So within the deployment file

[36:49] you just sptify that we use this image

[36:53] sellon a larel latest

[36:58] okay this is also the reason why we uh

[37:02] yeah we change the security policy so

[37:05] it's not recommended to use the

[37:09] latest

[37:10] uh yeah so you make your um Docker

[37:16] compos you prepare all the necessary

[37:20] Services containers storages Etc and

[37:24] then it will be much easier for you to

[37:27] Define all these deployment files um

[37:30] it's just a different syntax but it's

[37:34] quite easy I would

[37:35] say um at

[37:37] least nothing complicated is here uh

[37:40] with the I started first with the radius

[37:43] with my SQL uh because it's U yeah it's

[37:47] just an engine X image it's it's quite

[37:51] uh I would say it's like a standard to

[37:54] use with the LL also the

[37:59] fpm and

[38:01] Alpine that's how you do it uh we tried

[38:05] also Octan I don't know if you tried it

[38:08] or not uh it's kind of cool

[38:11] idea

[38:13] but again with the kubernetes it's much

[38:16] more reliable so you can use old school

[38:19] Technologies containerize it scale

[38:23] it uh and there Works they works like

[38:27] aain it's much harder to uh especially

[38:32] if use some other dependencies or

[38:35] extensions PHP

[38:37] extensions uh to make it work and yeah

[38:41] uh to make

[38:42] it scale the kubernetes you can scale

[38:46] everything what you can containerize if

[38:48] your container is

[38:50] stateless then you good to go I would

[38:55] say okay sorry um just bit maybe lost

[39:00] but I deployed already my SQL

[39:03] Ries uh secret yeah uh I think we

[39:07] can deploy um the

[39:12] Ingress uh Ingress it's um it's like a

[39:16] networking um for your um kubernetes so

[39:23] I already deployed one of

[39:25] the uh clusters but I just change it

[39:29] here the host um maybe I just call it

[39:31] larel

[39:33] 2 and that's it Port

[39:36] 80 uh the app called LEL yeah think it's

[39:50] okay okay grace is

[39:54] created um yeah we can deploy an app

[39:59] again here is just uh engine

[40:03] X port a with the already deployed uh

[40:09] config for engine

[40:11] X and uh app it's already built and

[40:17] pushed to dockerhub

[40:19] uh so we can already use it

[40:31] yeah appointment is

[40:33] created let me show

[40:38] you uh container is

[40:41] created let's run it again it's already

[40:46] running

[40:48] uh what

[40:50] else it looks like I forget

[40:55] something here okay maybe let's try just

[41:00] try it so within engress we use this

[41:04] URL let's go to the

[41:09] browser

[41:10] okay as you can see I missed already

[41:14] something

[41:16] um I think I didn't run

[41:19] the I also need to uh have a service for

[41:23] my app right

[41:31] so servic is created let's try

[41:38] again

[41:40] works that's what I deployed before it

[41:43] also works yeah so it's two apps within

[41:47] the same cluster yeah ah of the scaling

[41:53] part

[41:55] um it's a

[41:57] example how you can horizontally scale

[42:00] your

[42:01] app um so normally you are limited by

[42:07] resources of the server like CPU Ram or

[42:10] uh storage so you scale B based on that

[42:14] based on

[42:15] that um so here I just as an example

[42:20] specify

[42:21] that um I use a metric as an Ingress

[42:27] and if we have too many requests let's

[42:30] scale it so the minimum we can have one

[42:32] replica but maximum it can be

[42:35] 10 uh so in case if we have huge traffic

[42:39] the kubernetes can scale it uh

[42:42] unfortunately when I tried it I

[42:45] didn't um make enough load so it to show

[42:50] you how it really

[42:52] scales uh but yeah that's actually how

[42:54] how it works um so so I cannot show it

[42:58] to you

[42:59] today uh we had good ideas with Yanik

[43:03] how to do it by based by CPU but I run

[43:06] it another problem with that so I just

[43:09] decided that I better show you how it

[43:11] works and and I show you as an example

[43:14] how you can do it but basically it's

[43:16] again you just Define the some

[43:19] configuration for your

[43:21] deployment and like the metric you want

[43:24] to use and then and that's

[43:28] it so yeah I think that's it thank you

⚡ Saved you 0h 43m reading this? Transcribe any YouTube video for free — no signup needed.