|
1 | 1 | <!-- {% if index %} -->
|
| 2 | + |
2 | 3 | # Installing Icinga for Kubernetes
|
3 | 4 |
|
4 | 5 | 
|
@@ -62,31 +63,85 @@ Icinga for Kubernetes installs its configuration file to `/etc/icinga-kubernetes
|
62 | 63 | pre-populating most of the settings for a local setup. Before running Icinga for Kubernetes,
|
63 | 64 | adjust the database credentials and, if necessary, the connection configuration.
|
64 | 65 | 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). |
68 | 67 |
|
69 | 68 | 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 | + |
70 | 73 | To connect to a Kubernetes cluster, a locally accessible
|
71 | 74 | [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: |
75 | 98 |
|
76 | 99 | ```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 |
79 | 103 | ```
|
80 | 104 |
|
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: |
82 | 128 |
|
83 | 129 | ```bash
|
84 | 130 | systemctl enable --now icinga-kubernetes
|
85 | 131 | ```
|
86 | 132 |
|
| 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 | + |
87 | 141 | #### Using a Container
|
88 | 142 |
|
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) |
90 | 145 | adjust the database credentials and, if necessary, the connection configuration.
|
91 | 146 | The configuration file explains general settings.
|
92 | 147 | 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
|
125 | 180 |
|
126 | 181 | ##### Configuring Icinga for Kubernetes
|
127 | 182 |
|
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) |
129 | 185 | adjust the database credentials and, if necessary, the connection configuration.
|
130 | 186 | The configuration file explains general settings.
|
131 | 187 | All available settings can be found under [Configuration](03-Configuration.md).
|
|
0 commit comments