Skip to content

Commit

Permalink
#31 - Minikube Support
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabjasrotia committed Jan 17, 2024
1 parent ebda249 commit 9e00361
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 5 deletions.
21 changes: 21 additions & 0 deletions Makefile
@@ -1,3 +1,24 @@
build:
docker compose up -d
docker exec -it drupal-fpm sh

build-minikube:
minikube start
Kubectl apply -f iac/docker/helm
Kubectl apply -f iac/docker/helm/nginx
Kubectl apply -f iac/docker/helm/drupal
Kubectl apply -f iac/docker/helm/mysql

build-tunnel:
minikube tunnel

run-minikube:
minikube service ngnix

deploy-minikube:
cd app && composer install && cd ..
chmod +x scripts/deploy-k8s && scripts/deploy-k8s

update-minikube:
cd app && composer install && cd ..
chmod +x scripts/deploy-k8s && scripts/deploy-k8s
17 changes: 13 additions & 4 deletions README.md
@@ -1,5 +1,5 @@

**Docker Base Drupal 10 Container Setup**
**Docker Base Drupal 10 Container Setup with Kubernetes Support**

## How to setup
- Build the setup using following command ```make build```
Expand All @@ -23,6 +23,15 @@

## Kubernetes MiniKube

- Kubectl apply -f iac/docker/helm && Kubectl apply -f iac/docker/helm/nginx && Kubectl apply -f iac/docker/drupal && Kubectl apply -f iac/docker/mysql
- Add domain to local host i.e. /etc/host file
- minikube tunnel
- Build Minikube Helm Files:
- ```make build-minikube```
- Deploy code to minkube containers:
- ```make deploy-minikube```
- Run Minikube Tunnel and expose Nginx container port:
- ```make build-tunnel```
- ```make run-minikube```
- Add domain to local host i.e. ```/etc/host``` file

## Post Deployment to minikube
- We can use following command to just update drupal & nginx containers files:
- ```make update-minikube```
2 changes: 1 addition & 1 deletion app/web/sites/default/settings.local.php
Expand Up @@ -5,7 +5,7 @@

$settings['config_sync_directory'] = '../config/sync';

if (getenv('K8S') == '1') {
if (getenv('KS') == '1') {
$databases['default']['default'] = [
'database' => 'drupal',
'username' => 'drupal_database_user',
Expand Down
1 change: 1 addition & 0 deletions iac/docker/helm/drupal/drupal-fpm-deployment.yaml
Expand Up @@ -25,6 +25,7 @@ spec:
io.kompose.network/external: "true"
io.kompose.network/internal: "true"
io.kompose.service: drupal-fpm
app: drupal-fpm
spec:
containers:
- env:
Expand Down
1 change: 1 addition & 0 deletions iac/docker/helm/nginx/ngnix-deployment.yaml
Expand Up @@ -24,6 +24,7 @@ spec:
labels:
io.kompose.network/external: "true"
io.kompose.service: ngnix
app: ngnix
spec:
containers:
- image: nginx:alpine-perl
Expand Down
14 changes: 14 additions & 0 deletions scripts/deploy-k8s
@@ -0,0 +1,14 @@
#!/bin/bash

POD=$(kubectl get pods -l app=drupal-fpm -o custom-columns=:metadata.name)
echo $POD
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
kubectl cp app/ $POD:/var/www/html/ -c drupal-fpm -n default
kubectl exec $POD -- bash -c "mv /var/www/html/app/* /var/www/html/."
kubectl exec $POD -- bash -c "cd /var/www/html && make build-drupal"

POD=$(kubectl get pods -l app=ngnix -o custom-columns=:metadata.name)
echo $POD
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
kubectl cp app/ $POD:/var/www/html/ -c ngnix -n default
kubectl exec $POD -- /bin/sh -c "mv /var/www/html/app/* /var/www/html/."
14 changes: 14 additions & 0 deletions scripts/update-k8s
@@ -0,0 +1,14 @@
#!/bin/bash

POD=$(kubectl get pods -l app=drupal-fpm -o custom-columns=:metadata.name)
echo $POD
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
kubectl cp app/ $POD:/var/www/html/ -c drupal-fpm -n default
kubectl exec $POD -- bash -c "mv /var/www/html/app/* /var/www/html/."
kubectl exec $POD -- bash -c "cd /var/www/html && make drupal-update"

POD=$(kubectl get pods -l app=ngnix -o custom-columns=:metadata.name)
echo $POD
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
kubectl cp app/ $POD:/var/www/html/ -c ngnix -n default
kubectl exec $POD -- /bin/sh -c "mv /var/www/html/app/* /var/www/html/."

0 comments on commit 9e00361

Please sign in to comment.