Debian Codegraph @

docs/install.md

raw
1 # Installing ntfy
2 The `ntfy` CLI allows you to [publish messages](publish.md), [subscribe to topics](subscribe/cli.md) as well as to
3 self-host your own ntfy server. It's all pretty straight forward. Just install the binary, package or Docker image,
4 configure it and run it. Just like any other software. No fuzz.
5
6 !!! info
7 The following steps are only required if you want to **self-host your own ntfy server or you want to use the ntfy CLI**.
8 If you just want to [send messages using ntfy.sh](publish.md), you don't need to install anything. You can just use
9 `curl`.
10
11 ## General steps
12 The ntfy server comes as a statically linked binary and is shipped as tarball, deb/rpm packages and as a Docker image.
13 We support amd64, armv7 and arm64.
14
15 1. Install ntfy using one of the methods described below
16 2. Then (optionally) edit `/etc/ntfy/server.yml` for the server (Linux only, see [configuration](config.md) or [sample server.yml](https://github.com/binwiederhier/ntfy/blob/main/server/server.yml))
17 3. Or (optionally) create/edit `~/.config/ntfy/client.yml` (for the non-root user), `~/Library/Application Support/ntfy/client.yml` (for the macOS non-root user), or `/etc/ntfy/client.yml` (for the root user), see [sample client.yml](https://github.com/binwiederhier/ntfy/blob/main/client/client.yml))
18
19 To run the ntfy server, then just run `ntfy serve` (or `systemctl start ntfy` when using the deb/rpm).
20 To send messages, use `ntfy publish`. To subscribe to topics, use `ntfy subscribe` (see [subscribing via CLI](subscribe/cli.md)
21 for details).
22
23 If you like tutorials, check out :simple-youtube: [Kris Occhipinti's ntfy install guide](https://www.youtube.com/watch?v=bZzqrX05mNU) on YouTube, or
24 [Alex's Docker-based setup guide](https://blog.alexsguardian.net/posts/2023/09/12/selfhosting-ntfy/). Both are great
25 resources to get started. _I am not affiliated with Kris or Alex, I just liked their video/post._
26
27 ## Linux binaries
28 Please check out the [releases page](https://github.com/binwiederhier/ntfy/releases) for binaries and
29 deb/rpm packages.
30
31 ### Download and run
32 The steps below allow you to download ntfy server and run it in a pinch. But it won't be enough to install it permanently
33 as a service starting at boot time.
34
35 === "x86_64/amd64"
36 ```bash
37 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_amd64.tar.gz
38 tar zxvf ntfy_2.27.0_linux_amd64.tar.gz
39 sudo cp -a ntfy_2.27.0_linux_amd64/ntfy /usr/local/bin/ntfy
40 sudo mkdir /etc/ntfy && sudo cp ntfy_2.27.0_linux_amd64/{client,server}/*.yml /etc/ntfy
41 sudo ntfy serve
42 ```
43
44 === "armv6"
45 ```bash
46 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_armv6.tar.gz
47 tar zxvf ntfy_2.27.0_linux_armv6.tar.gz
48 sudo cp -a ntfy_2.27.0_linux_armv6/ntfy /usr/bin/ntfy
49 sudo mkdir /etc/ntfy && sudo cp ntfy_2.27.0_linux_armv6/{client,server}/*.yml /etc/ntfy
50 sudo ntfy serve
51 ```
52
53 === "armv7/armhf"
54 ```bash
55 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_armv7.tar.gz
56 tar zxvf ntfy_2.27.0_linux_armv7.tar.gz
57 sudo cp -a ntfy_2.27.0_linux_armv7/ntfy /usr/bin/ntfy
58 sudo mkdir /etc/ntfy && sudo cp ntfy_2.27.0_linux_armv7/{client,server}/*.yml /etc/ntfy
59 sudo ntfy serve
60 ```
61
62 === "arm64"
63 ```bash
64 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_arm64.tar.gz
65 tar zxvf ntfy_2.27.0_linux_arm64.tar.gz
66 sudo cp -a ntfy_2.27.0_linux_arm64/ntfy /usr/bin/ntfy
67 sudo mkdir /etc/ntfy && sudo cp ntfy_2.27.0_linux_arm64/{client,server}/*.yml /etc/ntfy
68 sudo ntfy serve
69 ```
70
71 ### Install as a service
72 If you want to install ntfy server permanently as a service, and your OS/distribution of choice doesn't offer a package,
73 there are a few more steps to follow.
74
75 Create the ntfy user and group:
76 ```bash
77 useradd --system --home-dir /var/lib/ntfy --shell /bin/false --comment "User for the simple HTTP-based pub-sub notification service" ntfy
78 ```
79
80 Depending on your init system, the following steps will diverge.
81
82 #### On systemd systems
83 Install the ntfy server unit file (which contains parameters to start the service at boot time):
84
85 === "x86_64/amd64"
86 ```bash
87 sudo mv ntfy_2.27.0_linux_amd64/server/ntfy.service /etc/systemd/system/
88 sudo chmod 644 /etc/systemd/system/ntfy.service
89 ```
90
91 === "armv6"
92 ```bash
93 sudo mv ntfy_2.27.0_linux_armv6/server/ntfy.service /etc/systemd/system/
94 sudo chmod 644 /etc/systemd/system/ntfy.service
95 ```
96
97 === "armv7/armhf"
98 ```bash
99 sudo mv ntfy_2.27.0_linux_armv7/server/ntfy.service /etc/systemd/system/
100 sudo chmod 644 /etc/systemd/system/ntfy.service
101 ```
102
103 === "arm64"
104 ```bash
105 sudo mv ntfy_2.27.0_linux_arm64/server/ntfy.service /etc/systemd/system/
106 sudo chmod 644 /etc/systemd/system/ntfy.service
107 ```
108
109 Then notify systemd we have added a new service and start the service:
110
111 ```bash
112 sudo systemctl daemon-reload
113 sudo systemctl start ntfy
114 ```
115
116 #### On OpenRC systems
117 Install the ntfy server service script:
118
119 === "x86_64/amd64"
120 ```bash
121 sudo mv ntfy_2.27.0_linux_amd64/server/ntfy.openrc /etc/init.d/ntfy
122 sudo chmod 755 /etc/init.d/ntfy
123 ```
124
125 === "armv6"
126 ```bash
127 sudo mv ntfy_2.27.0_linux_armv6/server/ntfy.openrc /etc/init.d/ntfy
128 sudo chmod 755 /etc/init.d/ntfy
129 ```
130
131 === "armv7/armhf"
132 ```bash
133 sudo mv ntfy_2.27.0_linux_armv7/server/ntfy.openrc /etc/init.d/ntfy
134 sudo chmod 755 /etc/init.d/ntfy
135 ```
136
137 === "arm64"
138 ```bash
139 sudo mv ntfy_2.27.0_linux_arm64/server/ntfy.openrc /etc/init.d/ntfy
140 sudo chmod 755 /etc/init.d/ntfy
141 ```
142
143 Start the ntfy server service:
144
145 ```bash
146 sudo rc-service ntfy start
147 ```
148
149 Add the ntfy server service to the default runlevel (so that it starts at boot time):
150
151 ```bash
152 sudo rc-update add ntfy default
153 ```
154
155 ## Debian/Ubuntu repository
156
157 !!! info
158 As of September 2025, **the official ntfy.sh Debian/Ubuntu repository has moved to [archive.ntfy.sh](https://archive.ntfy.sh/apt)**.
159 The old repository [archive.heckel.io](https://archive.heckel.io/apt) is still available for now, but will likely
160 go away soon. I suspect I will phase it out some time in early 2026.
161
162 Installation via Debian/Ubuntu repository (fingerprint `55BA 774A 6F5E E674 31E4 B6B7 CFDB 962D 4F1E C4AF`):
163
164 === "x86_64/amd64"
165 ```bash
166 sudo mkdir -p /etc/apt/keyrings
167 sudo curl -L -o /etc/apt/keyrings/ntfy.gpg https://archive.ntfy.sh/apt/keyring.gpg
168 sudo apt install apt-transport-https
169 echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/ntfy.gpg] https://archive.ntfy.sh/apt stable main" \
170 | sudo tee /etc/apt/sources.list.d/ntfy.list
171 sudo apt update
172 sudo apt install ntfy
173 sudo systemctl enable ntfy
174 sudo systemctl start ntfy
175 ```
176
177 === "armv7/armhf"
178 ```bash
179 sudo mkdir -p /etc/apt/keyrings
180 sudo curl -L -o /etc/apt/keyrings/ntfy.gpg https://archive.ntfy.sh/apt/keyring.gpg
181 sudo apt install apt-transport-https
182 echo "deb [arch=armhf signed-by=/etc/apt/keyrings/ntfy.gpg] https://archive.ntfy.sh/apt stable main" \
183 | sudo tee /etc/apt/sources.list.d/ntfy.list
184 sudo apt update
185 sudo apt install ntfy
186 sudo systemctl enable ntfy
187 sudo systemctl start ntfy
188 ```
189
190 === "arm64"
191 ```bash
192 sudo mkdir -p /etc/apt/keyrings
193 sudo curl -L -o /etc/apt/keyrings/ntfy.gpg https://archive.ntfy.sh/apt/keyring.gpg
194 sudo apt install apt-transport-https
195 echo "deb [arch=arm64 signed-by=/etc/apt/keyrings/ntfy.gpg] https://archive.ntfy.sh/apt stable main" \
196 | sudo tee /etc/apt/sources.list.d/ntfy.list
197 sudo apt update
198 sudo apt install ntfy
199 sudo systemctl enable ntfy
200 sudo systemctl start ntfy
201 ```
202
203 Manually installing the .deb file:
204
205 === "x86_64/amd64"
206 ```bash
207 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_amd64.deb
208 sudo dpkg -i ntfy_*.deb
209 sudo systemctl enable ntfy
210 sudo systemctl start ntfy
211 ```
212
213 === "armv6"
214 ```bash
215 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_armv6.deb
216 sudo dpkg -i ntfy_*.deb
217 sudo systemctl enable ntfy
218 sudo systemctl start ntfy
219 ```
220
221 === "armv7/armhf"
222 ```bash
223 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_armv7.deb
224 sudo dpkg -i ntfy_*.deb
225 sudo systemctl enable ntfy
226 sudo systemctl start ntfy
227 ```
228
229 === "arm64"
230 ```bash
231 wget https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_arm64.deb
232 sudo dpkg -i ntfy_*.deb
233 sudo systemctl enable ntfy
234 sudo systemctl start ntfy
235 ```
236
237 ## Fedora/RHEL/CentOS
238
239 === "x86_64/amd64"
240 ```bash
241 sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_amd64.rpm
242 sudo systemctl enable ntfy
243 sudo systemctl start ntfy
244 ```
245
246 === "armv6"
247 ```bash
248 sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_armv6.rpm
249 sudo systemctl enable ntfy
250 sudo systemctl start ntfy
251 ```
252
253 === "armv7/armhf"
254 ```bash
255 sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_armv7.rpm
256 sudo systemctl enable ntfy
257 sudo systemctl start ntfy
258 ```
259
260 === "arm64"
261 ```bash
262 sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_linux_arm64.rpm
263 sudo systemctl enable ntfy
264 sudo systemctl start ntfy
265 ```
266
267 ## Arch Linux
268 <span class="community-badge" title="This package is maintained by the community, not the ntfy developers"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg> Community maintained</span>
269
270 ntfy can be installed using an [AUR package](https://aur.archlinux.org/packages/ntfysh-bin/).
271 You can use an [AUR helper](https://wiki.archlinux.org/title/AUR_helpers) like `paru`, `yay` or others to download,
272 build and install ntfy and keep it up to date.
273 ```
274 paru -S ntfysh-bin
275 ```
276
277 Alternatively, run the following commands to install ntfy manually:
278 ```
279 curl https://aur.archlinux.org/cgit/aur.git/snapshot/ntfysh-bin.tar.gz | tar xzv
280 cd ntfysh-bin
281 makepkg -si
282 ```
283
284 ## NixOS / Nix
285 <span class="community-badge" title="This package is maintained by the community, not the ntfy developers"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg> Community maintained</span>
286
287 ntfy is packaged in nixpkgs as `ntfy-sh`. It can be installed by adding the package name to the configuration file and calling `nixos-rebuild`. Alternatively, the following command can be used to install ntfy in the current user environment:
288 ```
289 nix-env -iA ntfy-sh
290 ```
291
292 NixOS also supports [declarative setup of the ntfy server](https://search.nixos.org/options?channel=unstable&show=services.ntfy-sh.enable&from=0&size=50&sort=relevance&type=packages&query=ntfy).
293
294 ## FreeBSD
295 <span class="community-badge" title="This package is maintained by the community, not the ntfy developers"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg> Community maintained</span>
296
297 ntfy is ported to FreeBSD and available via the ports collection as [sysutils/go-ntfy](https://www.freshports.org/sysutils/go-ntfy/). You can install it via `pkg`:
298 ```
299 pkg install go-ntfy
300 ```
301
302 ## macOS
303 The [ntfy CLI](subscribe/cli.md) (`ntfy publish` and `ntfy subscribe` only) is supported on macOS as well.
304 To install, please [download the tarball](https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_darwin_all.tar.gz),
305 extract it and place it somewhere in your `PATH` (e.g. `/usr/local/bin/ntfy`).
306
307 If run as `root`, ntfy will look for its config at `/etc/ntfy/client.yml`. For all other users, it'll look for it at
308 `~/Library/Application Support/ntfy/client.yml` (sample included in the tarball).
309
310 ```bash
311 curl -L https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_darwin_all.tar.gz > ntfy_2.27.0_darwin_all.tar.gz
312 tar zxvf ntfy_2.27.0_darwin_all.tar.gz
313 sudo cp -a ntfy_2.27.0_darwin_all/ntfy /usr/local/bin/ntfy
314 mkdir ~/Library/Application\ Support/ntfy
315 cp ntfy_2.27.0_darwin_all/client/client.yml ~/Library/Application\ Support/ntfy/client.yml
316 ntfy --help
317 ```
318
319 !!! info
320 Only the ntfy CLI is supported on macOS. ntfy server is currently not supported, but you can build and run it for
321 development as well. Check out the [build instructions](develop.md) for details.
322
323 ## Homebrew
324 <span class="community-badge" title="This package is maintained by the community, not the ntfy developers"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg> Community maintained</span>
325
326 To install the [ntfy CLI](subscribe/cli.md) (`ntfy publish` and `ntfy subscribe` only) via Homebrew (Linux and macOS),
327 simply run:
328 ```
329 brew install ntfy
330 ```
331
332 ## Windows
333 The ntfy server and CLI are fully supported on Windows. You can run the ntfy server directly or as a Windows service.
334 To install, you can either
335
336 * [Download the latest ZIP](https://github.com/binwiederhier/ntfy/releases/download/v2.27.0/ntfy_2.27.0_windows_amd64.zip),
337 extract it and place the `ntfy.exe` binary somewhere in your `%Path%`.
338 * Or install ntfy from the [Scoop](https://scoop.sh) main repository via `scoop install ntfy`
339
340 Once installed, you can run the ntfy CLI commands like so:
341
342 ```
343 ntfy.exe -h
344 ```
345
346 The default configuration file location on Windows is `%ProgramData%\ntfy\server.yml` (e.g., `C:\ProgramData\ntfy\server.yml`)
347 for the server, and `%AppData%\ntfy\client.yml` for the client. You may need to create the directory and config file manually.
348
349 To install the ntfy server as a Windows service, you can use the built-in `sc` command. For example, run this in an
350 elevated command prompt (adjust the path to `ntfy.exe` accordingly):
351
352 ```
353 sc create ntfy binPath="C:\path\to\ntfy.exe serve" start=auto
354 sc start ntfy
355 ```
356
357 ## Docker
358 The [ntfy image](https://hub.docker.com/r/binwiederhier/ntfy) is available for amd64, armv6, armv7 and arm64. It should
359 be pretty straight forward to use.
360
361 The server exposes its web UI and the API on port 80, so you need to expose that in Docker. To use the persistent
362 [message cache](config.md#message-cache), you also need to map a volume to `/var/cache/ntfy`. To change other settings,
363 you should map `/etc/ntfy`, so you can edit `/etc/ntfy/server.yml`.
364
365 !!! info
366 Note that the Docker image **does not contain a `/etc/ntfy/server.yml` file**. If you'd like to use a config file,
367 please manually create one outside the image and map it as a volume, e.g. via `-v /etc/ntfy:/etc/ntfy`. You may
368 use the [`server.yml` file on GitHub](https://github.com/binwiederhier/ntfy/blob/main/server/server.yml) as a template.
369
370 Basic usage (no cache or additional config):
371 ```
372 docker run -p 80:80 -it binwiederhier/ntfy serve
373 ```
374
375 With persistent cache (configured as command line arguments):
376 ```bash
377 docker run \
378 -v /var/cache/ntfy:/var/cache/ntfy \
379 -p 80:80 \
380 -it \
381 binwiederhier/ntfy \
382 serve \
383 --cache-file /var/cache/ntfy/cache.db
384 ```
385
386 With other config options, timezone, and non-root user (configured via `/etc/ntfy/server.yml`, see [configuration](config.md) for details):
387 ```bash
388 docker run \
389 -v /etc/ntfy:/etc/ntfy \
390 -e TZ=UTC \
391 -p 80:80 \
392 -u UID:GID \
393 -it \
394 binwiederhier/ntfy \
395 serve
396 ```
397
398 Using docker-compose with non-root user and healthchecks enabled:
399 ```yaml
400 services:
401 ntfy:
402 image: binwiederhier/ntfy
403 container_name: ntfy
404 command:
405 - serve
406 environment:
407 - TZ=UTC # optional: set desired timezone
408 user: UID:GID # optional: replace with your own user/group or uid/gid
409 volumes:
410 - /var/cache/ntfy:/var/cache/ntfy
411 - /etc/ntfy:/etc/ntfy
412 ports:
413 - 80:80
414 healthcheck: # optional: remember to adapt the host:port to your environment
415 test: ["CMD-SHELL", "wget -q --tries=1 http://localhost:80/v1/health -O - | grep -Eo '\"healthy\"\\s*:\\s*true' || exit 1"]
416 interval: 60s
417 timeout: 10s
418 retries: 3
419 start_period: 40s
420 restart: unless-stopped
421 init: true # needed, if healthcheck is used. Prevents zombie processes
422 ```
423
424 If using a non-root user when running the docker version, be sure to chown the server.yml, user.db, and cache.db files and attachments directory to the same uid/gid.
425
426 Alternatively, you may wish to build a customized Docker image that can be run with fewer command-line arguments and without delivering the configuration file separately.
427 ```
428 FROM binwiederhier/ntfy
429 COPY server.yml /etc/ntfy/server.yml
430 ENTRYPOINT ["ntfy", "serve"]
431 ```
432 This image can be pushed to a container registry and shipped independently. All that's needed when running it is mapping ntfy's port to a host port.
433
434 ## Kubernetes
435
436 The setup for Kubernetes is very similar to that for Docker, and requires a fairly minimal deployment or pod definition to function. There
437 are a few options to mix and match, including a deployment without a cache file, a stateful set with a persistent cache, and a standalone
438 unmanned pod.
439
440 === "deployment"
441 ```yaml
442 apiVersion: apps/v1
443 kind: Deployment
444 metadata:
445 name: ntfy
446 spec:
447 selector:
448 matchLabels:
449 app: ntfy
450 template:
451 metadata:
452 labels:
453 app: ntfy
454 spec:
455 containers:
456 - name: ntfy
457 image: binwiederhier/ntfy
458 args: ["serve"]
459 resources:
460 limits:
461 memory: "128Mi"
462 cpu: "500m"
463 ports:
464 - containerPort: 80
465 name: http
466 volumeMounts:
467 - name: config
468 mountPath: "/etc/ntfy"
469 readOnly: true
470 volumes:
471 - name: config
472 configMap:
473 name: ntfy
474 ---
475 # Basic service for port 80
476 apiVersion: v1
477 kind: Service
478 metadata:
479 name: ntfy
480 spec:
481 selector:
482 app: ntfy
483 ports:
484 - port: 80
485 targetPort: 80
486 ```
487
488 === "stateful set"
489 ```yaml
490 apiVersion: apps/v1
491 kind: StatefulSet
492 metadata:
493 name: ntfy
494 spec:
495 selector:
496 matchLabels:
497 app: ntfy
498 serviceName: ntfy
499 template:
500 metadata:
501 labels:
502 app: ntfy
503 spec:
504 containers:
505 - name: ntfy
506 image: binwiederhier/ntfy
507 args: ["serve", "--cache-file", "/var/cache/ntfy/cache.db"]
508 ports:
509 - containerPort: 80
510 name: http
511 volumeMounts:
512 - name: config
513 mountPath: "/etc/ntfy"
514 readOnly: true
515 - name: cache
516 mountPath: "/var/cache/ntfy"
517 volumes:
518 - name: config
519 configMap:
520 name: ntfy
521 volumeClaimTemplates:
522 - metadata:
523 name: cache
524 spec:
525 accessModes: [ "ReadWriteOnce" ]
526 resources:
527 requests:
528 storage: 1Gi
529 ```
530
531 === "pod"
532 ```yaml
533 apiVersion: v1
534 kind: Pod
535 metadata:
536 labels:
537 app: ntfy
538 spec:
539 containers:
540 - name: ntfy
541 image: binwiederhier/ntfy
542 args: ["serve"]
543 resources:
544 limits:
545 memory: "128Mi"
546 cpu: "500m"
547 ports:
548 - containerPort: 80
549 name: http
550 volumeMounts:
551 - name: config
552 mountPath: "/etc/ntfy"
553 readOnly: true
554 volumes:
555 - name: config
556 configMap:
557 name: ntfy
558 ```
559
560 Configuration is relatively straightforward. As an example, a minimal configuration is provided.
561
562 === "resource definition"
563 ```yaml
564 apiVersion: v1
565 kind: ConfigMap
566 metadata:
567 name: ntfy
568 data:
569 server.yml: |
570 # Template: https://github.com/binwiederhier/ntfy/blob/main/server/server.yml
571 base-url: https://ntfy.sh
572 ```
573
574 === "from-file"
575 ```bash
576 kubectl create configmap ntfy --from-file=server.yml
577 ```
578
579 ## Kustomize
580
581 ntfy can be deployed in a Kubernetes cluster with [Kustomize](https://github.com/kubernetes-sigs/kustomize), a tool used
582 to customize Kubernetes objects using a `kustomization.yaml` file.
583
584 1. Create new folder - `ntfy`
585 2. Add all files listed below
586 1. `kustomization.yaml` - stores all configmaps and resources used in a deployment
587 2. `ntfy-deployment.yaml` - define deployment type and its parameters
588 3. `ntfy-pvc.yaml` - describes how [persistent volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) will be created
589 4. `ntfy-svc.yaml` - expose application to the internal kubernetes network
590 5. `ntfy-ingress.yaml` - expose service to outside the network using [ingress controller](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/)
591 6. `server.yaml` - simple server configuration
592 3. Replace **TESTNAMESPACE** within `kustomization.yaml` with designated namespace
593 4. Replace **ntfy.test** within `ntfy-ingress.yaml` with desired DNS name
594 5. Apply configuration to cluster set in current context:
595
596 ```bash
597 kubectl apply -k /ntfy
598 ```
599
600 === "kustomization.yaml"
601 ```yaml
602 apiVersion: kustomize.config.k8s.io/v1beta1
603 kind: Kustomization
604 resources:
605 - ntfy-deployment.yaml # deployment definition
606 - ntfy-svc.yaml # service connecting pods to cluster network
607 - ntfy-pvc.yaml # pvc used to store cache and attachment
608 - ntfy-ingress.yaml # ingress definition
609 configMapGenerator: # will parse config from raw config to configmap,it allows for dynamic reload of application if additional app is deployed ie https://github.com/stakater/Reloader
610 - name: server-config
611 files:
612 - server.yml
613 namespace: TESTNAMESPACE # select namespace for whole application
614 ```
615 === "ntfy-deployment.yaml"
616 ```yaml
617 apiVersion: apps/v1
618 kind: Deployment
619 metadata:
620 name: ntfy-deployment
621 labels:
622 app: ntfy-deployment
623 spec:
624 revisionHistoryLimit: 1
625 replicas: 1
626 selector:
627 matchLabels:
628 app: ntfy-pod
629 template:
630 metadata:
631 labels:
632 app: ntfy-pod
633 spec:
634 containers:
635 - name: ntfy
636 image: binwiederhier/ntfy:v1.28.0 # set deployed version
637 args: ["serve"]
638 env: #example of adjustments made in environmental variables
639 - name: TZ # set timezone
640 value: XXXXXXX
641 - name: NTFY_DEBUG # enable/disable debug
642 value: "false"
643 - name: NTFY_LOG_LEVEL # adjust log level
644 value: INFO
645 - name: NTFY_BASE_URL # add base url
646 value: XXXXXXXXXX
647 ports:
648 - containerPort: 80
649 name: http-ntfy
650 resources:
651 limits:
652 memory: 300Mi
653 cpu: 200m
654 requests:
655 cpu: 150m
656 memory: 150Mi
657 volumeMounts:
658 - mountPath: /etc/ntfy/server.yml
659 subPath: server.yml
660 name: config-volume # generated via configMapGenerator from kustomization file
661 - mountPath: /var/cache/ntfy
662 name: cache-volume # cache volume mounted to persistent volume
663 volumes:
664 - name: config-volume
665 configMap: # uses configmap generator to parse server.yml to configmap
666 name: server-config
667 - name: cache-volume
668 persistentVolumeClaim: # stores /cache/ntfy in defined pv
669 claimName: ntfy-pvc
670 ```
671
672 === "ntfy-pvc.yaml"
673 ```yaml
674 apiVersion: v1
675 kind: PersistentVolumeClaim
676 metadata:
677 name: ntfy-pvc
678 spec:
679 accessModes:
680 - ReadWriteOnce
681 storageClassName: local-path # adjust storage if needed
682 resources:
683 requests:
684 storage: 1Gi
685 ```
686
687 === "ntfy-svc.yaml"
688 ```yaml
689 apiVersion: v1
690 kind: Service
691 metadata:
692 name: ntfy-svc
693 spec:
694 type: ClusterIP
695 selector:
696 app: ntfy-pod
697 ports:
698 - name: http-ntfy-out
699 protocol: TCP
700 port: 80
701 targetPort: http-ntfy
702 ```
703
704 === "ntfy-ingress.yaml"
705 ```yaml
706 apiVersion: networking.k8s.io/v1
707 kind: Ingress
708 metadata:
709 name: ntfy-ingress
710 spec:
711 rules:
712 - host: ntfy.test #select own
713 http:
714 paths:
715 - path: /
716 pathType: Prefix
717 backend:
718 service:
719 name: ntfy-svc
720 port:
721 number: 80
722 ```
723
724 === "server.yml"
725 ```yaml
726 cache-file: "/var/cache/ntfy/cache.db"
727 attachment-cache-dir: "/var/cache/ntfy/attachments"
728 ```
729
730 ## Helm
731 <span class="community-badge" title="This package is maintained by the community, not the ntfy developers"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg> Community maintained</span>
732
733 If you prefer [Helm](https://helm.sh/), ntfy can be deployed using the third-party
734 [HelmForge chart](https://helmforge.dev/docs/charts/ntfy), which packages the official
735 `binwiederhier/ntfy` image with persistent storage, Service, Ingress, optional Prometheus metrics, and more.
736 This chart is **not** maintained by the ntfy developers.
737
738 !!! warning
739 The HelmForge project is young and maintained by a small community. Review the chart before deploying it,
740 and use it at your own risk.
741
742 ```bash
743 helm repo add helmforge https://repo.helmforge.dev
744 helm repo update
745 helm install ntfy helmforge/ntfy
746 ```
747
748 Alternatively, install it directly from the OCI registry:
749
750 ```bash
751 helm install ntfy oci://ghcr.io/helmforgedev/helm/ntfy
752 ```
753
754 Because ntfy's default SQLite storage is single-writer, run the chart as a single instance rather than
755 treating it as a horizontally scalable deployment. See the [chart documentation](https://helmforge.dev/docs/charts/ntfy)
756 for the full list of configurable values.