-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add autoscaling for deployment to helm chart (#3221)
- Loading branch information
1 parent
e53732d
commit 6a2997d
Showing
13 changed files
with
360 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{{- if and (eq .Values.controller.type "deployment") .Values.controller.autoscaling.enabled }} | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ include "grafana-agent.fullname" . }} | ||
labels: | ||
{{- include "grafana-agent.labels" . | nindent 4 }} | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ include "grafana-agent.fullname" . }} | ||
{{- with .Values.controller.autoscaling }} | ||
minReplicas: {{ .minReplicas }} | ||
maxReplicas: {{ .maxReplicas }} | ||
metrics: | ||
{{- with .targetCPUUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ . }} | ||
{{- end }} | ||
{{- with .targetMemoryUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
5 changes: 5 additions & 0 deletions
5
operations/helm/charts/grafana-agent/tests/create-deployment-autoscaling.values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Test rendering of the chart with the controller explicitly set to Deployment and autoscaling enabled. | ||
controller: | ||
type: deployment | ||
autoscaling: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
68 changes: 68 additions & 0 deletions
68
...m/tests/create-deployment-autoscaling/grafana-agent/templates/controllers/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
# Source: grafana-agent/templates/controllers/deployment.yaml | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
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: | ||
replicas: 1 | ||
minReadySeconds: 10 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: grafana-agent | ||
app.kubernetes.io/instance: grafana-agent | ||
spec: | ||
serviceAccount: grafana-agent | ||
containers: | ||
- name: grafana-agent | ||
image: grafana/agent:v0.32.1 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- run | ||
- /etc/agent/config.river | ||
- --storage.path=/tmp/agent | ||
- --server.http.listen-addr=0.0.0.0:80 | ||
env: | ||
- name: AGENT_MODE | ||
value: flow | ||
- name: HOSTNAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
ports: | ||
- containerPort: 80 | ||
name: http-metrics | ||
- containerPort: 12347 | ||
name: faro | ||
readinessProbe: | ||
httpGet: | ||
path: /-/ready | ||
port: 80 | ||
initialDelaySeconds: 10 | ||
timeoutSeconds: 1 | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/agent | ||
- name: config-reloader | ||
image: jimmidyson/configmap-reload:v0.8.0 | ||
args: | ||
- --volume-dir=/etc/agent | ||
- --webhook-url=http://localhost:80/-/reload | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/agent | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: grafana-agent |
26 changes: 26 additions & 0 deletions
26
operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/hpa.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
# Source: grafana-agent/templates/hpa.yaml | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
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: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: grafana-agent | ||
minReplicas: 1 | ||
maxReplicas: 5 | ||
metrics: | ||
- type: Resource | ||
resource: | ||
name: memory | ||
target: | ||
type: Utilization | ||
averageUtilization: 80 |
100 changes: 100 additions & 0 deletions
100
operations/helm/tests/create-deployment-autoscaling/grafana-agent/templates/rbac.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
# Source: grafana-agent/templates/rbac.yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
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 | ||
rules: | ||
# Rules which allow discovery.kubernetes to function. | ||
- apiGroups: | ||
- "" | ||
- "discovery.k8s.io" | ||
- "networking.k8s.io" | ||
resources: | ||
- endpoints | ||
- endpointslices | ||
- ingresses | ||
- nodes | ||
- nodes/proxy | ||
- pods | ||
- services | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow loki.source.kubernetes and loki.source.podlogs to work. | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- pods/log | ||
- namespaces | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "monitoring.grafana.com" | ||
resources: | ||
- podlogs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow mimir.rules.kubernetes to work. | ||
- apiGroups: ["monitoring.coreos.com"] | ||
resources: | ||
- prometheusrules | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- nonResourceURLs: | ||
- /metrics | ||
verbs: | ||
- get | ||
# Rules for prometheus.kubernetes.* | ||
- apiGroups: ["monitoring.coreos.com"] | ||
resources: | ||
- podmonitors | ||
- servicemonitors | ||
- probes | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
# Rules which allow eventhandler to work. | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
--- | ||
# Source: grafana-agent/templates/rbac.yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
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 | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: grafana-agent | ||
subjects: | ||
- kind: ServiceAccount | ||
name: grafana-agent | ||
namespace: default |
Oops, something went wrong.