Skip to content

juniorb2ss/laravel-pulumi-eks

Repository files navigation

Larapulu ⚡

🧙 🏗️ A magic way to deploy Laravel using Pulumi, EKS and ECR. 🎉

A different, dynamic, fast and secure way to deploy your Laravel application.

What you need to know first

This is my first stack that I built using Pulumi and Kubernetes. I confess, I don't know much about it. I actually created this stack as a way of studying. But, don't be like me. Study the technologies involved here first. But, if you want, be like me, download that stack, deploy it and go changing, modifying or breaking.

Here are some interesting documentations:

Ah, I know I wouldn't need to ask this, but: You already know docker, right? If not, LEAVE AND GO STUDY DOCKER BEFORE!

If you implement something cool, don't forget to send the PR. Okay?

Why AWS?

Why EKS?

I didn't want to build a K8s cluster because I was lazy.

First Steps

Stack resources

Let's deploy 🚀

Now that we already have Pulumi and Kubectl already installed, let's start our stack.

  1. Install dependencies
# npm install
  1. Initialize stack
# pulumi stack init yourStackName
  1. Configure Laravel APP_KEY
# pulumi config set laravel-pulumi-eks:APP_KEY <value> --secret`
  1. Review resources and stack preview
# pulumi preview

Output expected:

Diagnostics:
  pulumi:pulumi:Stack (laravel-pulumi-eks-yourStackName):
    [19:55:22] Initializing AWS provider in the region us-east-2
    [19:55:22] Initializing VPC
    [19:55:22] Initializing EKS cluster
    [19:55:22] Exporting applications labels
    [19:55:22] Creating stack namespace
    [19:55:22] Initializing EKS Service
    [19:55:22] Creating stack configMap
    [19:55:22] Uploading application images to ECR
    [19:55:22] Starting application image build
    [19:55:22] Starting nginx image build
    [19:55:22] Creating schedule cron job
    [19:55:22] Initializing queue jobs
    [19:55:22] Deploying application on cluster
    [19:55:22] Initializing stack
    [19:55:24] Creating queue job default
  1. Start deploy!
# pulumi up --yes
  1. After many minutes...

Expected output:

   loadBalancer: "ac908c4876a2a4b079c72f5a0a05af7a-607904941.us-east-2.elb.amazonaws.com"
Resources:
    72 changed
  1. Access your Laravel application
# pulumi stack output loadBalancer
ac908c4876a2a4b079c72f5a0a05af7a-607904941.us-east-2.elb.amazonaws.com

Observations

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Tips and Tricks

  • How to see pods and cluster information?

Read kubectl documentation, bastard!

  • How to destroy, scale change, etc?

Read Kubernetes documentation, bastard!

Free software! Oh, Yeah!

Welcome to the jungle, baby! 🪨