Skip to content

Commit 33c704e

Browse files
Merge pull request #32 from rishabjasrotia/feature/31-minikube-support
#31 - Minikube Support
2 parents ebda249 + 9e00361 commit 33c704e

File tree

7 files changed

+65
-5
lines changed

7 files changed

+65
-5
lines changed

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
11
build:
22
docker compose up -d
33
docker exec -it drupal-fpm sh
4+
5+
build-minikube:
6+
minikube start
7+
Kubectl apply -f iac/docker/helm
8+
Kubectl apply -f iac/docker/helm/nginx
9+
Kubectl apply -f iac/docker/helm/drupal
10+
Kubectl apply -f iac/docker/helm/mysql
11+
12+
build-tunnel:
13+
minikube tunnel
14+
15+
run-minikube:
16+
minikube service ngnix
17+
18+
deploy-minikube:
19+
cd app && composer install && cd ..
20+
chmod +x scripts/deploy-k8s && scripts/deploy-k8s
21+
22+
update-minikube:
23+
cd app && composer install && cd ..
24+
chmod +x scripts/deploy-k8s && scripts/deploy-k8s

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
**Docker Base Drupal 10 Container Setup**
2+
**Docker Base Drupal 10 Container Setup with Kubernetes Support**
33

44
## How to setup
55
- Build the setup using following command ```make build```
@@ -23,6 +23,15 @@
2323

2424
## Kubernetes MiniKube
2525

26-
- 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
27-
- Add domain to local host i.e. /etc/host file
28-
- minikube tunnel
26+
- Build Minikube Helm Files:
27+
- ```make build-minikube```
28+
- Deploy code to minkube containers:
29+
- ```make deploy-minikube```
30+
- Run Minikube Tunnel and expose Nginx container port:
31+
- ```make build-tunnel```
32+
- ```make run-minikube```
33+
- Add domain to local host i.e. ```/etc/host``` file
34+
35+
## Post Deployment to minikube
36+
- We can use following command to just update drupal & nginx containers files:
37+
- ```make update-minikube```

app/web/sites/default/settings.local.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

8-
if (getenv('K8S') == '1') {
8+
if (getenv('KS') == '1') {
99
$databases['default']['default'] = [
1010
'database' => 'drupal',
1111
'username' => 'drupal_database_user',

iac/docker/helm/drupal/drupal-fpm-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ spec:
2525
io.kompose.network/external: "true"
2626
io.kompose.network/internal: "true"
2727
io.kompose.service: drupal-fpm
28+
app: drupal-fpm
2829
spec:
2930
containers:
3031
- env:

iac/docker/helm/nginx/ngnix-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ spec:
2424
labels:
2525
io.kompose.network/external: "true"
2626
io.kompose.service: ngnix
27+
app: ngnix
2728
spec:
2829
containers:
2930
- image: nginx:alpine-perl

scripts/deploy-k8s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
POD=$(kubectl get pods -l app=drupal-fpm -o custom-columns=:metadata.name)
4+
echo $POD
5+
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
6+
kubectl cp app/ $POD:/var/www/html/ -c drupal-fpm -n default
7+
kubectl exec $POD -- bash -c "mv /var/www/html/app/* /var/www/html/."
8+
kubectl exec $POD -- bash -c "cd /var/www/html && make build-drupal"
9+
10+
POD=$(kubectl get pods -l app=ngnix -o custom-columns=:metadata.name)
11+
echo $POD
12+
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
13+
kubectl cp app/ $POD:/var/www/html/ -c ngnix -n default
14+
kubectl exec $POD -- /bin/sh -c "mv /var/www/html/app/* /var/www/html/."

scripts/update-k8s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
POD=$(kubectl get pods -l app=drupal-fpm -o custom-columns=:metadata.name)
4+
echo $POD
5+
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
6+
kubectl cp app/ $POD:/var/www/html/ -c drupal-fpm -n default
7+
kubectl exec $POD -- bash -c "mv /var/www/html/app/* /var/www/html/."
8+
kubectl exec $POD -- bash -c "cd /var/www/html && make drupal-update"
9+
10+
POD=$(kubectl get pods -l app=ngnix -o custom-columns=:metadata.name)
11+
echo $POD
12+
kubectl exec $POD -- /bin/sh -c "rm -rf /var/www/html/*"
13+
kubectl cp app/ $POD:/var/www/html/ -c ngnix -n default
14+
kubectl exec $POD -- /bin/sh -c "mv /var/www/html/app/* /var/www/html/."

0 commit comments

Comments
 (0)