Montaser El-sawy
Montaser El-sawy

Reputation: 830

how to run php artisan optimize:clear on laravel dockerized app via kubernetes

I'm using Kubernetes on Digitalocean cloud platform

the deckorized laravel app is running right now

and i need to run php artisan optimize:clear to all pods which are loading the app

how can i do that?

Edit:

I got the solution

First step connect to pod container

kubectl exec -it  pod_name -- /bin/bash

then

php artisan optimize:clear

or

kubectl exec -it pod_name -- /bin/bash -c "php artisan  route:clear"

Upvotes: 2

Views: 710

Answers (1)

Pooya Sabramooz
Pooya Sabramooz

Reputation: 342

You can build a bash file like the below:

#!/bin/bash
PODS=$(kubectl get pods -n my-production | grep php-fpm | awk -F' *|/' '$2 == $3 && $4 == "Running"' | awk {'print $1'} | column -t )
for POD in $PODS
do
    echo $POD
    kubectl -n my-production exec $POD -c php -- php artisan optimize:clear
done

echo "Done!"

Upvotes: 2

Related Questions