Skip to content

Commit 0973189

Browse files
committed
Add kubernetes demo
1 parent 93c6e39 commit 0973189

14 files changed

+296
-0
lines changed
File renamed without changes.
File renamed without changes.

demo/kubernetes/kustomization.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resources:
2+
- postgres.pvc.yaml
3+
- postgres.deployment.yaml
4+
- postgres.svc.yaml
5+
- redis.deployment.yaml
6+
- redis.svc.yaml
7+
- php.config-map.yaml
8+
- php.deployment.yaml
9+
- php.svc.yaml
10+
- nginx.config-map.yaml
11+
- nginx.deployment.yaml
12+
- nginx.svc.yaml

demo/kubernetes/nginx.config-map.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: nginx-config
5+
data:
6+
default.conf.template: |
7+
server {
8+
listen 80;
9+
listen [::]:80;
10+
root /app/public;
11+
12+
add_header X-Frame-Options "SAMEORIGIN";
13+
add_header X-Content-Type-Options "nosniff";
14+
15+
index index.php;
16+
17+
charset utf-8;
18+
19+
location / {
20+
try_files $uri $uri/ /index.php?$query_string;
21+
}
22+
23+
location = /favicon.ico { access_log off; log_not_found off; }
24+
location = /robots.txt { access_log off; log_not_found off; }
25+
26+
error_page 404 /index.php;
27+
28+
location ~ \.php$ {
29+
fastcgi_pass ${PHP_SERVICE_HOST}:${PHP_SERVICE_PORT};
30+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
31+
include fastcgi_params;
32+
}
33+
34+
location ~ /\.(?!well-known).* {
35+
deny all;
36+
}
37+
}

demo/kubernetes/nginx.deployment.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nginx
5+
labels:
6+
app: laravel-docker
7+
tier: nginx
8+
spec:
9+
replicas: 1
10+
template:
11+
metadata:
12+
name: nginx
13+
labels:
14+
app: laravel-docker
15+
tier: nginx
16+
spec:
17+
containers:
18+
- name: nginx
19+
image: laravel-docker:nginx
20+
imagePullPolicy: Never # local development only
21+
ports:
22+
- containerPort: 80
23+
name: nginx-http
24+
volumeMounts:
25+
- mountPath: /etc/nginx/templates/default.conf.template
26+
name: nginx-config-volume
27+
subPath: default.conf.template
28+
restartPolicy: Always
29+
volumes:
30+
- name: nginx-config-volume
31+
configMap:
32+
name: nginx-config
33+
selector:
34+
matchLabels:
35+
app: laravel-docker
36+
tier: nginx

demo/kubernetes/nginx.svc.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: nginx
5+
spec:
6+
selector:
7+
app: laravel-docker
8+
tier: nginx
9+
ports:
10+
- port: 80
11+
type: NodePort

demo/kubernetes/php.config-map.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: laravel-config
5+
data:
6+
APP_NAME: "Laravel Docker"
7+
APP_ENV: "production"
8+
APP_KEY: "base64:Avm4zs1yLfogxHpwBZRZhKZJ0EC6/7IX0FcVSyQQlLU="
9+
APP_DEBUG: "false"
10+
APP_URL: "http://localhost"
11+
LOG_CHANNEL: "stderr"
12+
# Postgres configuration
13+
DB_CONNECTION: "pgsql"
14+
DB_HOST: "postgres"
15+
DB_PORT: "5432"
16+
DB_DATABASE: "laravel-app"
17+
DB_USERNAME: "laravel"
18+
DB_PASSWORD: "password"
19+
# Redis configuration
20+
REDIS_HOST: "redis"
21+
REDIS_PORT: "6379"
22+
BROADCAST_DRIVER: "redis"
23+
CACHE_DRIVER: "redis"
24+
QUEUE_CONNECTION: "redis"
25+
SESSION_DRIVER: "redis"
26+
# Minio configuration
27+
FILESYSTEM_DISK: "s3"
28+
AWS_ACCESS_KEY_ID: "laravel"
29+
AWS_SECRET_ACCESS_KEY: "password"
30+
AWS_DEFAULT_REGION: "us-east-1"
31+
AWS_BUCKET: "local"
32+
AWS_URL: "http://localhost:9000"
33+
AWS_ENDPOINT: "http://minio:9000"
34+
AWS_USE_PATH_STYLE_ENDPOINT: "true"
35+
---

demo/kubernetes/php.deployment.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: php
5+
labels:
6+
app: laravel-docker
7+
tier: php
8+
spec:
9+
replicas: 3
10+
template:
11+
metadata:
12+
name: php
13+
labels:
14+
app: laravel-docker
15+
tier: php
16+
spec:
17+
containers:
18+
- name: php
19+
image: laravel-docker:php
20+
imagePullPolicy: Never
21+
envFrom:
22+
- configMapRef:
23+
name: laravel-config
24+
ports:
25+
- containerPort: 9000
26+
name: php-fpm
27+
initContainers:
28+
- name: migrations
29+
image: laravel-docker:php
30+
envFrom:
31+
- configMapRef:
32+
name: laravel-config
33+
command:
34+
- /bin/bash
35+
- -c
36+
- php artisan migrate --force
37+
restartPolicy: Always
38+
selector:
39+
matchLabels:
40+
app: laravel-docker
41+
tier: php

demo/kubernetes/php.svc.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: php
5+
spec:
6+
selector:
7+
app: laravel-docker
8+
tier: php
9+
ports:
10+
- port: 9000
11+
type: NodePort
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: postgres
5+
labels:
6+
app: laravel-docker
7+
tier: postgres
8+
spec:
9+
replicas: 1
10+
template:
11+
metadata:
12+
name: postgres
13+
labels:
14+
app: laravel-docker
15+
tier: postgres
16+
spec:
17+
containers:
18+
- name: postgres
19+
image: postgres:15
20+
imagePullPolicy: IfNotPresent
21+
env:
22+
- name: POSTGRES_DB
23+
valueFrom:
24+
configMapKeyRef:
25+
key: DB_DATABASE
26+
name: laravel-config
27+
- name: POSTGRES_USER
28+
valueFrom:
29+
configMapKeyRef:
30+
key: DB_USERNAME
31+
name: laravel-config
32+
- name: POSTGRES_PASSWORD
33+
valueFrom:
34+
configMapKeyRef:
35+
key: DB_PASSWORD
36+
name: laravel-config
37+
ports:
38+
- containerPort: 5432
39+
name: postgres
40+
volumeMounts:
41+
- mountPath: /var/lib/postgresql/data
42+
name: postgres-persistent-storage
43+
restartPolicy: Always
44+
volumes:
45+
- name: postgres-persistent-storage
46+
persistentVolumeClaim:
47+
claimName: postgres-pv-claim
48+
selector:
49+
matchLabels:
50+
app: laravel-docker
51+
tier: postgres

0 commit comments

Comments
 (0)