Prometheus rule support
This commit is contained in:
@@ -22,7 +22,7 @@ image:
|
||||
ingress:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: nginx
|
||||
host: chart-example.local
|
||||
host: my-release.mycompany.com
|
||||
EOF
|
||||
|
||||
helm template my-release onechart/onechart -f values.yaml
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
Feature branch deploys in large part is a templating question:
|
||||
|
||||
- Names should be unique to avoid collision between application instances
|
||||
- Names should follow some convention
|
||||
- It's driven by CI, and git branch name is a typical input parameter
|
||||
|
||||
### Avoiding name collisions
|
||||
|
||||
With OneChart, you can drive the naming of most resources by setting a unique release name.
|
||||
Release name is unique in Helm too, so it makes it a good tool to drive resource names.
|
||||
|
||||
One good practice can be to add a `-$BRANCH` suffix to the feature branch instance:
|
||||
|
||||
```
|
||||
helm template my-release-my-branch onechart/onechart -f values.yaml
|
||||
```
|
||||
|
||||
### Avoiding domain name collision
|
||||
|
||||
The release name will make all Kubernetes objects unique, but the domain name configuration remains static:
|
||||
|
||||
```
|
||||
image:
|
||||
repository: nginx
|
||||
tag: 1.19.3
|
||||
|
||||
ingress:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: nginx
|
||||
host: my-release.mycompany.com
|
||||
|
||||
helm template my-release-my-branch onechart/onechart -f values.yaml
|
||||
```
|
||||
|
||||
The `ingress.host` name should also be dynamic to avoid the collision:
|
||||
|
||||
```
|
||||
helm template my-release-my-branch onechart/onechart\
|
||||
-f values.yaml \
|
||||
--set ingress.host=my-release-my-branch.mycompany.com
|
||||
```
|
||||
|
||||
### CI
|
||||
|
||||
In CI the above command needs to be templated:
|
||||
|
||||
```
|
||||
helm template my-release-$BRANCH onechart/onechart\
|
||||
-f values.yaml \
|
||||
--set ingress.host=my-release-$BRANCH.mycompany.com
|
||||
```
|
||||
|
||||
where $BRANCH is a built-in CI variable.
|
||||
@@ -0,0 +1,27 @@
|
||||
This page shows how you can add a `PrometheusRule` to your app deployment.
|
||||
|
||||
!!! Note
|
||||
This is a feature only supported by the [kube-stack-prometheus stack (formerly known as the Prometheus Operator)](https://github.com/prometheus-operator/kube-prometheus)
|
||||
|
||||
The following Prometheus rule alerts if a pod is crashlooping:
|
||||
|
||||
```yaml
|
||||
image:
|
||||
repository: nginx
|
||||
tag: 1.19.3
|
||||
|
||||
prometheusRules:
|
||||
- name: KubePodCrashLooping
|
||||
message: "Pod {{`{{`}} $labels.namespace {{`}}`}}/{{`{{`}} $labels.pod {{`}}`}} ({{`{{`}} $labels.container {{`}}`}}) is restarting {{`{{`}} printf \"%.2f\" $value {{`}}`}} times / 5 minutes."
|
||||
runBookURL: myrunbook.com
|
||||
expression: "rate(kube_pod_container_status_restarts_total{job=\"kube-state-metrics\", namespace=~\"{{ $targetNamespace }}\"}[15m]) * 60 * 5 > 0"
|
||||
for: 1h
|
||||
labels:
|
||||
severity: critical
|
||||
```
|
||||
|
||||
Check the Kubernetes manifest:
|
||||
|
||||
```bash
|
||||
helm template my-release onechart/onechart -f values.yaml
|
||||
```
|
||||
+3
-1
@@ -28,7 +28,7 @@ site_description: >-
|
||||
# Repository
|
||||
repo_name: onechart/onechart
|
||||
repo_url: https://github.com/onechart/onechart
|
||||
edit_uri: https://github.com/onechart/onechart/website
|
||||
edit_uri: https://github.com/onechart/onechart/tree/master/website/docs
|
||||
|
||||
extra_css:
|
||||
- stylesheets/extra.css
|
||||
@@ -138,3 +138,5 @@ nav:
|
||||
- Volumes: examples/volumes.md
|
||||
- Custom command: examples/custom-command.md
|
||||
- Cron job: examples/cron-job.md
|
||||
- Feature branch deploys: examples/feature-branch-deploys.md
|
||||
- Prometheus monitoring rules: examples/prometheus-monitoring-rules.md
|
||||
|
||||
Reference in New Issue
Block a user