-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkubernetes-example.yaml
More file actions
209 lines (199 loc) · 3.45 KB
/
kubernetes-example.yaml
File metadata and controls
209 lines (199 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
---
# Namespace
apiVersion: v1
kind: Namespace
metadata:
name: webapp
---
# PostgreSQL Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
namespace: webapp
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:15
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: appdb
- name: POSTGRES_USER
value: postgres
- name: POSTGRES_PASSWORD
value: password
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres-storage
persistentVolumeClaim:
claimName: postgres-pvc
---
# PostgreSQL Service
apiVersion: v1
kind: Service
metadata:
name: postgres-service
namespace: webapp
spec:
type: ClusterIP
selector:
app: postgres
ports:
- port: 5432
targetPort: 5432
---
# Redis Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: webapp
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7-alpine
ports:
- containerPort: 6379
---
# Redis Service
apiVersion: v1
kind: Service
metadata:
name: redis-service
namespace: webapp
spec:
type: ClusterIP
selector:
app: redis
ports:
- port: 6379
targetPort: 6379
---
# Flask Application Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: flask-app
namespace: webapp
spec:
replicas: 3
selector:
matchLabels:
app: flask-app
template:
metadata:
labels:
app: flask-app
spec:
containers:
- name: webapp
image: myregistry/flask-app:latest
ports:
- containerPort: 5000
env:
- name: DATABASE_URL
value: postgresql://postgres:password@postgres-service:5432/appdb
- name: REDIS_URL
value: redis://redis-service:6379
---
# Flask Application Service
apiVersion: v1
kind: Service
metadata:
name: flask-service
namespace: webapp
spec:
type: ClusterIP
selector:
app: flask-app
ports:
- port: 5000
targetPort: 5000
---
# Nginx Ingress Controller Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-ingress
namespace: webapp
spec:
replicas: 2
selector:
matchLabels:
app: nginx-ingress
template:
metadata:
labels:
app: nginx-ingress
spec:
containers:
- name: nginx
image: nginx:alpine
ports:
- containerPort: 80
- containerPort: 443
---
# Nginx Service (LoadBalancer)
apiVersion: v1
kind: Service
metadata:
name: nginx-service
namespace: webapp
spec:
type: LoadBalancer
selector:
app: nginx-ingress
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
---
# PersistentVolumeClaim for PostgreSQL
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
namespace: webapp
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: standard
---
# ConfigMap for Application Configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: webapp
data:
APP_ENV: production
LOG_LEVEL: info
MAX_WORKERS: "4"