-
Notifications
You must be signed in to change notification settings - Fork 0
/
kubernetes.yaml
236 lines (235 loc) · 5.34 KB
/
kubernetes.yaml
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# ____ _ ____ _
# / ___|___ __| | ___/ ___|| |__ __ _ _ __ ___
# | | / _ \ / _` |/ _ \___ \| '_ \ / _` | '__/ _ \
# | |__| (_) | (_| | __/___) | | | | (_| | | | __/
# \____\___/ \__,_|\___|____/|_| |_|\__,_|_| \___|
# Version 1.1 @ Kubernetes
# 2023/09/02
# MIT License
# By Tim Dürr (t9craft)
apiVersion: v1
kind: Namespace
metadata:
name: codeshare
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: codesharev1-default
namespace: codeshare
spec:
ingress:
- from:
- podSelector:
matchLabels:
ch.t9craft.network/codesharev1-default: "true"
podSelector:
matchLabels:
ch.t9craft.network/codesharev1-default: "true"
---
apiVersion: v1
kind: Service
metadata:
labels:
ch.t9craft.service: mysql
name: mysql
namespace: codeshare
spec:
ports:
- name: "3306"
port: 3306
targetPort: 3306
selector:
ch.t9craft.service: mysql
status:
loadBalancer: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
ch.t9craft.service: mysql
name: mysql
namespace: codeshare
spec:
replicas: 1 # Number of MySQL replicas
selector:
matchLabels:
ch.t9craft.service: mysql
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
ch.t9craft.network/codesharev1-default: "true"
ch.t9craft.service: mysql
spec:
containers:
- env: # You may also change these values in the PHP configuration
- name: MYSQL_DATABASE
value: codeshare
- name: MYSQL_PASSWORD
value: W1EavJ6k6D
- name: MYSQL_ROOT_PASSWORD
value: 4F8VK4xB5YpX
- name: MYSQL_USER
value: dbuser
image: mysql:8.0.32
name: mysql-container
ports:
- containerPort: 3306
resources:
requests:
memory: "512Mi"
cpu: "0.5"
limits:
memory: "1Gi"
cpu: "1"
restartPolicy: Always
status: {}
---
apiVersion: v1
kind: Service
metadata:
labels:
ch.t9craft.service: nginx
name: nginx
namespace: codeshare
spec:
ports:
- name: "80"
port: 80
targetPort: 80
selector:
ch.t9craft.service: nginx
status:
loadBalancer: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
ch.t9craft.service: nginx
name: nginx
namespace: codeshare
spec:
replicas: 1 # Number of Nginx replicas
selector:
matchLabels:
ch.t9craft.service: nginx
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
ch.t9craft.network/codesharev1-default: "true"
ch.t9craft.service: nginx
spec:
containers:
- image: tdu135585/codeshare-nginx-default:latest
name: nginx-container
ports:
- containerPort: 80
resources:
requests:
memory: "128Mi"
cpu: "0.5"
limits:
memory: "256Mi"
cpu: "1"
restartPolicy: Always
status: {}
---
apiVersion: networking.k8s.io/v1 #NOT WORKING CORRECTLY
kind: Ingress
metadata:
name: nginx-ingress
namespace: codeshare
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: codeshare.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx
port:
number: 80
---
apiVersion: v1
kind: Service
metadata:
labels:
ch.t9craft.service: php
name: php
namespace: codeshare
spec:
ports:
- name: "9000"
port: 9000
targetPort: 9000
selector:
ch.t9craft.service: php
status:
loadBalancer: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
ch.t9craft.service: php
name: php
namespace: codeshare
spec:
replicas: 1 # Number of PHP replicas
selector:
matchLabels:
ch.t9craft.service: php
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
ch.t9craft.network/codesharev1-default: "true"
ch.t9craft.service: php
spec:
containers:
- env: # DO NOT CHANGE DB_HOST AND DB_TABLE; You may also change these values in the MYSQL configuration
- name: DB_HOST
value: mysql
- name: DB_NAME
value: codeshare
- name: DB_PASSWORD
value: W1EavJ6k6D
- name: DB_PORT
value: "3306"
- name: DB_TABLE
value: snippets
- name: DB_USERNAME
value: dbuser
image: tdu135585/codeshare-php-default:latest
name: php-container
ports:
- containerPort: 9000
resources:
requests:
memory: "256Mi"
cpu: "0.5"
limits:
memory: "512Mi"
cpu: "1"
restartPolicy: Always
status: {}