Why adopt GitOps for Laravel 11 on Kubernetes?
Enterprises that moved more than 30% of their web traffic to containerised services in 2023 reported a 40% reduction in deployment time. Laravel 11 developers can capture the same advantage by treating the entire Kubernetes manifest as code, letting Argo CD continuously reconcile the cluster state with a Git repository.
Prerequisites and system requirements
Before you start, ensure the following components are available:
- Ubuntu 22.04 LTS or a comparable Linux distribution.
- Docker Engine 24.x and kubectl 1.28.
- A Kubernetes cluster (managed or self‑hosted) with at least 2 vCPU and 4 GB RAM per node.
- Helm 3.12 installed on your workstation.
- Argo CD 2.7 running in the same cluster.
- Git repository (GitHub, GitLab, or Bitbucket) that will store Helm chart sources and values files.
All tools should be reachable from the command line; verify with
docker --version and helm version. Creating a Helm chart for Laravel 11
The first concrete step is to scaffold a Helm chart that packages the Laravel application, a PHP‑FPM container, and an Nginx sidecar. Run the following command inside your project root:
helm create laravel11-chart Replace the default templates/deployment.yaml with a Laravel‑specific definition. Below is a minimal example that references a Docker image built from the Dockerfile located in /docker:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "laravel11-chart.fullname" . }}
labels:
{{- include "laravel11-chart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "laravel11-chart.name" . }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "laravel11-chart.name" . }}
spec:
containers:
- name: php-fpm
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
- containerPort: 9000
envFrom:
- secretRef:
name: {{ include "laravel11-chart.fullname" . }}-env
volumeMounts:
- name: storage
mountPath: /var/www/html/storage
- name: nginx
image: nginx:1.25-alpine
ports:
- containerPort: 80
volumeMounts:
- name: storage
mountPath: /var/www/html/storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: {{ include "laravel11-chart.fullname" . }}-pvc
Adjust .Values.image.repository and .Values.image.tag in values.yaml to match your CI pipeline output, for example myregistry.com/laravel11:2024-09-03.
Embedding GitOps with Argo CD
Argo CD watches a Git branch and automatically applies any change to the target namespace. Create a new application manifest that points to the Helm chart directory:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: laravel11-prod
spec:
project: default
source:
repoURL: https://github.com/yourorg/laravel11-infra.git
targetRevision: main
path: helm/laravel11-chart
helm:
valueFiles:
- values-prod.yaml
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
Commit this file to the infrastructure repository. Argo CD will detect the new Application object, render the Helm chart, and create the Deployment, Service, and PVC resources in the production namespace.
CI pipeline that pushes Docker images and updates Helm values
A typical GitHub Actions workflow for Laravel 11 looks like this:
name: CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to registry
uses: docker/login-action@v2
with:
registry: myregistry.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: Build and push Laravel image
uses: docker/build-push-action@v4
with:
context: ./docker
push: true
tags: myregistry.com/laravel11:${{ github.sha }}
- name: Update Helm values file
run: |
sed -i "s|tag:.*|tag: ${{ github.sha }}|" helm/laravel11-chart/values-prod.yaml
git config user.name "github-actions"
git config user.email "actions@github.com"
git add helm/laravel11-chart/values-prod.yaml
git commit -m "chore: bump image tag to ${{ github.sha }}"
git push origin main
This pipeline builds a reproducible PHP‑FPM image, pushes it to a private registry, and amends the Helm values file with the new tag. Because Argo CD continuously watches the same repository, the new tag triggers an automatic sync, rolling out the updated containers without manual intervention.
Testing the deployment and handling rollbacks
After the first sync, verify the pods are healthy:
kubectl -n production get pods -l app.kubernetes.io/name=laravel11-chart If the new image introduces a regression, Argo CD’s history feature lets you roll back to the previous release with a single click in the UI or via CLI:
argocd app rollback laravel11-prod --revision 5 The rollback reverts the Helm values file to the earlier tag, and Argo CD redeploys the stable containers automatically.
Performance tuning tips for Laravel 11 on Kubernetes
Laravel 11 benefits from opcode caching and queue workers. Add a sidecar container that runs php artisan queue:work --daemon and expose a shared /var/www/html/storage volume for cached files. In values.yaml set resources.limits.cpu to 500m and memory to 1024Mi for predictable scaling. Enable Horizontal Pod Autoscaler (HPA) with a target CPU utilization of 70% to let the cluster add replicas during traffic spikes.
Conclusion
By combining Laravel 11, Helm, and Argo CD, you transform every deployment into a repeatable, auditable Git operation. The workflow described above reduces manual steps, guarantees that production always matches the declared state in Git, and provides instant rollback capabilities. Teams that adopt this GitOps pattern typically see deployment frequency increase by 2‑3× while error rates drop below 1%.
Sources
Official Laravel 11 Documentation; Argo CD Project Documentation; Helm Charts Best Practices Guide
Author: Mahmut Sarıkaya — sarikayadev.com
.jpeg&w=320&q=50)