Skip to content

Commit 761001c

Browse files
authored
allow specyfing pod labels and annotations (#12)
Signed-off-by: Jonasz Łasut-Balcerzak <jonasz.lasut@gmail.com>
1 parent a5f6c88 commit 761001c

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

apis/resourcestatemetrics/definition.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ spec:
3939
or a specific version tag.
4040
type: string
4141
type: object
42+
podMetadata:
43+
description: "Pod's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
44+
properties:
45+
labels:
46+
description: "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels"
47+
additionalProperties:
48+
x-kubernetes-preserve-unknown-fields: true
49+
type: object
50+
annotations:
51+
description: "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations"
52+
additionalProperties:
53+
x-kubernetes-preserve-unknown-fields: true
54+
type: object
55+
type: object
4256
replicas:
4357
description: Number of controller replicas to run. Defaults to 1 for
4458
high availability consider 2 or more.

examples/xr-rsm.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ spec:
1717
image:
1818
repository: xpkg.crossplane.io/crossplane-contrib/resource-state-metrics-server
1919
tag: v0.3.0
20+
podMetadata:
21+
labels:
22+
example-label: example-label-value
23+
annotations:
24+
example-annotation: example-annotation-value
2025
resources:
2126
limits:
2227
cpu: 200m

functions/rsm/05-deployment.yaml.gotmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@ spec:
2020
app.kubernetes.io/name: resource-state-metrics
2121
template:
2222
metadata:
23+
{{- with $xr.spec.parameters.deployment.podMetadata.annotations }}
24+
annotations:
25+
{{- range $k, $v := . }}
26+
{{ $k }}: {{ $v }}
27+
{{- end }}
28+
{{- end }}
2329
labels:
2430
app.kubernetes.io/component: exporter
2531
app.kubernetes.io/name: resource-state-metrics
2632
app.kubernetes.io/version: 0.0.1
33+
{{- range $k, $v := $xr.spec.parameters.deployment.podMetadata.labels }}
34+
{{ $k }}: {{ $v }}
35+
{{- end }}
2736
spec:
2837
automountServiceAccountToken: true
2938
serviceAccountName: resource-state-metrics

tests/test-rsm/test.yaml.gotmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,13 @@ items:
548548
app.kubernetes.io/name: resource-state-metrics
549549
template:
550550
metadata:
551+
annotations:
552+
example-annotation: example-annotation-value
551553
labels:
552554
app.kubernetes.io/component: exporter
553555
app.kubernetes.io/name: resource-state-metrics
554556
app.kubernetes.io/version: "0.0.1"
557+
example-label: example-label-value
555558
spec:
556559
automountServiceAccountToken: true
557560
containers:

0 commit comments

Comments
 (0)