Skip to content

Commit eec0ac5

Browse files
evkuzinpetewall
andauthored
allow to define extra labels for alloy controller (#3833)
* allow to define extra labels for alloy controller * fix * address comments * Update operations/helm/charts/alloy/README.md Co-authored-by: Pete Wall <[email protected]> * Update operations/helm/charts/alloy/templates/controllers/statefulset.yaml Co-authored-by: Pete Wall <[email protected]> * Update README.md * add tests --------- Co-authored-by: Pete Wall <[email protected]>
1 parent 8090b5c commit eec0ac5

File tree

12 files changed

+299
-0
lines changed

12 files changed

+299
-0
lines changed

operations/helm/charts/alloy/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ internal API changes are not present.
1010
Unreleased
1111
----------
1212

13+
- Add support to provide extraLabels to alloy.controler (@evkuzin)
14+
1315
### Enhancements
1416

1517
- Add support for configuring initialDelaySeconds and timeoutSeconds in Helm chart for readiness probe. (@peter-meltcafe)

operations/helm/charts/alloy/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ useful if just using the default DaemonSet isn't sufficient.
107107
| controller.enableStatefulSetAutoDeletePVC | bool | `false` | Whether to enable automatic deletion of stale PVCs due to a scale down operation, when controller.type is 'statefulset'. |
108108
| controller.extraAnnotations | object | `{}` | Annotations to add to controller. |
109109
| controller.extraContainers | list | `[]` | Additional containers to run alongside the Alloy container and initContainers. |
110+
| controller.extraLabels | object | `{}` | Extra labels to add to the controller. |
110111
| controller.hostNetwork | bool | `false` | Configures Pods to use the host network. When set to true, the ports that will be used must be specified. |
111112
| controller.hostPID | bool | `false` | Configures Pods to use the host PID namespace. |
112113
| controller.initContainers | list | `[]` | |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
controller:
2+
extraLabels:
3+
custom: "true"

operations/helm/charts/alloy/templates/controllers/daemonset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ metadata:
66
namespace: {{ include "alloy.namespace" . }}
77
labels:
88
{{- include "alloy.labels" . | nindent 4 }}
9+
{{- with .Values.controller.extraLabels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
912
{{- with .Values.controller.extraAnnotations }}
1013
annotations:
1114
{{- toYaml . | nindent 4 }}

operations/helm/charts/alloy/templates/controllers/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ metadata:
66
namespace: {{ include "alloy.namespace" . }}
77
labels:
88
{{- include "alloy.labels" . | nindent 4 }}
9+
{{- with .Values.controller.extraLabels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
912
{{- with .Values.controller.extraAnnotations }}
1013
annotations:
1114
{{- toYaml . | nindent 4 }}

operations/helm/charts/alloy/templates/controllers/statefulset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ metadata:
99
namespace: {{ include "alloy.namespace" . }}
1010
labels:
1111
{{- include "alloy.labels" . | nindent 4 }}
12+
{{- with .Values.controller.extraLabels }}
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
1215
{{- with .Values.controller.extraAnnotations }}
1316
annotations:
1417
{{- toYaml . | nindent 4 }}

operations/helm/charts/alloy/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ controller:
195195
# -- Number of pods to deploy. Ignored when controller.type is 'daemonset'.
196196
replicas: 1
197197

198+
# -- Extra labels to add to the controller.
199+
extraLabels: {}
200+
198201
# -- Annotations to add to controller.
199202
extraAnnotations: {}
200203

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# Source: alloy/templates/configmap.yaml
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: alloy
7+
namespace: default
8+
labels:
9+
helm.sh/chart: alloy
10+
app.kubernetes.io/name: alloy
11+
app.kubernetes.io/instance: alloy
12+
app.kubernetes.io/version: "vX.Y.Z"
13+
app.kubernetes.io/managed-by: Helm
14+
app.kubernetes.io/component: config
15+
data:
16+
config.alloy: |-
17+
logging {
18+
level = "info"
19+
format = "logfmt"
20+
}
21+
22+
discovery.kubernetes "pods" {
23+
role = "pod"
24+
}
25+
26+
discovery.kubernetes "nodes" {
27+
role = "node"
28+
}
29+
30+
discovery.kubernetes "services" {
31+
role = "service"
32+
}
33+
34+
discovery.kubernetes "endpoints" {
35+
role = "endpoints"
36+
}
37+
38+
discovery.kubernetes "endpointslices" {
39+
role = "endpointslice"
40+
}
41+
42+
discovery.kubernetes "ingresses" {
43+
role = "ingress"
44+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
# Source: alloy/templates/controllers/daemonset.yaml
3+
apiVersion: apps/v1
4+
kind: DaemonSet
5+
metadata:
6+
name: alloy
7+
namespace: default
8+
labels:
9+
helm.sh/chart: alloy
10+
app.kubernetes.io/name: alloy
11+
app.kubernetes.io/instance: alloy
12+
app.kubernetes.io/version: "vX.Y.Z"
13+
app.kubernetes.io/managed-by: Helm
14+
custom: "true"
15+
spec:
16+
minReadySeconds: 10
17+
selector:
18+
matchLabels:
19+
app.kubernetes.io/name: alloy
20+
app.kubernetes.io/instance: alloy
21+
template:
22+
metadata:
23+
annotations:
24+
kubectl.kubernetes.io/default-container: alloy
25+
labels:
26+
app.kubernetes.io/name: alloy
27+
app.kubernetes.io/instance: alloy
28+
spec:
29+
serviceAccountName: alloy
30+
containers:
31+
- name: alloy
32+
image: docker.io/grafana/alloy:v1.10.0
33+
imagePullPolicy: IfNotPresent
34+
args:
35+
- run
36+
- /etc/alloy/config.alloy
37+
- --storage.path=/tmp/alloy
38+
- --server.http.listen-addr=0.0.0.0:12345
39+
- --server.http.ui-path-prefix=/
40+
- --stability.level=generally-available
41+
env:
42+
- name: ALLOY_DEPLOY_MODE
43+
value: "helm"
44+
- name: HOSTNAME
45+
valueFrom:
46+
fieldRef:
47+
fieldPath: spec.nodeName
48+
ports:
49+
- containerPort: 12345
50+
name: http-metrics
51+
readinessProbe:
52+
httpGet:
53+
path: /-/ready
54+
port: 12345
55+
scheme: HTTP
56+
initialDelaySeconds: 10
57+
timeoutSeconds: 1
58+
volumeMounts:
59+
- name: config
60+
mountPath: /etc/alloy
61+
- name: config-reloader
62+
image: quay.io/prometheus-operator/prometheus-config-reloader:v0.81.0
63+
args:
64+
- --watched-dir=/etc/alloy
65+
- --reload-url=http://localhost:12345/-/reload
66+
volumeMounts:
67+
- name: config
68+
mountPath: /etc/alloy
69+
resources:
70+
requests:
71+
cpu: 10m
72+
memory: 50Mi
73+
dnsPolicy: ClusterFirst
74+
volumes:
75+
- name: config
76+
configMap:
77+
name: alloy
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
# Source: alloy/templates/rbac.yaml
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: ClusterRole
5+
metadata:
6+
name: alloy
7+
labels:
8+
helm.sh/chart: alloy
9+
app.kubernetes.io/name: alloy
10+
app.kubernetes.io/instance: alloy
11+
app.kubernetes.io/version: "vX.Y.Z"
12+
app.kubernetes.io/managed-by: Helm
13+
app.kubernetes.io/component: rbac
14+
rules:
15+
# Rules which allow discovery.kubernetes to function.
16+
- apiGroups:
17+
- ""
18+
- "discovery.k8s.io"
19+
- "networking.k8s.io"
20+
resources:
21+
- endpoints
22+
- endpointslices
23+
- ingresses
24+
- nodes
25+
- nodes/proxy
26+
- nodes/metrics
27+
- pods
28+
- services
29+
verbs:
30+
- get
31+
- list
32+
- watch
33+
# Rules which allow loki.source.kubernetes and loki.source.podlogs to work.
34+
- apiGroups:
35+
- ""
36+
resources:
37+
- pods
38+
- pods/log
39+
- namespaces
40+
verbs:
41+
- get
42+
- list
43+
- watch
44+
- apiGroups:
45+
- "monitoring.grafana.com"
46+
resources:
47+
- podlogs
48+
verbs:
49+
- get
50+
- list
51+
- watch
52+
# Rules which allow mimir.rules.kubernetes to work.
53+
- apiGroups: ["monitoring.coreos.com"]
54+
resources:
55+
- prometheusrules
56+
verbs:
57+
- get
58+
- list
59+
- watch
60+
- nonResourceURLs:
61+
- /metrics
62+
verbs:
63+
- get
64+
# Rules for prometheus.kubernetes.*
65+
- apiGroups: ["monitoring.coreos.com"]
66+
resources:
67+
- podmonitors
68+
- servicemonitors
69+
- probes
70+
- scrapeconfigs
71+
verbs:
72+
- get
73+
- list
74+
- watch
75+
# Rules which allow eventhandler to work.
76+
- apiGroups:
77+
- ""
78+
resources:
79+
- events
80+
verbs:
81+
- get
82+
- list
83+
- watch
84+
# needed for remote.kubernetes.*
85+
- apiGroups: [""]
86+
resources:
87+
- "configmaps"
88+
- "secrets"
89+
verbs:
90+
- get
91+
- list
92+
- watch
93+
# needed for otelcol.processor.k8sattributes
94+
- apiGroups: ["apps"]
95+
resources: ["replicasets"]
96+
verbs: ["get", "list", "watch"]
97+
- apiGroups: ["extensions"]
98+
resources: ["replicasets"]
99+
verbs: ["get", "list", "watch"]
100+
---
101+
# Source: alloy/templates/rbac.yaml
102+
apiVersion: rbac.authorization.k8s.io/v1
103+
kind: ClusterRoleBinding
104+
metadata:
105+
name: alloy
106+
labels:
107+
helm.sh/chart: alloy
108+
app.kubernetes.io/name: alloy
109+
app.kubernetes.io/instance: alloy
110+
app.kubernetes.io/version: "vX.Y.Z"
111+
app.kubernetes.io/managed-by: Helm
112+
app.kubernetes.io/component: rbac
113+
roleRef:
114+
apiGroup: rbac.authorization.k8s.io
115+
kind: ClusterRole
116+
name: alloy
117+
subjects:
118+
- kind: ServiceAccount
119+
name: alloy
120+
namespace: default

0 commit comments

Comments
 (0)