Skip to content

Commit 318ccbb

Browse files
feat(cf-common): add podMonitor tpl (#62)
1 parent 17a4526 commit 318ccbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+602
-285
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ $templateName := printf "cf-common-%s.podMonitor" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- include $templateName . -}}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: pod monitor error handler
3+
templates:
4+
- templates/podMonitor.yaml
5+
tests:
6+
- it: Test main service monitor with no endpoints
7+
values:
8+
- values.yaml
9+
set:
10+
podMonitor:
11+
main:
12+
podMetricsEndpoints: null
13+
asserts:
14+
- failedTemplate:
15+
errorMessage: "podMetricsEndpoints are required for podMonitor RELEASE-NAME-cf-common-test"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: pod monitor metadata
3+
templates:
4+
- templates/podMonitor.yaml
5+
tests:
6+
- it: Test pod monitor default metadata
7+
values:
8+
- values.yaml
9+
asserts:
10+
- hasDocuments:
11+
count: 1
12+
- isKind:
13+
of: PodMonitor
14+
- isNull:
15+
path: metadata.annotations
16+
- equal:
17+
path: metadata.labels
18+
value:
19+
app.kubernetes.io/instance: RELEASE-NAME
20+
app.kubernetes.io/managed-by: Helm
21+
app.kubernetes.io/name: cf-common-test
22+
helm.sh/chart: cf-common-test-0.0.0
23+
- equal:
24+
path: metadata.name
25+
value: RELEASE-NAME-cf-common-test
26+
27+
- it: Test pod monitor custom metadata
28+
values:
29+
- values.yaml
30+
set:
31+
podMonitor:
32+
main:
33+
labels:
34+
alice: bob
35+
annotations:
36+
foo: bar
37+
asserts:
38+
- hasDocuments:
39+
count: 1
40+
- isKind:
41+
of: PodMonitor
42+
- equal:
43+
path: metadata.annotations
44+
value:
45+
foo: bar
46+
- equal:
47+
path: metadata.labels
48+
value:
49+
app.kubernetes.io/instance: RELEASE-NAME
50+
app.kubernetes.io/managed-by: Helm
51+
app.kubernetes.io/name: cf-common-test
52+
helm.sh/chart: cf-common-test-0.0.0
53+
alice: bob
54+
55+
- it: Test main pod monitor with name override
56+
template: templates/podMonitor.yaml
57+
values:
58+
- values.yaml
59+
set:
60+
podMonitor:
61+
main:
62+
nameOverride: foobar
63+
asserts:
64+
- equal:
65+
path: metadata.name
66+
value: RELEASE-NAME-cf-common-test-foobar
67+
68+
- it: Test main pod monitor with full name override
69+
template: templates/podMonitor.yaml
70+
values:
71+
- values.yaml
72+
set:
73+
podMonitor:
74+
main:
75+
fullnameOverride: foobar
76+
asserts:
77+
- equal:
78+
path: metadata.name
79+
value: foobar
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/quintush/helm-unittest/master/schema/helm-testsuite.json
2+
suite: pod monitor spec
3+
templates:
4+
- templates/podMonitor.yaml
5+
values:
6+
- values.yaml
7+
tests:
8+
- it: Test main pod monitor selector
9+
template: templates/podMonitor.yaml
10+
asserts:
11+
- isNotEmpty:
12+
path: spec.selector.matchLabels
13+
- equal:
14+
path: spec.selector.matchLabels
15+
value:
16+
app.kubernetes.io/instance: RELEASE-NAME
17+
app.kubernetes.io/name: cf-common-test
18+
19+
- it: Test main pod monitor with selector override
20+
template: templates/podMonitor.yaml
21+
values:
22+
- values.yaml
23+
set:
24+
podMonitor:
25+
main:
26+
selector:
27+
matchLabels:
28+
alice: bob
29+
asserts:
30+
- isNotEmpty:
31+
path: spec.selector.matchLabels
32+
- equal:
33+
path: spec.selector.matchLabels
34+
value:
35+
alice: bob
36+
37+
- it: Test main pod monitor with namespace selector
38+
template: templates/podMonitor.yaml
39+
values:
40+
- values.yaml
41+
set:
42+
podMonitor:
43+
main:
44+
namespaceSelector:
45+
matchNames:
46+
- foobar
47+
asserts:
48+
- contains:
49+
path: spec.namespaceSelector.matchNames
50+
content:
51+
foobar
52+
53+
- it: Test main pod monitor endpoints
54+
template: templates/podMonitor.yaml
55+
values:
56+
- values.yaml
57+
asserts:
58+
- contains:
59+
path: spec.podMetricsEndpoints
60+
content:
61+
interval: 1m
62+
path: /metrics
63+
port: metrics
64+
scheme: http
65+
scrapeTimeout: 10s
66+
count: 1
67+
68+
- it: Test main pod monitor disabled
69+
template: templates/podMonitor.yaml
70+
set:
71+
podMonitor:
72+
main:
73+
enabled: false
74+
values:
75+
- values.yaml
76+
asserts:
77+
- hasDocuments:
78+
count: 0
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# mock deployment for service monitor
2+
controller:
3+
enabled: true
4+
type: deployment
5+
replicas: 2
6+
deployment:
7+
strategy: Recreate
8+
revisionHistoryLimit: 5
9+
10+
container:
11+
image:
12+
registry: docker.io
13+
repository: nginx
14+
tag: master
15+
pullPolicy: Always
16+
17+
service:
18+
main:
19+
enabled: true
20+
primary: true
21+
labels: {}
22+
annotations: {}
23+
type: ClusterIP
24+
ports:
25+
http:
26+
port: 8080
27+
protocol: HTTP
28+
metrics:
29+
enabled: true
30+
type: ClusterIP
31+
ports:
32+
metrics:
33+
port: 8082
34+
protocol: HTTP
35+
36+
podMonitor:
37+
main:
38+
enabled: true
39+
nameOverride: ""
40+
labels: {}
41+
annotations: {}
42+
selector: {}
43+
namespaceSelector: {}
44+
podMetricsEndpoints:
45+
- port: metrics
46+
scheme: http
47+
path: /metrics
48+
interval: 1m
49+
scrapeTimeout: 10s

charts/cf-common/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: v0.0.0
33
description: Codefresh library chart
44
name: cf-common
5-
version: 0.12.3
5+
version: 0.13.0
66
type: library
77
keywords:
88
- codefresh

charts/cf-common/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Codefresh library chart
44

5-
![Version: 0.12.3](https://img.shields.io/badge/Version-0.12.3-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
5+
![Version: 0.13.0](https://img.shields.io/badge/Version-0.13.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
66

77
## Installing the Chart
88

@@ -18,7 +18,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
1818
# Chart.yaml
1919
dependencies:
2020
- name: cf-common
21-
version: 0.12.3
21+
version: 0.13.0
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -144,6 +144,16 @@ dependencies:
144144
| persistence.data.storageClass | string | `nil` | Set Storage Class for PVC object If set to `-`, dynamic provisioning is disabled. If set to something else, the given storageClass is used. If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. |
145145
| podAnnotations | object | `{}` | Set additional pod annotations |
146146
| podLabels | object | `{}` | Set additional pod labels |
147+
| podMonitor | object | See below | Configure PodMonitors for the chart. Additional podMonitors can be added by adding a dictionary key similar to the 'main' service monitor. |
148+
| podMonitor.main | object | `{"annotations":{},"enabled":false,"fullNameOverride":"","labels":{},"nameOverride":"","namespaceSelector":{},"podMetricsEndpoints":[{"path":"/metrics","targetPort":9100}],"selector":{}}` | pod monitor name |
149+
| podMonitor.main.annotations | object | `{}` | Add additional annotations for the pod monitor |
150+
| podMonitor.main.enabled | bool | `false` | Enable pod monitor |
151+
| podMonitor.main.fullNameOverride | string | `""` | Override pod monitor full name |
152+
| podMonitor.main.labels | object | `{}` | Add additional labels for the pod monitor |
153+
| podMonitor.main.nameOverride | string | `""` | Override pod monitor name suffix |
154+
| podMonitor.main.namespaceSelector | object | `{}` | Set namespace selector. If nil, release namespace is used. |
155+
| podMonitor.main.podMetricsEndpoints | list | `[{"path":"/metrics","targetPort":9100}]` | Set endpoints for pod monitor |
156+
| podMonitor.main.selector | object | `{}` | Override the default selector for the podMonitor. Takes precedence over default labels. Helm template can be used. |
147157
| podSecurityContext | object | `{}` | Set security context for the pod |
148158
| rbac | object | See below | Configure RBAC parameters |
149159
| rbac.enabled | bool | `false` | Enable RBAC resources |

0 commit comments

Comments
 (0)