Skip to content

Commit

Permalink
change readme to complete explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
rizkyfaza20 committed Nov 17, 2023
1 parent f4fdabc commit 2ace9c4
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 66 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Laravel App - CRUD Services

This application run the service of Laravel CRUD Application with the database server. Include with the monitoring services using Prometheus and Grafana.

The application it self contain of :
- Laravel Apps Directory
- Dockerfile and Docker compose script
- Helm chart for deploying locally
- Github Actions Workflow

The configuration of the deployment to Kubernetes, it's using such as:
- Health Checks
- Horizontal Pod Autoscaling; While the container down, there are some backup to make the pods running up again.

The monitoring setup with the Helm chart using Prometheus and Grafana, which that also could monitor the Laravel apps
Default of the dashboard itself using Laravel App Metrics.

The monitoring process its using the default of Kubernetes system, with health checks to show the process of the pods itself

To run this app, you can try with:

`helm install <name of the app> .`

If you want to run separately, such as to work with the container itself and database container, you can try with:

`docker pull mrfzy00/crud_laravel_api-sre-test-app:latest`
`docker run -d -p 8000:8000 --name <the container name> crud_laravel_api-sre-test-app`

Or you would try with run the app combined with docker compose its okay

To run the database you can start:
`docker-compose up -d`

The database will start the service itself

![Local Infrastructure Kubernetes Diagram](infra-local-diagram.png "Local Infrastructure Diagram")
64 changes: 0 additions & 64 deletions api-laravel-crud/README.md

This file was deleted.

5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ services:
image: mysql:5.7-oracle
command: --default-authentication-plugin=mysql_native_password
ports:
- '33060:3306'
- 3306:3306
environment:
- MYSQL_DATABASE=db_laravel
- MYSQL_ROOT_PASSWORD=Ch4ng3me!@
volumes:
- ./db:/var/lib/mysql
- ./db:/var/lib/mysql
network_mode: host
Binary file added infra-local-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions laravel-minikube/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ spec:
- name: http
containerPort: 80
protocol: TCP
# livenessProbe:
# httpGet:
# path: /
# port: http
# initialDelaySeconds: 3
# periodSeconds: 3
# readinessProbe:
# httpGet:
# path: /
# port: http
# initialDelaySeconds: 5
# periodSeconds: 5
env:
- name: APP_KEY
valueFrom:
Expand All @@ -46,3 +58,5 @@ spec:
value: {{ .Values.database.user }}
- name: DB_PASSWORD
value: {{ .Values.database.password }}


20 changes: 20 additions & 0 deletions laravel-minikube/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "laravel-minikube.fullname" . }}
labels:
app: {{ include "laravel-minikube.name" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "laravel-minikube.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
8 changes: 8 additions & 0 deletions laravel-minikube/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ service:
type: ClusterIP
port: 80

autoscaling:
enabled: true
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 50


ingress:
enabled: false
annotations: {}
Expand All @@ -23,6 +30,7 @@ appKey:

database:
enabled: true
version: "5.7-oracle"
type: mysql
name: laraveldb
user: root
Expand Down

0 comments on commit 2ace9c4

Please sign in to comment.