Skip to content

Commit 6660ce2

Browse files
yypastushenkoYuri Pastushenko
andauthored
Add helm chart (deckhouse#18)
* Added helm chart * Added helm chart. * Bumped app version to v0.1.13. * Increased application version in docs to 0.1.13. Added newline at the end of file in templates. Co-authored-by: Yuri Pastushenko <[email protected]>
1 parent 8bccd14 commit 6660ce2

File tree

10 files changed

+311
-0
lines changed

10 files changed

+311
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "v0.1.13"
3+
description: Application for monitoring the cluster workloads image presence in docker registry.
4+
name: k8s-image-availability-exporter
5+
version: "0.0.1"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# k8s-image-availability-exporter
2+
3+
## Introduction
4+
5+
This chart bootstraps a [k8s-image-availability-exporter](https://github.com/flant/k8s-image-availability-exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
6+
7+
## Prerequisites
8+
- Kubernetes 1.12+
9+
- Helm 3+
10+
11+
## Installing the Chart
12+
13+
To install the chart with the release name `my-release`:
14+
15+
```console
16+
$ git clone https://github.com/flant/k8s-image-availability-exporter
17+
$ cd k8s-image-availability-exporter/helm
18+
$ helm install my-release k8s-image-availability-exporter
19+
```
20+
21+
The command clones the repository and deploys k8s-image-availability-exporter on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
22+
23+
The default installation includes only the deployment, service, and rbac configuration.
24+
25+
## Uninstalling the Chart
26+
27+
To uninstall/delete the `my-release` deployment:
28+
29+
```console
30+
$ helm delete my-release
31+
```
32+
33+
The command removes all the Kubernetes components associated with the chart and deletes the release.
34+
35+
## Configuration
36+
37+
The following tables list the configurable parameters of the k8s-image-availability-exporter chart and their default values.
38+
39+
### General
40+
| Parameter | Description | Default |
41+
| ----- | ----------- | ------ |
42+
| `k8sImageAvailabilityExporter.image.pullPolicy` | Image pull policy to use for the k8s-image-availability-exporter deployment | `IfNotPresent` |
43+
| `k8sImageAvailabilityExporter.image.repository` | Repository to use for the k8s-image-availability-exporter deployment | `flant/k8s-image-availability-exporter` |
44+
| `k8sImageAvailabilityExporter.image.tag` | Tag to use for the k8s-image-availability-exporter deployment | `v0.1.13` |
45+
| `k8sImageAvailabilityExporter.replicas` | Number of instances to deploy for a k8s-image-availability-exporter deployment. | `1` |
46+
| `k8sImageAvailabilityExporter.resources` | Resource limits for k8s-image-availability-exporter | `{}` |
47+
| `serviceMonitor.enabled` | Create [Prometheus Operator](https://github.com/coreos/prometheus-operator) serviceMonitor resource | `false` |
48+
| `serviceMonitor.interval` | Scrape interval for serviceMonitor | `15s` |
49+
| `prometheusRule.enabled` | Create [Prometheus Operator](https://github.com/coreos/prometheus-operator) prometheusRule resource | `false` |
50+
| `prometheusRule.defaultGroupsEnabled` | Setup default alerts (works only if prometheusRule.enabled is set to true) | `true` |
51+
| `prometheusRule.additionalGroups` | Additional PrometheusRule groups | `[]` |
52+
53+
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
54+
55+
```console
56+
$ helm install my-release k8s-image-availability-exporter --set k8sImageAvailabilityExporter.replicas=2
57+
```
58+
59+
Alternatively, one or more YAML files that specify the values for the above parameters can be provided while installing the chart. For example,
60+
61+
```console
62+
$ helm install my-release k8s-image-availability-exporter -f values1.yaml,values2.yaml
63+
```
64+
65+
> **Tip**: You can use the default [values.yaml](values.yaml)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Expand the name of the chart.
5+
*/}}
6+
{{- define "k8s-image-availability-exporter.name" -}}
7+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
8+
{{- end -}}
9+
10+
{{/*
11+
Create a default fully qualified app name.
12+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
13+
And depending on the resources the name is completed with an extension.
14+
If release name contains chart name it will be used as a full name.
15+
*/}}
16+
{{- define "k8s-image-availability-exporter.fullname" -}}
17+
{{- if .Values.fullnameOverride -}}
18+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
19+
{{- else -}}
20+
{{- $name := default .Chart.Name .Values.nameOverride -}}
21+
{{- if contains $name .Release.Name -}}
22+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
23+
{{- else -}}
24+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
25+
{{- end -}}
26+
{{- end -}}
27+
{{- end -}}
28+
29+
{{/*
30+
Create chart name and version as used by the chart label.
31+
*/}}
32+
{{- define "k8s-image-availability-exporter.chart" -}}
33+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
34+
{{- end -}}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
5+
labels:
6+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
7+
app.kubernetes.io/name: "{{ template "k8s-image-availability-exporter.fullname" . }}"
8+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
10+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
11+
app.kubernetes.io/component: monitoring
12+
spec:
13+
replicas: {{ .Values.k8sImageAvailabilityExporter.replicas }}
14+
selector:
15+
matchLabels:
16+
app: {{ template "k8s-image-availability-exporter.fullname" . }}
17+
template:
18+
metadata:
19+
labels:
20+
app: {{ template "k8s-image-availability-exporter.fullname" . }}
21+
spec:
22+
containers:
23+
- name: k8s-image-availability-exporter
24+
args: ["--bind-address=:8080"]
25+
ports:
26+
- containerPort: 8080
27+
name: http
28+
image: {{ .Values.k8sImageAvailabilityExporter.image.repository }}:{{ .Values.k8sImageAvailabilityExporter.image.tag }}
29+
imagePullPolicy: {{ .Values.k8sImageAvailabilityExporter.image.imagePullPolicy }}
30+
livenessProbe:
31+
httpGet:
32+
path: /healthz
33+
port: http
34+
scheme: HTTP
35+
readinessProbe:
36+
httpGet:
37+
path: /healthz
38+
port: http
39+
scheme: HTTP
40+
resources:
41+
{{ if .Values.k8sImageAvailabilityExporter.resources }}
42+
{{ .Values.k8sImageAvailabilityExporter.resources | toYaml | indent 10}}
43+
{{ end }}
44+
serviceAccountName: {{ template "k8s-image-availability-exporter.fullname" . }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{- if .Values.prometheusRule.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: PrometheusRule
4+
metadata:
5+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
6+
spec:
7+
groups:
8+
{{- if .Values.prometheusRule.defaultGroupsEnabled }}
9+
- name: k8s-image-availability-exporter.rules
10+
rules:
11+
- alert: DeploymentImageUnavailable
12+
expr: |
13+
max by (namespace, deployment, container, image) (
14+
k8s_image_availability_exporter_deployment_available == 0
15+
)
16+
annotations:
17+
message: >
18+
Image {{`{{ $labels.image }}`}} from container {{`{{ $labels.container }}`}}
19+
in deployment {{`{{ $labels.deployment }}`}}
20+
from namespace {{`{{ $labels.namespace }}`}}
21+
is not available in docker registry.
22+
labels:
23+
severity: critical
24+
- alert: StatefulSetImageUnavailable
25+
expr: |
26+
max by (namespace, statefulset, container, image) (
27+
k8s_image_availability_exporter_statefulset_available == 0
28+
)
29+
message: >
30+
Image {{`{{ $labels.image }}`}} from container {{`{{ $labels.container }}`}}
31+
in statefulSet {{`{{ $labels.statefulset }}`}}
32+
from namespace {{`{{ $labels.namespace }}`}}
33+
is not available in docker registry.
34+
labels:
35+
severity: critical
36+
- alert: DaemonSetImageUnavailable
37+
expr: |
38+
max by (namespace, daemonset, container, image) (
39+
k8s_image_availability_exporter_daemonset_available == 0
40+
)
41+
annotations:
42+
message: >
43+
Image {{`{{ $labels.image }}`}} from container {{`{{ $labels.container }}`}}
44+
in daemonSet {{`{{ $labels.daemonset }}`}}
45+
from namespace {{`{{ $labels.namespace }}`}}
46+
is not available in docker registry.
47+
labels:
48+
severity: critical
49+
- alert: CronJobImageUnavailable
50+
expr: |
51+
max by (namespace, cronjob, container, image) (
52+
k8s_image_availability_exporter_cronjob_available == 0
53+
)
54+
annotations:
55+
message: >
56+
Image {{`{{ $labels.image }}`}} from container {{`{{ $labels.container }}`}}
57+
in cronJob {{`{{ $labels.cronjob }}`}}
58+
from namespace {{`{{ $labels.namespace }}`}}
59+
is not available in docker registry.
60+
labels:
61+
severity: critical
62+
{{- end }}
63+
64+
{{- if .Values.prometheusRule.additionalGroups }}
65+
{{ .Values.prometheusRule.additionalGroups | toYaml | indent 2}}
66+
{{- end }}
67+
68+
{{- end }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- secrets
11+
verbs:
12+
- list
13+
- watch
14+
- get
15+
- apiGroups:
16+
- extensions
17+
- apps
18+
resources:
19+
- deployments
20+
- daemonsets
21+
- statefulsets
22+
verbs:
23+
- list
24+
- watch
25+
- get
26+
- apiGroups:
27+
- batch
28+
resources:
29+
- cronjobs
30+
verbs:
31+
- list
32+
- watch
33+
- get
34+
---
35+
apiVersion: rbac.authorization.k8s.io/v1
36+
kind: ClusterRoleBinding
37+
metadata:
38+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
39+
roleRef:
40+
apiGroup: rbac.authorization.k8s.io
41+
kind: ClusterRole
42+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
43+
subjects:
44+
- kind: ServiceAccount
45+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
46+
namespace: {{ .Release.Namespace }}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.serviceMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
6+
labels:
7+
app: {{ template "k8s-image-availability-exporter.fullname" . }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
app: {{ template "k8s-image-availability-exporter.fullname" . }}
12+
endpoints:
13+
- port: http
14+
interval: {{ .Values.serviceMonitor.interval }}
15+
{{- end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "k8s-image-availability-exporter.fullname" . }}
5+
labels:
6+
app: {{ template "k8s-image-availability-exporter.fullname" . }}
7+
spec:
8+
ports:
9+
- name: http
10+
port: 8080
11+
protocol: TCP
12+
targetPort: http
13+
selector:
14+
app: {{ template "k8s-image-availability-exporter.fullname" . }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
k8sImageAvailabilityExporter:
2+
image:
3+
repository: flant/k8s-image-availability-exporter
4+
tag: v0.1.13
5+
pullPolicy: IfNotPresent
6+
replicas: 1
7+
resources: {}
8+
9+
serviceMonitor:
10+
enabled: false
11+
interval: 15s
12+
13+
prometheusRule:
14+
enabled: false
15+
defaultGroupsEnabled: true
16+
additionalGroups: []

0 commit comments

Comments
 (0)