Skip to content

Commit 793000c

Browse files
committed
Add the health handler and the OpenShift Kubernetes deploymentinto README.adoc
1 parent d15b638 commit 793000c

File tree

1 file changed

+84
-10
lines changed

1 file changed

+84
-10
lines changed

README.adoc

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ In this handler are the following modules in use.
1919
IMPORTANT: The relative paths are relative to the current web root
2020
directory `http.vars.root`!
2121

22+
=== Environment Variables
23+
24+
.Parameters
25+
[cols="2,6",options=header]
26+
|===
27+
|Name
28+
|Description
29+
30+
|**APPPORT**
31+
|The Port on which Caddyserver should listen. The format depends which Configuration file format you use. See the official Caddyserver documentation for the format https://caddyserver.com/docs/conventions#network-addresses[Network addresses]
32+
33+
|**SKIP_LOG**
34+
|With this variable can you control if the health check will be logged or not. This feature was implemented as part of the vars handler.
35+
36+
|===
37+
2238
=== Parameters
2339

2440
.Parameters
@@ -45,7 +61,7 @@ directory be evaluated at runtime from this variable `http.vars.root`.
4561

4662
|**max_form_buffer**
4763
|The maximum buffer size for https://pkg.go.dev/net/http#Request.ParseMultipartForm[ParseMultipartForm]. It accepts all size values supported by https://pkg.go.dev/github.com/dustin/go-humanize#pkg-constants[go-humanize]. Here can also be used a https://caddyserver.com/docs/conventions#placeholders[Placeholder] +
48-
JSON: `"{env.MAXFILESIZE}"` +
64+
JSON: `"{env.MAXBUFFSIZE}"` +
4965
Caddyfile: `{$MAXBUFFSIZE}` +
5066

5167
The default size is **1G**.
@@ -58,7 +74,7 @@ The default size is **1G**.
5874
|is the maximum size in bytes allowed for the upload.
5975
It accepts all size values supported by https://pkg.go.dev/github.com/dustin/go-humanize#pkg-constants[go-humanize]. Reads of more bytes will return an error with HTTP status 413. Here can also be used a https://caddyserver.com/docs/conventions#placeholders[Placeholder] +
6076
JSON: `"{env.MAXFILESIZE}"` +
61-
Caddyfile: `{$MAXBUFFSIZE}` +
77+
Caddyfile: `{$MAXFILESIZE}` +
6278

6379
The default size is **1G**.
6480

@@ -174,28 +190,28 @@ Here a example Caddyfile which expects that the environment variable
174190

175191
=== local
176192
[source,shell]
177-
---
193+
----
178194
xcaddy build --with github.com/kirsch33/realip \
179195
--with github.com/git001/caddyv2-upload
180-
---
196+
----
181197

182198
=== docker
183199
[source,shell]
184-
---
200+
----
185201
buildah bud --tag caddyv2-upload .
186202
# or
187203
docker build --tag caddyv2-upload .
188-
---
204+
----
189205

190206
== run
191207

192208
=== cli
193209

194210
[source,shell]
195-
---
211+
----
196212
APPPORT=:2011 ./caddy run \
197213
-config Caddyfile-upload.json
198-
---
214+
----
199215

200216
=== docker
201217

@@ -208,14 +224,72 @@ The default listen port must be defined with this variable
208224
https://hub.docker.com/r/me2digital/caddyv2-upload
209225

210226
[source,shell]
211-
---
227+
----
212228
podman run --rm --network host --name caddy-test \
213229
--env APPPORT=:8888 -it \
214230
docker.io/me2digital/caddyv2-upload:latest
215231
# or
216232
docker run --name caddy-test --rm \
217233
docker.io/me2digital/caddyv2-upload:latest
218-
---
234+
----
235+
236+
=== OpenShift / kubernetes
237+
238+
You can use the examples in the directory `openshift` to deploy the caddy uploader
239+
into your OpenShift or kubernetes Cluster.
240+
241+
[source,shell]
242+
----
243+
oc new-project caddyupload
244+
oc -n caddyupload apply -f openshift/
245+
----
246+
247+
To adopt the used Caddyfile then can you easily do this with a configmap.
248+
The commands below show the steps.
249+
250+
[source,shell]
251+
----
252+
# add configure change trigger
253+
oc -n caddyupload \
254+
set triggers \
255+
deployment.apps/caddy-upload \
256+
--from-config
257+
258+
# create configmap
259+
oc -n caddyupload \
260+
create configmap \
261+
caddyfile-json \
262+
--from-file=Caddyfile-upload.json=<PATH_TO_LOCAL>/Caddyfile-upload.json
263+
264+
# add configmap to caddy deployment
265+
oc -n caddyupload \
266+
set volumes \
267+
deployment.apps/caddy-upload \
268+
--add --configmap-name=caddyfile-json \
269+
--mount-path=/opt/webroot/config/Caddyfile-upload.json \
270+
--name=caddyfile-json \
271+
--sub-path=Caddyfile-upload.json \
272+
--type=configmap
273+
----
274+
275+
In case the first shot of the configuration file does not work can you use the following
276+
commands to recreate the configuration file.
277+
278+
[source,shell]
279+
----
280+
oc -n caddyupload-nis delete configmap caddyfile-json \
281+
&& oc -n caddyupload-nis create configmap caddyfile-json --from-file=Caddyfile-upload.json=<PATH_TO_LOCAL>/Caddyfile-upload.json
282+
283+
# output of the commands
284+
configmap "caddyfile-json" deleted
285+
configmap/caddyfile-json created
286+
----
287+
288+
== Health probe
289+
290+
There is a builtin health handler with the path `/health` which just returns
291+
`200` and `Okay`.
292+
The log output can be controled via the environment variable `SKIP_LOG`.
219293

220294
== example cli
221295

0 commit comments

Comments
 (0)