Skip to content

Commit

Permalink
Add kubectl.kubernetes.io/default-container annotation to grafana-age…
Browse files Browse the repository at this point in the history
…nt pod template (#6146)
  • Loading branch information
aerfio authored Jan 15, 2024
1 parent fb865f8 commit 93b628d
Show file tree
Hide file tree
Showing 33 changed files with 332 additions and 3 deletions.
4 changes: 4 additions & 0 deletions operations/helm/charts/grafana-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ internal API changes are not present.
Unreleased
----------

### Enhancments

- Add `kubectl.kubernetes.io/default-container: grafana-agent` annotation to allow various tools to choose `grafana-agent` container as default target (@aerfio)

0.31.0 (2024-01-10)
-------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Test correct rendering of the pod annotations
controller:
podAnnotations:
testAnnotationKey: testAnnotationValue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{{- define "grafana-agent.pod-template" -}}
metadata:
{{- with .Values.controller.podAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
kubectl.kubernetes.io/default-container: grafana-agent
{{- with .Values.controller.podAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "grafana-agent.selectorLabels" . | nindent 4 }}
{{- with .Values.controller.podLabels }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ spec:
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Source: grafana-agent/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-agent
labels:
helm.sh/chart: grafana-agent
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
app.kubernetes.io/version: "vX.Y.Z"
app.kubernetes.io/managed-by: Helm
data:
config.river: |-
logging {
level = "info"
format = "logfmt"
}
discovery.kubernetes "pods" {
role = "pod"
}
discovery.kubernetes "nodes" {
role = "node"
}
discovery.kubernetes "services" {
role = "service"
}
discovery.kubernetes "endpoints" {
role = "endpoints"
}
discovery.kubernetes "endpointslices" {
role = "endpointslice"
}
discovery.kubernetes "ingresses" {
role = "ingress"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
# Source: grafana-agent/templates/controllers/daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: grafana-agent
labels:
helm.sh/chart: grafana-agent
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
app.kubernetes.io/version: "vX.Y.Z"
app.kubernetes.io/managed-by: Helm
spec:
minReadySeconds: 10
selector:
matchLabels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: grafana-agent
testAnnotationKey: testAnnotationValue
labels:
app.kubernetes.io/name: grafana-agent
app.kubernetes.io/instance: grafana-agent
spec:
serviceAccountName: grafana-agent
containers:
- name: grafana-agent
image: docker.io/grafana/agent:v0.39.0
imagePullPolicy: IfNotPresent
args:
- run
- /etc/agent/config.river
- --storage.path=/tmp/agent
- --server.http.listen-addr=0.0.0.0:80
- --server.http.ui-path-prefix=/
env:
- name: AGENT_MODE
value: flow
- name: AGENT_DEPLOY_MODE
value: "helm"
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
ports:
- containerPort: 80
name: http-metrics
readinessProbe:
httpGet:
path: /-/ready
port: 80
initialDelaySeconds: 10
timeoutSeconds: 1
volumeMounts:
- name: config
mountPath: /etc/agent
- name: config-reloader
image: ghcr.io/jimmidyson/configmap-reload:v0.12.0
args:
- --volume-dir=/etc/agent
- --webhook-url=http://localhost:80/-/reload
volumeMounts:
- name: config
mountPath: /etc/agent
resources:
requests:
cpu: 1m
memory: 5Mi
dnsPolicy: ClusterFirst
volumes:
- name: config
configMap:
name: grafana-agent
Loading

0 comments on commit 93b628d

Please sign in to comment.