Skip to content

Commit 9fe0599

Browse files
committed
Add docs
1 parent 433d445 commit 9fe0599

File tree

3 files changed

+148
-16
lines changed

3 files changed

+148
-16
lines changed

doc/01-About.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,21 @@ including the database, common setup approaches include the following:
2424

2525
## Multi-Cluster Support
2626

27-
Icinga for Kubernetes supports multiple Kubernetes clusters by deploying several daemons,
28-
each connecting to a different cluster but writing data into the same database.
29-
The web interface accesses this database to display resource information and state,
30-
offering the flexibility to view aggregated data from all clusters or focus on a specific cluster.
31-
This setup ensures scalable monitoring and a unified view of resources across multiple Kubernetes environments.
27+
Icinga for Kubernetes provides two approaches for monitoring multiple Kubernetes clusters.
28+
29+
**Option 1**: The Icinga for Kubernetes daemons are installed directly within each Kubernetes cluster.
30+
Each daemon connects to a central database - which resides outside the clusters - through an external service.
31+
This database serves as the unified data source for all monitored clusters. The web interface is also hosted
32+
outside the clusters, allowing for an aggregated view of resources from all clusters or a focused view on a
33+
specific cluster. This architecture ensures monitoring is handled locally within the clusters while centralizing
34+
data storage and visualization outside.
35+
36+
**Option 2**: All components, including the Icinga for Kubernetes daemons and the web interface, operate entirely
37+
outside the Kubernetes clusters. Instead of being deployed within the clusters, multiple systemd service instances
38+
are started on an external system, with each instance connecting to a different cluster.
39+
40+
More about multi-cluster support can be found under
41+
[Configuration](03-Configuration.md#multi-cluster-support-using-systemd-instantiated-services).
3242

3343
## Vision and Roadmap
3444

doc/02-Installation.md

+67-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!-- {% if index %} -->
2+
23
# Installing Icinga for Kubernetes
34

45
![Icinga for Kubernetes](res/icinga-kubernetes-installation.png)
@@ -62,31 +63,85 @@ Icinga for Kubernetes installs its configuration file to `/etc/icinga-kubernetes
6263
pre-populating most of the settings for a local setup. Before running Icinga for Kubernetes,
6364
adjust the database credentials and, if necessary, the connection configuration.
6465
The configuration file explains general settings.
65-
All available settings can be found under [Configuration](03-Configuration.md).
66-
67-
##### Running Icinga for Kubernetes
66+
All available settings can be found under [Configuration](03-Configuration.md#configuration-via-yaml-file).
6867

6968
The `icinga-kubernetes` package automatically installs the required systemd unit files to run Icinga for Kubernetes.
69+
The service instances are configured via environment files in `/etc/icinga-kubernetes`.
70+
More about the configuration via environment files can be found under
71+
[Configuration](03-Configuration.md#managing-instances-with-environment-files).
72+
7073
To connect to a Kubernetes cluster, a locally accessible
7174
[kubeconfig](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/) file is needed.
72-
You can specify which kubeconfig file to use by setting the `KUBECONFIG` environment variable for
73-
the Icinga for Kubernetes systemd service.
74-
To do this, run `systemctl edit icinga-kubernetes` and add the following:
75+
76+
If you're only planning to monitor a single Kubernetes cluster, you can simply edit
77+
`/etc/icinga-kubernetes/default.env`.
78+
This file serves as the configuration for your Icinga for Kubernetes default instance. It contains all the necessary
79+
parameters to connect to your Kubernetes cluster, such as the `KUBECONFIG` variable pointing to your kubeconfig file.
80+
More about the `default.env` file can be found under [Configuration](03-Configuration.md#default-environment).
81+
82+
##### Configuring multiple Instances of Icinga for Kubernetes for Multi-Cluster Support
83+
84+
If you're planning to monitor multiple Kubernetes clusters, you can add additional environment files.
85+
86+
**Add a new Instance**:
87+
88+
1. Create a new environment file in `/etc/icinga-kubernetes`. The file name will be the instance name for the
89+
systemd service. For example `test-cluster.env` will start the service instance `icinga-kubernetes@test-cluster`.
90+
2. Set the `KUBECONFIG` environment variable to configure how Icinga for Kubernetes can connect to the cluster.
91+
3. Set the `ICINGA_FOR_KUBERNETES_CLUSTER_NAME` environment variable to configure the cluster name. If the environment
92+
variable is not set the cluster name will be the environment file's name.
93+
4. You can add additional environment variables to override the `config.yml`
94+
([Available environment variables](03-Configuration.md#configuration-via-environment-variables)).
95+
5. Reload the systemd daemon with `systemctl daemon-reload` to recognize the new cluster configs.
96+
97+
An example `test-cluster.env` file could look like the following:
7598

7699
```bash
77-
[Service]
78-
Environment="KUBECONFIG=..."
100+
KUBECONFIG=$HOME/.kube/config
101+
ICINGA_FOR_KUBERNETES_CLUSTER_NAME="Test Cluster"
102+
ICINGA_FOR_KUBERNETES_PROMETHEUS_URL=http://localhost:9090
79103
```
80104

81-
Please run the following command to enable and start the Icinga for Kubernetes service:
105+
**Remove Instance**:
106+
107+
1. If running, stop the service instance manually. For `test-cluster` it would be
108+
`systemctl stop icinga-kubernetes@test-cluster`.
109+
2. Remove the corresponding environment file from `/etc/icinga-kubernetes`.
110+
3. Reload the systemd daemon with `systemctl daemon-reload` to make sure the daemon forgets the file.
111+
112+
!!! Warning
113+
114+
If you stop the service without removing the environment file, the instance will restart when the service is
115+
restarted.
116+
117+
If you remove the environment file without stopping the instance, the instance will try to restart and
118+
fail when the service is restarted.
119+
120+
You can also explicitly define which environment files should be used to start service instances. For this,
121+
you can adjust the `/etc/default/icinga-kubernetes` file.
122+
More about the this can be found under [Configuration](03-Configuration.md#service-configuration).
123+
124+
##### Running Icinga for Kubernetes
125+
126+
After configuring, please run the following command to enable and start all configured Icinga for Kubernetes
127+
service instances:
82128

83129
```bash
84130
systemctl enable --now icinga-kubernetes
85131
```
86132

133+
##### Stopping Icinga for Kubernetes
134+
135+
The following command will stop all running Icinga for Kubernetes services instances:
136+
137+
```bash
138+
systemctl stop icinga-kubernetes
139+
```
140+
87141
#### Using a Container
88142

89-
Before running Icinga for Kubernetes, create a local `config.yml` using [the sample configuration](../config.example.yml)
143+
Before running Icinga for Kubernetes, create a local `config.yml`
144+
using [the sample configuration](../config.example.yml)
90145
adjust the database credentials and, if necessary, the connection configuration.
91146
The configuration file explains general settings.
92147
All available settings can be found under [Configuration](03-Configuration.md).
@@ -125,7 +180,8 @@ go build -o icinga-kubernetes cmd/icinga-kubernetes/main.go
125180

126181
##### Configuring Icinga for Kubernetes
127182

128-
Before running Icinga for Kubernetes, create a local `config.yml` using [the sample configuration](../config.example.yml)
183+
Before running Icinga for Kubernetes, create a local `config.yml`
184+
using [the sample configuration](../config.example.yml)
129185
adjust the database credentials and, if necessary, the connection configuration.
130186
The configuration file explains general settings.
131187
All available settings can be found under [Configuration](03-Configuration.md).

doc/03-Configuration.md

+66
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,69 @@ The configurations set by environment variables override the ones set by YAML.
9797
| PROMETHEUS_URL | **Optional.** Prometheus server URL. If not set, metric synchronization is disabled. |
9898
| PROMETHEUS_USERNAME | **Optional.** Prometheus username. |
9999
| PROMETHEUS_PASSWORD | **Optional.** Prometheus password. |
100+
101+
## Multi-Cluster Support using systemd Instantiated Services
102+
103+
Starting from Icinga for Kubernetes version 0.3.0, multi-cluster support has been streamlined through
104+
systemd instantiated services. This approach allows you to run Icinga for Kubernetes components outside of the
105+
Kubernetes clusters themselves while enabling you to monitor multiple Kubernetes clusters. By leveraging systemd,
106+
you can manage separate instances of Icinga for Kubernetes, each connecting to a different cluster, without the need
107+
to install components directly inside the clusters.
108+
109+
### Managing Instances with Environment Files
110+
111+
Each instance of Icinga for Kubernetes is managed through an environment file (.env). These environment files contain
112+
the necessary configurations for connecting to specific Kubernetes clusters. Generally, the key configuration for each
113+
instance is the `KUBECONFIG`, which points to the kubeconfig file for the relevant cluster. However, it’s also possible
114+
to override other configurations depending on your needs.
115+
116+
The cluster name is typically derived from the environment file name, but you can override this default behavior using
117+
the `ICINGA_FOR_KUBERNETES_CLUSTER_NAME` variable. This cluster name is used throughout the frontend to identify and
118+
organize the monitoring data associated with that cluster.
119+
120+
### Default Environment
121+
122+
The `default.env` file is the default instance configuration. If you're only managing a single cluster, you can simply
123+
edit this file to configure your connection to that cluster. The `default.env` file contains the basic settings needed
124+
for the Icinga for Kubernetes daemon to connect to a Kubernetes cluster, including the `KUBECONFIG` variable, which
125+
points to the kubeconfig file for the cluster.
126+
127+
However, if you’re planning to monitor multiple clusters, you’ll want to create additional environment files for each
128+
additional cluster, as described in the earlier section.
129+
130+
### Service Configuration
131+
132+
The `/etc/default/icinga-kubernetes` file allows you to control which Icinga for Kubernetes service instances should be
133+
started automatically. This provides flexibility when managing multiple clusters by defining which environment files
134+
should be used for systemd service instances.
135+
136+
The `AUTOSTART` variable in `/etc/default/icinga-kubernetes` determines which clusters are automatically started.
137+
138+
The allowed values are:
139+
140+
* **all** (default if empty) – Starts all instances corresponding to environment files in `/etc/icinga-kubernetes/`.
141+
* **none** – Prevents automatic startup of any instances.
142+
* **A space-separated list of cluster names** – Starts only the specified instances, where each name corresponds to an
143+
environment file.
144+
145+
For example, to start only test-cluster and prod-cluster, set:
146+
147+
```bash
148+
AUTOSTART="test-cluster prod-cluster"
149+
```
150+
151+
This will start `icinga-kubernetes@test-cluster` and `icinga-kubernetes@prod-cluster`, using the configuration from
152+
`/etc/icinga-kubernetes/test-cluster.env` and `/etc/icinga-kubernetes/prod-cluster.env`, respectively.
153+
154+
After modifying this file, you must reload the systemd configuration:
155+
156+
```bash
157+
systemctl daemon-reload
158+
```
159+
160+
If you removed clusters from the `AUTOSTART` list, you may need to manually stop the corresponding instances before
161+
restarting the service:
162+
163+
```bash
164+
systemctl stop icinga-kubernetes@old-cluster
165+
```

0 commit comments

Comments
 (0)