forked from Jeremiaszmacura/devops-workshops-for-students
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk8s.yaml
More file actions
161 lines (161 loc) · 2.93 KB
/
k8s.yaml
File metadata and controls
161 lines (161 loc) · 2.93 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
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv-volume
labels:
type: local
app: postgres
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/postgres_data"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-pv-claim
labels:
app: postgres
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: workshop
data:
POSTGRES_DB: prod_db
POSTGRES_USER: prod_user
POSTGRES_PASSWORD: prod_password
---
apiVersion: v1
kind: ConfigMap
metadata:
name: flaskr-config
labels:
app: workshop
tier: backend
data:
FLASK_DEBUG: "True"
FLASK_ENV: "development"
DATABASE_URI: "postgresql://prod_user:prod_password@postgres:5432/prod_db"
---
apiVersion: v1
kind: Service
metadata:
name: postgres
labels:
app: workshop
spec:
type: NodePort
ports:
- protocol: TCP
port: 5432
targetPort: 5432
selector:
app: workshop
tier: database
---
apiVersion: v1
kind: Service
metadata:
name: flaskr
labels:
app: workshop
spec:
type: LoadBalancer
selector:
app: workshop
tier: backend
ports:
- protocol: TCP
port: 5000
targetPort: 5000
---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: postgres
labels:
app: workshop
spec:
replicas: 1
selector:
matchLabels:
app: workshop
tier: database
template:
metadata:
labels:
app: workshop
tier: database
spec:
volumes:
- name: postgresql
persistentVolumeClaim:
claimName: postgres-pv-claim
containers:
- name: postgres
image: postgres:14
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres-config
volumeMounts:
- name: postgresql
mountPath: /var/lib/postgresql/data
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flaskr
labels:
app: workshop
spec:
selector:
matchLabels:
app: workshop
tier: backend
replicas: 1
template:
metadata:
labels:
app: workshop
tier: backend
spec:
containers:
- name: flaskr
image: flask-app:develop
imagePullPolicy: IfNotPresent
startupProbe:
httpGet:
path: /
port: 5000
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet:
path: /
port: 5000
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 1
envFrom:
- configMapRef:
name: flaskr-config
ports:
- containerPort: 5000
restartPolicy: Always