Skip to content

Commit

Permalink
Merge pull request #28 from OmegaVVeapon/configurable-healthcheck-port
Browse files Browse the repository at this point in the history
Changing default healthz port, adding configuration env var
  • Loading branch information
OmegaVVeapon authored Oct 13, 2021
2 parents 2e6f934 + 11844bf commit 3f7b09b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ If you are looking to use this image with the [Grafana Helm chart](https://githu

The sidecar offers a simple healthcheck endpoint for use in a liveness probe (don't use it for readiness is it makes no sense for an operator).

Should this port conflict with other containers in your pod, you can change it via the `HEALTHCHECK_PORT` env var.

```
livenessProbe:
httpGet:
path: /healthz
port: 8080
port: 8181
```

## Configuration Environment Variables
Expand All @@ -68,6 +70,7 @@ livenessProbe:
| WATCH_CLIENT_TIMEOUT | No | `660` | (seconds) is how long the session with a watching request will exist before closing it from the client side. This includes the connection establishing and event streaming. |
| WATCH_SERVER_TIMEOUT | No | `600` | (seconds) is how long the session with a watching request will exist before closing it from the server side. This value is passed to the server side in a query string, and the server decides on how to follow it. The watch-stream is then gracefully closed. |
| UNIQUE_FILENAMES | No (but recommended!) | `False` | A value of `true` will produce unique filenames to avoid issues when duplicate data keys exist between `ConfigMap`s and/or `Secret`s within the same or multiple `Namespace`s. |
| HEALTHCHECK_PORT | No | `8181` | Port on which the `/healthz` endpoint will be listening on |

## Gotchas

Expand Down
2 changes: 1 addition & 1 deletion app/sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def kopf_thread(
with contextlib.closing(loop):

opts = {
"liveness_endpoint": "http://0.0.0.0:8080/healthz",
"liveness_endpoint": f"http://0.0.0.0:{sidecar_settings.HEALTHCHECK_PORT}/healthz",
"clusterwide": False,
"namespaces": [],
"ready_flag": ready_flag,
Expand Down
4 changes: 3 additions & 1 deletion app/sidecar_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
DEFAULT_FILE_MODE = int(DEFAULT_FILE_MODE, base=8)
logger.info("DEFAULT_FILE_MODE is %s", DEFAULT_FILE_MODE)


# Set the client and service k8s API timeouts
# Very important! Without proper values, the operator may stop responding!
# See https://github.com/nolar/kopf/issues/585
Expand All @@ -73,3 +72,6 @@
UNIQUE_FILENAMES = get_env_var_bool('UNIQUE_FILENAMES')
if get_env_var_bool('UNIQUE_FILENAMES'):
logger.info("Unique filenames will be enforced.")

HEALTHCHECK_PORT = os.getenv('HEALTHCHECK_PORT', '8181')
logger.info("Healthcheck /healthz endpoint listening on port %s", HEALTHCHECK_PORT)
2 changes: 1 addition & 1 deletion examples/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
livenessProbe:
httpGet:
path: /healthz
port: 8080
port: 8181
volumeMounts:
- name: shared-volume
mountPath: /tmp/
Expand Down

0 comments on commit 3f7b09b

Please sign in to comment.