-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathk8s.yaml
More file actions
270 lines (254 loc) · 6.95 KB
/
k8s.yaml
File metadata and controls
270 lines (254 loc) · 6.95 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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# Website (PHP)
# Source: https://github.com/Tob1as/docker-php
# upload/copy your files to webfolder:
# kubectl -n website cp ./upload/. $(kubectl -n website get pod -l app.kubernetes.io/name=website -o jsonpath="{.items[0].metadata.name}"):/var/www/html/ -c website
---
# Recommended: After the initial installation, comment Namespace out to protect it from deletion by mistake.
apiVersion: v1
kind: Namespace
metadata:
name: website
---
# Recommended: After the initial installation, comment PVC out to protect it from deletion by mistake.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: website-data
namespace: website
labels:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
storageClassName: local-path # set to your class
resources:
requests:
storage: 15Gi
---
apiVersion: v1
kind: ConfigMap
metadata:
name: website-env-config
namespace: website
labels:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
data:
TZ: "Europe/Berlin"
PHP_ERRORS: "1"
PHP_MEM_LIMIT: "128"
PHP_POST_MAX_SIZE: "250"
PHP_UPLOAD_MAX_FILESIZE: "250"
PHP_MAX_FILE_UPLOADS: "20"
PHP_MAX_EXECUTION_TIME: "120"
PHP_SET_OPCACHE_SETTINGS: "0"
CREATE_PHPINFO_FILE: "0"
CREATE_INDEX_FILE: "0"
## next env only with php-fpm
#ENABLE_PHP_FPM_STATUS: "1"
## next env only with apache
ENABLE_APACHE_REWRITE: "1"
ENABLE_APACHE_ACTIONS: "0"
ENABLE_APACHE_SSL: "0"
ENABLE_APACHE_HEADERS: "0"
ENABLE_APACHE_ALLOWOVERRIDE: "1"
ENABLE_APACHE_REMOTEIP: "1"
ENABLE_APACHE_STATUS: "1"
#ENABLE_APACHE_SSL_REDIRECT: "0"
#APACHE_SERVER_NAME: ""
#APACHE_SERVER_ALIAS: ""
#APACHE_SERVER_ADMIN: ""
DISABLE_APACHE_DEFAULTSITES: "0"
## next env only with nginx
#ENABLE_NGINX_REMOTEIP: "1"
#ENABLE_NGINX_STATUS: "1"
#---
#
## when you want using "data" instead "stringData" then ...
## convert string to base64 in Linux: "echo -n 'value' | base64"
#
#apiVersion: v1
#kind: Secret
#metadata:
# name: website-env-secret
# namespace: website
# labels:
# app.kubernetes.io/name: website
# app.kubernetes.io/component: server
# app.kubernetes.io/part-of: website
#stringData:
# MY_SECRET_ENV: "my-secret"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: website
namespace: website
labels:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
template:
metadata:
labels:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
spec:
#hostname: website
#imagePullSecrets:
#- name: regcred-dockerhub
restartPolicy: Always
#securityContext:
# fsGroup: 33 # 33 for apache or 82 for alpine
containers:
- name: website
image: docker.io/tobi312/php:8.4-apache # or: docker.io/tobi312/php:8.4-apache-debian-wsc
#image: docker.io/tobi312/php:8.4-fpm-nginx-alpine # or: docker.io/tobi312/php:8.4-fpm-nginx-alpine-wsc
imagePullPolicy: Always
envFrom:
- configMapRef:
name: website-env-config
#optional: true
- secretRef:
name: website-env-secret
optional: true
ports:
- containerPort: 80
name: http
protocol: TCP
- containerPort: 443
name: https
protocol: TCP
readinessProbe:
#httpGet:
# path: /server-status # /server-status or /nginx_ping
# port: 80
# scheme: HTTP
tcpSocket:
port: 80
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
livenessProbe:
#httpGet:
# path: /server-status # /server-status or /nginx_ping
# port: 80
# scheme: HTTP
tcpSocket:
port: 80
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
resources:
requests:
memory: "512Mi"
cpu: "0.5"
limits:
memory: "1Gi"
cpu: "1.0"
volumeMounts:
- name: website-data
mountPath: /var/www/html
initContainers:
# volume-mount-chmod only for first startup or set securityContext->fsGroup
- name: volume-mount-chmod
image: busybox
command: ["sh", "-c", "mkdir -p /var/www/html; chmod 777 /var/www/html; exit"]
volumeMounts:
- name: website-data
mountPath: /var/www/html
resources:
requests:
memory: "128Mi"
cpu: "0.1"
limits:
memory: "128Mi"
cpu: "0.1"
volumes:
- name: website-data
persistentVolumeClaim:
claimName: website-data
---
apiVersion: v1
kind: Service
metadata:
name: website
namespace: website
labels:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
spec:
type: ClusterIP
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
#- name: https
# protocol: TCP
# port: 443
# targetPort: 443
selector:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: website
namespace: website
labels:
app.kubernetes.io/name: website
app.kubernetes.io/component: server
app.kubernetes.io/part-of: website
annotations:
## https://cert-manager.io/docs/
#cert-manager.io/cluster-issuer: ingress-tls-secret
#cert-manager.io/acme-challenge-type: http01
## NGINX
#nginx.ingress.kubernetes.io/ssl-redirect: "true"
#nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
## Traefik
#traefik.ingress.kubernetes.io/router.middlewares: 'website-https-redirectscheme@kubernetescrd'
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
traefik.ingress.kubernetes.io/service.serversscheme: http
spec:
#ingressClassName: nginx # nginx or traefik or in future "Kubernetes Gateway API"
tls:
- hosts:
- example.com
secretName: ingress-tls-secret
rules:
- host: example.com
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: website
port:
#name: http
number: 80