2021-12-18 04:38:29 +01:00
# Installing ntfy
2021-12-20 03:01:49 +01:00
The `ntfy` CLI allows you to [publish messages ](publish.md ), [subscribe to topics ](subscribe/cli.md ) as well as to
self-host your own ntfy server. It's all pretty straight forward. Just install the binary, package or Docker image,
2021-12-05 21:57:37 +01:00
configure it and run it. Just like any other software. No fuzz.
!!! info
2021-12-20 03:01:49 +01:00
The following steps are only required if you want to **self-host your own ntfy server or you want to use the ntfy CLI** .
2021-12-18 04:38:29 +01:00
If you just want to [send messages using ntfy.sh ](publish.md ), you don't need to install anything. You can just use
`curl` .
2021-12-02 05:08:12 +01:00
## General steps
The ntfy server comes as a statically linked binary and is shipped as tarball, deb/rpm packages and as a Docker image.
We support amd64, armv7 and arm64.
1. Install ntfy using one of the methods described below
2022-05-11 04:10:38 +02:00
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 ))
2022-12-30 14:59:28 +01:00
3. Or (optionally) create/edit `~/.config/ntfy/client.yml` (for the 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 ))
2021-12-18 04:38:29 +01:00
To run the ntfy server, then just run `ntfy serve` (or `systemctl start ntfy` when using the deb/rpm).
2022-11-08 15:14:37 +01:00
To send messages, use `ntfy publish` . To subscribe to topics, use `ntfy subscribe` (see [subscribing via CLI ](subscribe/cli.md )
2021-12-18 04:38:29 +01:00
for details).
2021-12-02 05:08:12 +01:00
2022-05-11 04:10:38 +02:00
## Linux binaries
2021-12-02 05:08:12 +01:00
Please check out the [releases page ](https://github.com/binwiederhier/ntfy/releases ) for binaries and
deb/rpm packages.
2021-12-04 02:38:21 +01:00
=== "x86_64/amd64"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_x86_64.tar.gz
tar zxvf ntfy_1.31.0_linux_x86_64.tar.gz
sudo cp -a ntfy_1.31.0_linux_x86_64/ntfy /usr/bin/ntfy
sudo mkdir /etc/ntfy & & sudo cp ntfy_1.31.0_linux_x86_64/{client,server}/*.yml /etc/ntfy
2022-03-17 02:40:56 +01:00
sudo ntfy serve
2021-12-04 02:38:21 +01:00
```
2021-12-02 05:08:12 +01:00
2022-04-25 03:53:08 +02:00
=== "armv6"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_armv6.tar.gz
tar zxvf ntfy_1.31.0_linux_armv6.tar.gz
sudo cp -a ntfy_1.31.0_linux_armv6/ntfy /usr/bin/ntfy
sudo mkdir /etc/ntfy & & sudo cp ntfy_1.31.0_linux_armv6/{client,server}/*.yml /etc/ntfy
2022-04-25 03:53:08 +02:00
sudo ntfy serve
```
2021-12-04 02:38:21 +01:00
=== "armv7/armhf"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_armv7.tar.gz
tar zxvf ntfy_1.31.0_linux_armv7.tar.gz
sudo cp -a ntfy_1.31.0_linux_armv7/ntfy /usr/bin/ntfy
sudo mkdir /etc/ntfy & & sudo cp ntfy_1.31.0_linux_armv7/{client,server}/*.yml /etc/ntfy
2022-03-17 02:40:56 +01:00
sudo ntfy serve
2021-12-04 02:38:21 +01:00
```
2021-12-02 05:08:12 +01:00
2021-12-04 02:38:21 +01:00
=== "arm64"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_arm64.tar.gz
tar zxvf ntfy_1.31.0_linux_arm64.tar.gz
sudo cp -a ntfy_1.31.0_linux_arm64/ntfy /usr/bin/ntfy
sudo mkdir /etc/ntfy & & sudo cp ntfy_1.31.0_linux_arm64/{client,server}/*.yml /etc/ntfy
2022-03-17 02:40:56 +01:00
sudo ntfy serve
2021-12-04 02:38:21 +01:00
```
2021-12-02 05:08:12 +01:00
## Debian/Ubuntu repository
Installation via Debian repository:
2021-12-04 02:38:21 +01:00
=== "x86_64/amd64"
```bash
2022-10-09 22:19:07 +02:00
sudo mkdir -p /etc/apt/keyrings
2022-10-09 22:22:08 +02:00
curl -fsSL https://archive.heckel.io/apt/pubkey.txt | sudo gpg --dearmor -o /etc/apt/keyrings/archive.heckel.io.gpg
2021-12-04 02:38:21 +01:00
sudo apt install apt-transport-https
2022-10-09 22:22:08 +02:00
sudo sh -c "echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/archive.heckel.io.gpg] https://archive.heckel.io/apt debian main' \
2021-12-04 02:38:21 +01:00
> /etc/apt/sources.list.d/archive.heckel.io.list"
sudo apt update
sudo apt install ntfy
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
=== "armv7/armhf"
```bash
2022-10-09 22:22:08 +02:00
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://archive.heckel.io/apt/pubkey.txt | sudo gpg --dearmor -o /etc/apt/keyrings/archive.heckel.io.gpg
2021-12-04 02:38:21 +01:00
sudo apt install apt-transport-https
2022-10-09 22:22:08 +02:00
sudo sh -c "echo 'deb [arch=armhf signed-by=/etc/apt/keyrings/archive.heckel.io.gpg] https://archive.heckel.io/apt debian main' \
> /etc/apt/sources.list.d/archive.heckel.io.list"
2021-12-04 02:38:21 +01:00
sudo apt update
sudo apt install ntfy
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
=== "arm64"
```bash
2022-10-09 22:22:08 +02:00
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://archive.heckel.io/apt/pubkey.txt | sudo gpg --dearmor -o /etc/apt/keyrings/archive.heckel.io.gpg
2021-12-04 02:38:21 +01:00
sudo apt install apt-transport-https
2022-10-09 22:22:08 +02:00
sudo sh -c "echo 'deb [arch=arm64 signed-by=/etc/apt/keyrings/archive.heckel.io.gpg] https://archive.heckel.io/apt debian main' \
> /etc/apt/sources.list.d/archive.heckel.io.list"
2021-12-04 02:38:21 +01:00
sudo apt update
sudo apt install ntfy
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
2021-12-02 05:08:12 +01:00
Manually installing the .deb file:
2021-12-04 02:38:21 +01:00
=== "x86_64/amd64"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_amd64.deb
2021-12-04 02:38:21 +01:00
sudo dpkg -i ntfy_*.deb
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
2022-04-25 03:53:08 +02:00
=== "armv6"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_armv6.deb
2022-04-25 03:53:08 +02:00
sudo dpkg -i ntfy_*.deb
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
2021-12-04 02:38:21 +01:00
=== "armv7/armhf"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_armv7.deb
2021-12-04 02:38:21 +01:00
sudo dpkg -i ntfy_*.deb
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
=== "arm64"
```bash
2023-02-15 03:45:03 +01:00
wget https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_arm64.deb
2021-12-04 02:38:21 +01:00
sudo dpkg -i ntfy_*.deb
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
2021-12-02 05:08:12 +01:00
## Fedora/RHEL/CentOS
2021-12-04 02:38:21 +01:00
=== "x86_64/amd64"
```bash
2023-02-15 03:45:03 +01:00
sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_amd64.rpm
2021-12-04 02:38:21 +01:00
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
2022-04-25 03:53:08 +02:00
=== "armv6"
```bash
2023-02-15 03:45:03 +01:00
sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_armv6.rpm
2022-04-25 03:53:08 +02:00
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
2021-12-04 02:38:21 +01:00
=== "armv7/armhf"
```bash
2023-02-15 03:45:03 +01:00
sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_armv7.rpm
2021-12-04 02:38:21 +01:00
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
=== "arm64"
```bash
2023-02-15 03:45:03 +01:00
sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_linux_arm64.rpm
2021-12-04 02:38:21 +01:00
sudo systemctl enable ntfy
sudo systemctl start ntfy
```
2021-12-02 05:08:12 +01:00
2021-12-27 17:39:42 +01:00
## Arch Linux
ntfy can be installed using an [AUR package ](https://aur.archlinux.org/packages/ntfysh-bin/ ). You can use an [AUR helper ](https://wiki.archlinux.org/title/AUR_helpers ) like `paru` , `yay` or others to download, build and install ntfy and keep it up to date.
```
paru -S ntfysh-bin
```
Alternatively, run the following commands to install ntfy manually:
```
curl https://aur.archlinux.org/cgit/aur.git/snapshot/ntfysh-bin.tar.gz | tar xzv
cd ntfysh-bin
makepkg -si
```
2022-05-30 10:59:23 +02:00
## NixOS / Nix
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:
```
nix-env -iA ntfy-sh
```
2022-11-17 19:37:24 +01:00
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 ).
2022-05-11 04:10:38 +02:00
## macOS
The [ntfy CLI ](subscribe/cli.md ) (`ntfy publish` and `ntfy subscribe` only) is supported on macOS as well.
2023-02-15 03:45:03 +01:00
To install, please [download the tarball ](https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_macOS_all.tar.gz ),
2022-06-23 20:33:51 +02:00
extract it and place it somewhere in your `PATH` (e.g. `/usr/local/bin/ntfy` ).
2022-05-11 04:10:38 +02:00
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
`~/Library/Application Support/ntfy/client.yml` (sample included in the tarball).
```bash
2023-02-15 03:45:03 +01:00
curl -L https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_macOS_all.tar.gz > ntfy_1.31.0_macOS_all.tar.gz
tar zxvf ntfy_1.31.0_macOS_all.tar.gz
sudo cp -a ntfy_1.31.0_macOS_all/ntfy /usr/local/bin/ntfy
2022-05-11 04:10:38 +02:00
mkdir ~/Library/Application\ Support/ntfy
2023-02-15 03:45:03 +01:00
cp ntfy_1.31.0_macOS_all/client/client.yml ~/Library/Application\ Support/ntfy/client.yml
2022-05-11 04:10:38 +02:00
ntfy --help
```
!!! info
2022-06-23 20:33:51 +02:00
There is a [GitHub issue ](https://github.com/binwiederhier/ntfy/issues/286 ) about making ntfy installable via
[Homebrew ](https://brew.sh/ ). I'll eventually get to that, but I'd also love if somebody else stepped up to do it.
Also, you can build and run the ntfy server on macOS as well, though I don't officially support that.
Check out the [build instructions ](develop.md ) for details.
2022-05-11 04:10:38 +02:00
## Windows
The [ntfy CLI ](subscribe/cli.md ) (`ntfy publish` and `ntfy subscribe` only) is supported on Windows as well.
2023-02-15 03:45:03 +01:00
To install, please [download the latest ZIP ](https://github.com/binwiederhier/ntfy/releases/download/v1.31.0/ntfy_1.31.0_windows_x86_64.zip ),
2022-05-11 04:10:38 +02:00
extract it and place the `ntfy.exe` binary somewhere in your `%Path%` .
The default path for the client config file is at `%AppData%\ntfy\client.yml` (not created automatically, sample in the ZIP file).
2022-06-04 20:29:21 +02:00
Also available in [Scoop's ](https://scoop.sh ) Main repository:
2022-06-04 20:27:26 +02:00
`scoop install ntfy`
2022-05-11 04:10:38 +02:00
!!! info
There is currently no installer for Windows, and the binary is not signed. If this is desired, please create a
[GitHub issue ](https://github.com/binwiederhier/ntfy/issues ) to let me know.
2021-12-02 05:08:12 +01:00
## Docker
2022-04-25 04:25:34 +02:00
The [ntfy image ](https://hub.docker.com/r/binwiederhier/ntfy ) is available for amd64, armv6, armv7 and arm64. It should
be pretty straight forward to use.
2021-12-04 02:38:21 +01:00
The server exposes its web UI and the API on port 80, so you need to expose that in Docker. To use the persistent
2021-12-17 15:32:59 +01:00
[message cache ](config.md#message-cache ), you also need to map a volume to `/var/cache/ntfy` . To change other settings,
2021-12-19 04:02:36 +01:00
you should map `/etc/ntfy` , so you can edit `/etc/ntfy/server.yml` .
2021-12-02 05:08:12 +01:00
2022-09-03 21:34:34 +02:00
!!! info
Note that the Docker image **does not contain a `/etc/ntfy/server.yml` file** . If you'd like to use a config file,
please manually create one outside the image and map it as a volume, e.g. via `-v /etc/ntfy:/etc/ntfy` . You may
use the [`server.yml` file on GitHub ](https://github.com/binwiederhier/ntfy/blob/main/server/server.yml ) as a template.
2021-12-02 05:08:12 +01:00
Basic usage (no cache or additional config):
```
2021-12-17 15:32:59 +01:00
docker run -p 80:80 -it binwiederhier/ntfy serve
2021-12-02 05:08:12 +01:00
```
With persistent cache (configured as command line arguments):
```bash
docker run \
-v /var/cache/ntfy:/var/cache/ntfy \
-p 80:80 \
-it \
binwiederhier/ntfy \
2022-06-12 16:43:42 +02:00
serve \
--cache-file /var/cache/ntfy/cache.db
2021-12-02 05:08:12 +01:00
```
2022-06-02 22:35:49 +02:00
With other config options, timezone, and non-root user (configured via `/etc/ntfy/server.yml` , see [configuration ](config.md ) for details):
2021-12-02 05:08:12 +01:00
```bash
docker run \
-v /etc/ntfy:/etc/ntfy \
2022-06-02 22:35:49 +02:00
-e TZ=UTC \
2021-12-02 05:08:12 +01:00
-p 80:80 \
2022-06-02 01:49:08 +02:00
-u UID:GID \
2021-12-02 05:08:12 +01:00
-it \
2021-12-17 15:32:59 +01:00
binwiederhier/ntfy \
serve
2021-12-02 05:08:12 +01:00
```
2022-06-02 01:49:08 +02:00
Using docker-compose with non-root user:
2022-04-01 00:16:56 +02:00
```yaml
2022-03-31 22:11:39 +02:00
version: "2.1"
services:
ntfy:
image: binwiederhier/ntfy
container_name: ntfy
command:
- serve
2022-06-02 22:35:49 +02:00
environment:
- TZ=UTC # optional: set desired timezone
user: UID:GID # optional: replace with your own user/group or uid/gid
2022-03-31 22:11:39 +02:00
volumes:
- /var/cache/ntfy:/var/cache/ntfy
- /etc/ntfy:/etc/ntfy
ports:
- 80:80
restart: unless-stopped
```
2023-01-22 10:32:30 +01:00
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.
2022-06-02 01:52:37 +02:00
2021-12-30 00:25:17 +01:00
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.
```
FROM binwiederhier/ntfy
COPY server.yml /etc/ntfy/server.yml
ENTRYPOINT ["ntfy", "serve"]
```
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.
2022-10-26 14:30:05 +02:00
## Kubernetes
2022-10-26 17:00:17 +02:00
The setup for Kubernetes is very similar to that for Docker, and requires a fairly minimal deployment or pod definition to function. There
2022-11-02 20:27:27 +01:00
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
2022-11-05 14:28:26 +01:00
unmanned pod.
2022-10-26 14:30:05 +02:00
2022-11-05 14:28:26 +01:00
=== "deployment"
```yaml
2022-10-26 14:30:05 +02:00
apiVersion: apps/v1
kind: Deployment
metadata:
2022-10-26 17:00:17 +02:00
name: ntfy
2022-10-26 14:30:05 +02:00
spec:
2022-10-26 17:00:17 +02:00
selector:
2022-10-26 14:30:05 +02:00
matchLabels:
2022-10-26 17:00:17 +02:00
app: ntfy
template:
2022-10-26 14:30:05 +02:00
metadata:
2022-10-26 17:00:17 +02:00
labels:
2022-10-26 14:30:05 +02:00
app: ntfy
spec:
2022-10-26 17:00:17 +02:00
containers:
- name: ntfy
2022-10-26 14:30:05 +02:00
image: binwiederhier/ntfy
args: ["serve"]
resources:
2022-10-26 17:00:17 +02:00
limits:
2022-10-26 14:30:05 +02:00
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80
2022-10-26 17:00:17 +02:00
name: http
volumeMounts:
- name: config
mountPath: "/etc/ntfy"
readOnly: true
volumes:
- name: config
configMap:
name: ntfy
---
# Basic service for port 80
apiVersion: v1
kind: Service
metadata:
name: ntfy
spec:
selector:
app: ntfy
ports:
- port: 80
targetPort: 80
2022-11-05 14:28:26 +01:00
```
2022-10-26 17:00:17 +02:00
2022-11-05 14:28:26 +01:00
=== "stateful set"
```yaml
2022-10-26 17:00:17 +02:00
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ntfy
spec:
selector:
matchLabels:
app: ntfy
serviceName: ntfy
template:
metadata:
labels:
app: ntfy
spec:
containers:
- name: ntfy
image: binwiederhier/ntfy
2023-01-13 19:29:44 +01:00
args: ["serve", "--cache-file", "/var/cache/ntfy/cache.db"]
2022-10-26 17:00:17 +02:00
ports:
- containerPort: 80
name: http
2022-10-26 14:30:05 +02:00
volumeMounts:
- name: config
2022-10-26 17:00:17 +02:00
mountPath: "/etc/ntfy"
readOnly: true
2023-01-13 19:29:44 +01:00
- name: cache
mountPath: "/var/cache/ntfy"
2022-10-26 17:00:17 +02:00
volumes:
2022-10-26 14:30:05 +02:00
- name: config
2022-10-26 17:00:17 +02:00
configMap:
2022-10-26 14:30:05 +02:00
name: ntfy
2022-10-26 17:00:17 +02:00
volumeClaimTemplates:
- metadata:
name: cache
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
2022-11-05 14:28:26 +01:00
```
2022-10-26 14:30:05 +02:00
2022-11-05 14:28:26 +01:00
=== "pod"
```yaml
2022-10-26 14:30:05 +02:00
apiVersion: v1
kind: Pod
metadata:
labels:
app: ntfy
spec:
containers:
- name: ntfy
image: binwiederhier/ntfy
args: ["serve"]
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80
name: http
volumeMounts:
- name: config
mountPath: "/etc/ntfy"
readOnly: true
volumes:
- name: config
configMap:
name: ntfy
2022-11-05 14:28:26 +01:00
```
2022-10-26 14:30:05 +02:00
2022-11-02 20:27:27 +01:00
Configuration is relatively straightforward. As an example, a minimal configuration is provided.
2022-10-26 14:30:05 +02:00
2022-11-05 14:28:26 +01:00
=== "resource definition"
```yaml
2022-10-26 14:30:05 +02:00
apiVersion: v1
kind: ConfigMap
metadata:
2022-10-26 17:00:17 +02:00
name: ntfy
2022-10-26 14:30:05 +02:00
data:
2022-11-15 15:10:55 +01:00
server.yml: |
2022-10-26 14:30:05 +02:00
# Template: https://github.com/binwiederhier/ntfy/blob/main/server/server.yml
base-url: https://ntfy.sh
2022-11-05 14:28:26 +01:00
```
2022-11-02 20:27:27 +01:00
2022-11-05 14:28:26 +01:00
=== "from-file"
```bash
2022-10-26 14:30:05 +02:00
kubectl create configmap ntfy --from-file=server.yml
2022-11-05 14:28:26 +01:00
```
2022-11-02 20:27:27 +01:00
2022-11-05 15:42:56 +01:00
## Kustomize
2022-11-18 02:57:01 +01:00
ntfy can be deployed in a Kubernetes cluster with [Kustomize ](https://github.com/kubernetes-sigs/kustomize ), a tool used
to customize Kubernetes objects using a `kustomization.yaml` file.
2022-11-05 15:42:56 +01:00
1. Create new folder - `ntfy`
2. Add all files listed below
2022-11-18 02:57:01 +01:00
1. `kustomization.yaml` - stores all configmaps and resources used in a deployment
2. `ntfy-deployment.yaml` - define deployment type and its parameters
3. `ntfy-pvc.yaml` - describes how [persistent volumes ](https://kubernetes.io/docs/concepts/storage/persistent-volumes/ ) will be created
4. `ntfy-svc.yaml` - expose application to the internal kubernetes network
5. `ntfy-ingress.yaml` - expose service to outside the network using [ingress controller ](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/ )
6. `server.yaml` - simple server configuration
3. Replace **TESTNAMESPACE** within `kustomization.yaml` with designated namespace
4. Replace **ntfy.test** within `ntfy-ingress.yaml` with desired DNS name
5. Apply configuration to cluster set in current context:
2022-11-02 20:27:27 +01:00
2022-11-05 15:42:56 +01:00
```bash
kubectl apply -k /ntfy
2022-11-02 20:27:27 +01:00
```
2022-11-05 15:42:56 +01:00
=== "kustomization.yaml"
```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ntfy-deployment.yaml # deployment definition
- ntfy-svc.yaml # service connecting pods to cluster network
- ntfy-pvc.yaml # pvc used to store cache and attachment
- ntfy-ingress.yaml # ingress definition
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
- name: server-config
files:
- server.yml
namespace: TESTNAMESPACE # select namespace for whole application
```
=== "ntfy-deployment.yaml"
```yaml
apiVersion: apps/v1
kind: Deployment
2022-11-02 20:27:27 +01:00
metadata:
2022-11-05 15:42:56 +01:00
name: ntfy-deployment
2022-11-02 20:27:27 +01:00
labels:
2022-11-05 15:42:56 +01:00
app: ntfy-deployment
2022-11-02 20:27:27 +01:00
spec:
2022-11-05 15:42:56 +01:00
revisionHistoryLimit: 1
replicas: 1
selector:
matchLabels:
app: ntfy-pod
template:
metadata:
labels:
app: ntfy-pod
spec:
containers:
- name: ntfy
image: binwiederhier/ntfy:v1.28.0 # set deployed version
args: ["serve"]
env: #example of adjustments made in environmental variables
- name: TZ # set timezone
value: XXXXXXX
- name: NTFY_DEBUG # enable/disable debug
value: "false"
- name: NTFY_LOG_LEVEL # adjust log level
value: INFO
- name: NTFY_BASE_URL # add base url
value: XXXXXXXXXX
ports:
- containerPort: 80
name: http-ntfy
resources:
limits:
memory: 300Mi
cpu: 200m
requests:
cpu: 150m
memory: 150Mi
volumeMounts:
- mountPath: /etc/ntfy/server.yml
subPath: server.yml
name: config-volume # generated vie configMapGenerator from kustomization file
- mountPath: /var/cache/ntfy
name: cache-volume #cache volume mounted to persistent volume
volumes:
- name: config-volume
configMap: # uses configmap generator to parse server.yml to configmap
name: server-config
- name: cache-volume
persistentVolumeClaim: # stores /cache/ntfy in defined pv
claimName: ntfy-pvc
```
=== "ntfy-pvc.yaml"
```yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ntfy-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-path # adjust storage if needed
resources:
requests:
storage: 1Gi
```
2022-11-02 20:27:27 +01:00
2022-11-05 15:42:56 +01:00
=== "ntfy-svc.yaml"
```yaml
apiVersion: v1
kind: Service
metadata:
name: ntfy-svc
spec:
type: ClusterIP
selector:
app: ntfy-pod
ports:
- name: http-ntfy-out
protocol: TCP
port: 80
targetPort: http-ntfy
```
2022-11-02 20:27:27 +01:00
2022-11-05 15:42:56 +01:00
=== "ntfy-ingress.yaml"
```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ntfy-ingress
spec:
rules:
- host: ntfy.test #select own
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ntfy-svc
port:
number: 80
```
2022-11-02 20:27:27 +01:00
2022-11-05 15:42:56 +01:00
=== "server.yml"
```yaml
cache-file: "/var/cache/ntfy/cache.db"
attachment-cache-dir: "/var/cache/ntfy/attachments"
2022-11-18 02:52:16 +01:00
```