Code Monkey home page Code Monkey logo

laravel-deployment's Introduction

Laravel-deployment

laravel project deployment to k8s cluster

This is a Basic Laravel project Ready to be deployed to Kubernetes Cluster alongside:

  • Nginx Ingress
  • Single instance Mysql
  • laravel FPM Api

CoreApi

CoreApi Directory hosts the source code with all of the configurations required. it does host a Dockerfile that is a Container in API Deployment.
.env file can be configured using configMap.

CoreApi Dockerfile

Core api dockerfile is using php frpm as base Image(8.2)
this Dockerfile can be change to add nginx as proxy pass for FPM socket. depends on the Production plan. a simple nginx installation and proxy pass on \ location block will get the job done.
you can add php extentions and more configuration as you need.

API

API directory is where the laravel api deployment and its service is configured.

coreapi deployment

CoreAPI-deployment.yml will deploy a set of pods maintaining CoreApi image. this deployment:

  • deploy pods based on roll out strategy.
  • use CoreApi lates image as main container.
  • test mysql app before starting the main container.
  • performe health checks over URLS(readinees and liveness).
  • set resource limit and request for hardware consumption.
  • run post exec command after startup for laravel database migration.

read configuration file to find out more about replica configuration and deployment stats.

coreapi service

a clusterIP service is designed for ingress use, this service is mapped to ingress for accepting incoming traffic from internet. this service:

  • map containerPort 8000 to 80.
  • after deployment, ready to accept traffic from ingress.

coreapi configmap

CoreApi-configmap.yml will create all configuration for you. all you have to do is to change values for your desired values.

coreapi secret

Just put your god damn Database Passowrd in this file and let k8s handle your secret ;).

Ingress

ingress.yml file is where you can talk to internet about your CoreApi service.
we do not have a Host so the ingress will route all the incoming traffic to the backend. backend is marked as CoreApi-service. check Ingress config file for more info.

ingress controler is prefered, mysql will not be exposed.

Mysql

this deployment is for Development usage and not Production. feel free to test cloud or any other database provider for your production.

mysql deployment

this deployment will setup a single mysql instance for dev use. this deployment:

  • uses mysql 8 as base image.
  • reads root initial password from kubernetes secrets.
  • uses volumes created using mysql-pv.yml configuration.

mysql deployment, service and secrets are simple, no details included, goes the same with PV and PVC.

HPA

you can configure HPA object or just simply enable horizontal auto scaling for your deployments. if so, in mannual approach, use this command to enable autoscale for CoreApi Deployment:
kubectl autoscale deployment CoreApi --cpu-percent=50 --min=4 --max=10
this will autoscale your deployment based on CPU usage, with maximum of 10 pods. check HPA status using: kubectl get hpa
or
you can deploy a HPA object to take care of this job:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: CoreApi
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: CoreAPI
  minReplicas: 4
  maxReplicas: 10

Notes:

This configuration supports helm improvements and various CICD pipelines.
for this project, php version is 8.2 and mysql is 8.0. you can simply change them in configuration.
change the deployment rollout strategy to meet your requirements.

laravel-deployment's People

Contributors

sinabehmanesh avatar pooriashahi avatar

Watchers

 avatar

laravel-deployment's Issues

Cannot Contribute !!!!!!

Hey man

I can't contribute in this project in any sort of ways. just leave github if you don't want any contribution.

helm chart

we have now helm chart!
lets configure it and then create a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.