TubeSum ← Transcribe a video

Deploying Laravel App on Kubernetes cluster

0h 14m video Transcribed Jun 30, 2026 C Coding Monk
Intermediate 12 min read For: Developers with basic Docker and Kubernetes knowledge who want to deploy a Laravel application.
20.5K
Views
194
Likes
33
Comments
31
Dislikes
1.1%
📊 Average

AI Summary

This tutorial demonstrates how to deploy a Laravel application on a Kubernetes cluster using Minikube. The presenter builds two Docker images (PHP-FPM and Nginx), pushes them to Docker Hub, and then deploys the application using Kubernetes deployment and service configurations. The video also shows how to scale deployments and access the running application.

[00:00]
Prerequisites

Assumes viewer knows basics of Kubernetes and Docker. Links to prerequisite tutorials are in the video description.

[00:53]
Start Minikube

Use 'minikube start' to create a local Kubernetes cluster.

[01:33]
Build Docker images

Build two separate images: one for PHP-FPM and one for Nginx. This follows microservices best practice.

[03:24]
Publish images to Docker Hub

Use 'docker push' to upload the images after logging in.

[04:29]
PHP Deployment configuration

YAML file defines a deployment with 2 replicas, a hostPath volume for code, and an init container that copies code from the image to the volume.

[06:47]
PHP Service

Exposes the PHP deployment on port 9000, targeting pods with labels app=php, tire=backend.

[07:03]
Nginx ConfigMap

Virtual host configuration pointing document root to /code/app/public and using PHP upstream. Note: static IP used due to DNS issue, but service name can be used normally.

[09:01]
Deploy to cluster

Apply PHP service, PHP deployment, ConfigMap, Nginx service, and Nginx deployment using kubectl apply -f.

[11:28]
Access application

Use 'minikube service nginx' to get the URL. The Laravel app is now running on Kubernetes.

[12:10]
Scaling

Change replicas in deployment YAML or use kubectl to scale. Pods become live in seconds without downtime.

Deploying a Laravel application on Kubernetes enables easy scaling and microservice architecture. The tutorial provides a practical step-by-step guide using Minikube, with all configuration files available on GitHub.

Clickbait Check

90% Legit

"Title accurately promises a Laravel deployment on Kubernetes, and the video delivers exactly that with a clear step-by-step walkthrough."

Mentioned in this Video

Tutorial Checklist

1 00:53 Start Minikube: run 'minikube start'
2 01:50 Build Docker image for PHP: 'docker build -t hirenquad/laravel:1.5.1 .'
3 03:24 Push PHP image to Docker Hub: 'docker push hirenquad/laravel:1.5.1'
4 04:29 Create PHP deployment YAML with 2 replicas, hostPath volume, init container to copy code
5 06:47 Create PHP service YAML exposing port 9000
6 07:03 Create Nginx ConfigMap with virtual host configuration (document root /code/app/public, PHP upstream)
7 07:36 Create Nginx deployment YAML with volume mount for code and ConfigMap mount
8 08:46 Create Nginx service of type LoadBalancer
9 09:01 Apply all YAML files: 'kubectl apply -f php-service.yml', 'kubectl apply -f php-deployment.yml', 'kubectl apply -f configmap.yml', 'kubectl apply -f nginx-service.yml', 'kubectl apply -f nginx-deployment.yml'
10 11:28 Access app: 'minikube service nginx'
11 12:10 Scale deployment: edit replicas in YAML or use 'kubectl scale deployment/php-deployment --replicas=3'

Study Flashcards (8)

Why should you create separate Docker images for PHP and Nginx instead of combining them?

medium Click to reveal answer

To follow microservices best practices – if you only need to scale the PHP service and not Nginx, separate images allow that flexibility.

02:23

What is the command to start a Minikube Kubernetes cluster?

easy Click to reveal answer

minikube start

00:53

What type of volume does the tutorial use for demonstration and why?

medium Click to reveal answer

hostPath volume, because the cluster has only one node. With multiple nodes, a persistent volume claim would be needed.

04:58

What is the purpose of the init container in the PHP deployment?

hard Click to reveal answer

To copy the application code from the image (/var/www) to the mounted volume (/code/app) before the main PHP container starts.

06:13

Which port does the PHP service expose?

easy Click to reveal answer

Port 9000.

06:47

What type of service is used for the Nginx service to expose it to the outside world?

medium Click to reveal answer

LoadBalancer.

08:46

What command is used to access the deployed application's URL?

easy Click to reveal answer

minikube service nginx

11:28

How can you scale the number of replicas without downtime in Kubernetes?

medium Click to reveal answer

Change the 'replicas' value in the deployment YAML and reapply, or use 'kubectl scale deployment/php-deployment --replicas=5'.

12:10

💡 Key Takeaways

⚖️

Microservices separation

Explains a core Kubernetes principle: separate services per container to enable independent scaling.

02:35
💡

HostPath volume warning

Highlights a common production pitfall – hostPath volumes cause data inconsistency across nodes.

04:58
🔧

Init container pattern

Demonstrates a practical pattern for pre-populating volumes with application code in a deployment.

06:13
📊

DNS inside cluster

Mentions that Kubernetes internal DNS allows using service names (like 'php') instead of static IPs for upstream; a key networking insight.

10:22
💡

Zero-downtime scaling

Emphasizes that Kubernetes can scale applications in seconds without downtime, the main benefit shown.

13:00

✂️ Creator Tools: Viral Hooks

AI-generated clip ideas for Shorts based on the transcript

Deploy Laravel on Kubernetes in Seconds

45s

The opening promise of scaling an app in seconds grabs attention for developers wanting fast deployment.

▶ Play Clip

Why Two Docker Images? Microservices Explained

57s

Explains a key Kubernetes best practice (separate PHP and Nginx images) with a clear scaling argument, appealing to devs learning microservices.

▶ Play Clip

Kubernetes PHP Deployment YAML Walkthrough

60s

Shows real YAML code with volume mounts and init containers, highly educational for hands-on learners.

▶ Play Clip

Nginx ConfigMap & Service Setup for Laravel

60s

Demonstrates how to configure Nginx to proxy to PHP service, a common pain point for Kubernetes beginners.

▶ Play Clip

Scale Laravel on Kubernetes with Zero Downtime

50s

Live demo of scaling replicas in seconds without downtime, directly showing Kubernetes' killer feature.

▶ Play Clip

[00:00] Hey everyone, welcome to the coding log, this is Hirain and you are going to learn about how you can deploy your level application on the Kubernetes.

[00:15] In previous tutorial we have already seen how you can build Docker image for your level application. In this tutorial we will be learning about how you can deploy your level application onto

[00:27] Kubernetes cluster to scale in seconds. So this is not a tutorial about basics of Kubernetes. If you don't know about Kubernetes, what is Kubernetes and basics of Kubernetes, I will

[00:40] be putting links into video description. So what those tutorials and come back here. I will be using MiniCube to create local Kubernetes cluster. You can use any cloud service provider for local environment.

[00:53] You can also use MiniCube. So let me start my MiniCube service or MiniCube Kubernetes cluster. You can just type MiniCube start and it will spin up Kubernetes cluster into your local machine.

[01:12] So as you can see now MiniCube has started my Kubernetes cluster. Now let's see application which I want to deploy on my Kubernetes cluster. So I have already one application which is let me show this travel application which I want

[01:33] to deploy. So this is the application which I want to deploy on my Kubernetes cluster. This is a larval application as you can see. So this is the application will be deploying and it is into this app directory.

[01:50] So let's first build and Docker image and publish it to our Docker Hub. You have already seen this tutorial in previous video. So I will be using this Docker file to create my application image and publish it to Docker Hub.

[02:06] So what I'm doing here is I'll be creating two separate images or I'll be using two separate images. One is for PHP and one is for engine X. You can also contain PHP and engine X in same image but that is not the best practice.

[02:23] For example, if you just want to scale your PHP service and not the engine X, then there will be problems if you contain both the application or both the services into same image and

[02:35] the objective of Kubernetes is to create microservices. So likewise we will be creating PHP and engine X two different services and expose engine X services

[02:47] to the outside world. So this is my Docker file which is pulling image PHP 7.2 FPM and then copying this app folder to where www and exposing this PHP service on the 9000 port.

[03:01] So let's build this Docker image first. So to build Docker image, Docker build minus T and name of the image.

[03:24] So it is creating a Docker image for my application currently it is copying my code from F folder to where www into my Docker image. To publish this Docker image onto Docker Hub, you can log into Docker Hub onto your CLI and

[03:40] then write Docker push and then your image name with tag.

[04:02] So here it is 1.5.1. Now let's move towards another part of Kubernetes deployment. We have already created this image and published to the Docker Hub.

[04:15] Now let's see what things we need to publish this app or deploy this app to Kubernetes cluster. So we will be needing deployment and services. I have already created PHP deployment and engine X deployment and services.

[04:29] So let's go through each one by one. So here it is PHP deployment file. It is kind of deployment. It is creating one replica. Let's change it to two replicas and this deployment will apply to all the labels with app is equal

[04:46] to PHP and TR is equal to backend because PHP is backend service. And we are also attaching a volume type of host part.

[04:58] So this will create one directory on the host or node and it will persist that directory throughout the node lifecycle. I'm not suggesting to create volume type of host part because if you are more than one node

[05:13] then it will have different directories on each node and your application might not be in sync. Whatever the cloud service provider you are using, you can create persistent volume claim

[05:25] and you can use those persistent volume claim and you can mount that volume into your pod. But for demonstration purpose I'll be using host path because we are only creating one node.

[05:37] So I'm creating directory code and volume name DIR directory. I'm using my this Hirenquad larval 1.5.1 image and I'm giving name to this container as PHP.

[05:55] I'm also mounting this volume we have created and mounting onto this path which volume I want to mount it is direct. Every pod has lifecycle. So on the initialization of container or pod what I want to do is I want to grab a busy

[06:13] box image and I'm mounting this directory volume and I want to copy my code from image which is located in where www to code app which is my volume directory.

[06:30] So this is PHP deployment. Now let's save this and go to PHP service. This is a service for exposing my deployment. I'll be exposing PHP deployment on 9000 and all the pods which contain app as PHP and TRS

[06:47] backend. So this is PHP service. Now let's move on to engine X things. So I have created this config map file which is a normal virtual host file which is pointing document root as code app public which is my larval application and I'm using PHP app

[07:03] app as my upstream server. So currently I'm using this IP address which is the end point of PHP service. Somehow my code here service in the Kubernetes local cluster is not working. So I'm using this static IP address but you can always write PHP here which is the name of

[07:20] your PHP service and it will be walking don't worry about it. So currently I'm putting this IP address here and let's go to engine X deployment. So what I'm doing here is I'll be creating one replica of this engine X deployment.

[07:36] I'll be selecting all the pods which has app is equal to engine X and TR is equal to backend and apply to this deployment and this is the template of my pod which has volume attached

[07:48] called directory and host path is code and I also attached this config map which I have already created. We need to create first config map and then we can attach that config map to our engine

[08:02] X deployment. So I'm attaching this engine X config map and I'm giving key value pair key is equal to config and I want to put that configuration file into my site.conf file.

[08:16] So this is my volumes. Now I'll be using official engine X image to create this deployment or engine X pods and I will mounting my volumes of directory and this config map to this mount path.

[08:34] And finally I'll be exposing this engine X container or pod to this anti pod. Now let's go to engine X service which is kind of load balancer because I want to expose

[08:46] my service to outside world I will be creating this engine X service of type load balancer and this is my node pod on which this service will be exposed. So this is engine X service and deployment.

[09:01] Now let's move to the CLI and deploy this application to Kubernetes cluster finally. So I'll be using cube CTL and first I will be creating PHP service. So apply minus f php service dot ml.

[09:18] So as you can see PHP service is created. If you want to see all the services created.

[09:36] So as you can see PHP service is running. Now let's create PHP deployment. So PHP deployment is created. Now I want to grab the IP address of this PHP service.

[09:52] So I can write PHP get and point yes I have to write cube CTL here.

[10:08] And these are the IP address of this PHP service. So I'll be having this one of the IP address and in config map I have to write PHP service

[10:22] because we'll be using this PHP service and point as our upstream server. Remember you can write directly PHP service name here like this.

[10:35] My core DNS are not working in my local Kubernetes cluster that's why I'm doing this. So you don't need to write static IP address and that is not the best practice at all. Now let's create config map.

[10:54] So my config map is created and then nginx service and nginx deployment. If we perform command get poured as you can see I have two containers of PHP and one container

[11:13] of nginx is being created. Now as you can see nginx container is also created. So you can see problem with the static IP address here. We are only specifying IP address of one of these service.

[11:28] If you want to use both of the service and handle load balancing itself by Kubernetes you have to write here PHP or the service name you want to use. But I have some issue with the Kubernetes cluster so I'm using this static IP address for

[11:44] just demonstration purpose. Now to get the URL of the application I will be writing mini-cube service and name of the service is nginx.

[11:56] So this is the URL on which my application is currently exposed. As you can see our larval application is up and running on the Kubernetes cluster.

[12:10] So this half you can deploy your larval application to Kubernetes cluster. Suppose if you want to scale this application it just very easy. Suppose if you want to scale your nginx deployment to 5 just change the number of the replicas

[12:28] into your deployment or you can directly perform with the CLI as well. So if I apply this PHP deployment and perform cube CTL cat ports as you can see other containers

[12:46] or ports are also being initialized. Just matter of second it will be live on your Kubernetes cluster without any downtime. So this is the main benefit of Kubernetes.

[13:00] You can scale your application in just seconds without any downtime. So this half you can deploy your larval application to Kubernetes cluster. I will be putting all this configuration file into GitHub and you can use that.

[13:14] So this is all about deploying your larval application to Kubernetes. This application was not connected to database and I have not created any database or my SQL deployment but I would suggest you to use any managed database or cloud databases.

[13:31] In next tutorial we will be learning how you can deploy your larval application to digital ocean managed Kubernetes. So this is all about larval with Kubernetes cluster. Thank you very much.

[13:43] Hey guys guys if you like this video then don't forget to share, like and subscribe. This would help me a lot. So please subscribe to my channel to watch more videos like this.

[13:55] Thank you very much.

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