This repository contains various examples of Kubernetes configurations to deploy a Laravel application.
This repository takes the following assumptions:
- You know what Laravel is and how it should be installed.
- You have basic Docker knowledge.
- You have PHP and Composer running on you local machine.
The Larvel application should be installed in the ./laravel
directory.
The insall.sh
script does this for you.
The examples can be found in kubernetes
directory.
Each directory contains a more details README.md.
The examples are meant to be a starting point to get Laravel running on a locally running Kubernetes cluster.
Every example runs in a dedicated namespace. See namespace.yaml
in each directory.
Note that persistent volumes are unaware of namespaces.
Examples might contain unsecure settings and commands that are not suitable for a production environments like:
- hardcoded database credentials
- 777 chmodded directories and files
This project comes intentional without Laravel. This makes it easy to pull in any Laravel version you want and perform any updates if needed.
Install a Docker application for your OS that also supports running a local Kubernetes clusters.
Examples of desktop applications that allow you to run Docker and Kubernetes on your machine are:
Most these applications require you to enable Kubernetes support manually.
To run the examples you need a Docker image with Laravel installed on it.
The examples asume a local Docker registry with a laravel-php
image:
localhost:5000/laravel-php
The following command does that for you:
bash build-laravel-image.sh
This script will do the following:
- Check if PHP is installed
- Check if Composer is installed
- Create a local Docker registry
- Install a fresh copy of Laravel
- Build, tag and push the Docker image to the local registry
From here you can try the Kubernetes examples. For example:
kubectl apply -f ./kubernetes/laravel-single-pod
This will create all Kubernetes configurations in your local cluster.