Coder Social home page Coder Social logo

Comments (10)

danielepolencic avatar danielepolencic commented on July 30, 2024

Interesting: https://www.reddit.com/r/kubernetes/comments/8gmh6m/extremely_new_to_kubernetes_want_to_deploy_a_lamp/

We could repurpose this tutorial and make it LAMP: https://medium.com/containerum/how-to-easily-deploy-a-drupal-8-instance-on-kubernetes-b90acc7786b7

Two interesting suggestions:

  • k8s + LAMP
  • from docker-compose to K8s

from learnk8s.io.

keithmifsud avatar keithmifsud commented on July 30, 2024

Keyword Research for the main title:

Keyword Monthly Volume Diificulty Organic CTR Priority Comments
How to deploy Laravel to Kubernetes no data 30 94% 30 We're already on top in SERP
Introduction to Kubernetes: How to Deploy a Laravel 5 application no data 40 86% 27
Getting started with Laravel 5 on Kubernetes no data 34 100% 30 We're already top in SERP
Deploy a Laravel 5 application to Kubernetes no data 37 88% 28

from learnk8s.io.

keithmifsud avatar keithmifsud commented on July 30, 2024

@danielepolencic I don't think we should change the title. My main reason is that if I had to google this I would literally type the title exactly: "How to deploy Laravel to Kubernetes". I would not specific the version number "laravel 5". I might search for "Deploy laravel to Kubernetes" instead. The article ranks #1 in google for both "Deploy laravel to Kubernetes" and the existing title. I think it will be detrimental to the existing search ranking if we change it. It is also specific to what users will type if this is the problem they are trying to solve.

SERP analysis is from MOZ https://moz.com/explorer/keyword/overview?locale=en-GB&q=deploy%20laravel%20to%20kubernetes and my previous search history and search profile does not affect it.

from learnk8s.io.

keithmifsud avatar keithmifsud commented on July 30, 2024

@danielepolencic In regards to the comment by sacundim; he's right in the sense that once the key is generated, it will be included in the image. Outside of a Docker setup, this is not an issue because Laravel uses a .env file which is ignored by git. I don't really know how to use the docker secrets feature. Do you? Also, I'm not sure this is very important for the purpose of this tutorial. Maybe we can simply add a disclaimer: "In a production scenario, the .env file should be ignored by docker ..."?

from learnk8s.io.

danielepolencic avatar danielepolencic commented on July 30, 2024

About laravel using serve in production, I think we should use php apache or php fpm as a base container as explained here: https://bitpress.io/simple-approach-using-docker-with-php/

"php artisan key:generate is a command that sets the APP_KEY value in your .env file."
That should be injected as an env variable. Example:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: app
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
      - name: app
        image: laravel
        env:
        - name: APP_KEY
          value: "something"
        ports:
          - containerPort: 8080

In your case, we're not using a yaml file, so I wonder... what happens if we remove that all together? does it still work without a key?

from learnk8s.io.

keithmifsud avatar keithmifsud commented on July 30, 2024

@danielepolencic :

Regarding apache / php-fpm.. we're using Nginx in Ingress? We could eliminate the php artisan serve if we didn't need a preview at such an early stage.

Laravel will not work without an APP_KEY variable. Also, I don't know how we can generate it and then add it to the yaml file?

from learnk8s.io.

keithmifsud avatar keithmifsud commented on July 30, 2024

pinging @danielepolencic 😄

from learnk8s.io.

danielepolencic avatar danielepolencic commented on July 30, 2024

The ingress is to route the traffic into the cluster. It's a proxy that distributes the traffic to the internal service in the network. It's not a replacement for the Nginx in front of php-fpm.

As for the env variable, you should tweak your command to be:

kubectl run laravel-kubernetes-demo \
  --image=yourname/laravel-kubernetes-demo \
  --port=8181 \
  --image-pull-policy=IfNotPresent \
  --env=APP_KEY=something

And you can remove RUN php artisan key:generate from your Dockerfile.

from learnk8s.io.

keithmifsud avatar keithmifsud commented on July 30, 2024

Thanks, @danielepolencic Sorry for the nginx.. Silly comment!
I will fix the Dockerfile so that includes a web server with PHP support - probably it will also be Nginx (not apache).

Regarding the app key, we still need to generate one before we can add it as an env var. This needs to be done inside the container. How would you go about it? We need to have a different and hidden key per install.

from learnk8s.io.

danielepolencic avatar danielepolencic commented on July 30, 2024

Regarding the app key, we still need to generate one before we can add it as an env var.

You can generate a random string and base64. It should work. I just checked the code and that's what they do in Laravel too https://github.com/laravel/framework/blob/56a58e0fa3d845bb992d7c64ac9bb6d0c24b745a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php#L59

from learnk8s.io.

Related Issues (20)

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.