Skip to content

Commit e03426a

Browse files
authored
Merge pull request #1632 from grafana/feat/pprof-endpoint
feat: enable pprof endpoint
2 parents e11fbbd + 8c636f5 commit e03426a

File tree

10 files changed

+36
-4
lines changed

10 files changed

+36
-4
lines changed

bundle/manifests/grafana-operator-operator-metrics-service_v1_service.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ metadata:
88
name: grafana-operator-operator-metrics-service
99
spec:
1010
ports:
11-
- name: metrics
12-
port: 8443
13-
protocol: TCP
14-
targetPort: metrics
11+
- name: metrics
12+
port: 8443
13+
protocol: TCP
14+
targetPort: metrics
15+
- port: 8888
16+
targetPort: pprof
17+
protocol: TCP
18+
name: pprof
1519
selector:
1620
app.kubernetes.io/managed-by: olm
1721
app.kubernetes.io/name: grafana-operator

config/default/metrics_service.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ spec:
1212
port: 8443
1313
protocol: TCP
1414
targetPort: metrics
15+
- port: 8888
16+
targetPort: pprof
17+
protocol: TCP
18+
name: pprof
1519
selector:
1620
app.kubernetes.io/name: grafana-operator
1721
app.kubernetes.io/managed-by: olm

config/manager/manager.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ spec:
4242
- containerPort: 9090
4343
protocol: TCP
4444
name: metrics
45+
- containerPort: 8888
46+
name: pprof
47+
protocol: TCP
4548
livenessProbe:
4649
httpGet:
4750
path: /healthz

deploy/helm/grafana-operator/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ It's easier to just manage this configuration outside of the operator.
7474
| isOpenShift | bool | `false` | Determines if the target cluster is OpenShift. Additional rbac permissions for routes will be added on OpenShift |
7575
| leaderElect | bool | `false` | If you want to run multiple replicas of the grafana-operator, this is not recommended. |
7676
| metricsService.metricsPort | int | `9090` | metrics service port |
77+
| metricsService.pprofPort | int | `8888` | port for the pprof profiling endpoint |
7778
| metricsService.type | string | `"ClusterIP"` | metrics service type |
7879
| nameOverride | string | `""` | Overrides the name of the chart. |
7980
| namespaceOverride | string | `""` | Overrides the namespace name. |

deploy/helm/grafana-operator/templates/deployment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ spec:
5757
args:
5858
- --health-probe-bind-address=:8081
5959
- --metrics-bind-address=0.0.0.0:{{ .Values.metricsService.metricsPort }}
60+
- --pprof-addr=0.0.0.0:{{ .Values.metricsService.pprofPort }}
6061
{{- if .Values.leaderElect }}
6162
- --leader-elect
6263
{{- end }}
@@ -67,6 +68,9 @@ spec:
6768
- containerPort: {{ .Values.metricsService.metricsPort }}
6869
name: metrics
6970
protocol: TCP
71+
- containerPort: {{ .Values.metricsService.pprofPort }}
72+
name: pprof
73+
protocol: TCP
7074
livenessProbe:
7175
httpGet:
7276
path: /healthz

deploy/helm/grafana-operator/templates/service.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ spec:
1313
targetPort: metrics
1414
protocol: TCP
1515
name: metrics
16+
- port: {{ .Values.metricsService.pprofPort }}
17+
targetPort: pprof
18+
protocol: TCP
19+
name: pprof
1620
selector:
1721
{{- include "grafana-operator.selectorLabels" . | nindent 4 }}

deploy/helm/grafana-operator/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ metricsService:
6060
type: ClusterIP
6161
# -- metrics service port
6262
metricsPort: 9090
63+
# -- port for the pprof profiling endpoint
64+
pprofPort: 8888
6365

6466
# -- additional labels to add to all resources
6567
additionalLabels: {}

deploy/kustomize/base/deployment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ spec:
2828
- containerPort: 9090
2929
name: metrics
3030
protocol: TCP
31+
- containerPort: 8888
32+
name: pprof
33+
protocol: TCP
3134
livenessProbe:
3235
httpGet:
3336
path: /healthz

deploy/kustomize/base/service.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ spec:
1111
targetPort: metrics
1212
protocol: TCP
1313
name: metrics
14+
- port: 8888
15+
targetPort: pprof
16+
protocol: TCP
17+
name: pprof
1418
selector:
1519
app.kubernetes.io/name: grafana-operator

main.go

+3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ func main() {
8282
var metricsAddr string
8383
var enableLeaderElection bool
8484
var probeAddr string
85+
var pprofAddr string
8586
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
8687
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
8788
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
8889
"Enable leader election for controller manager. "+
8990
"Enabling this will ensure there is only one active controller manager.")
91+
flag.StringVar(&pprofAddr, "pprof-addr", ":8888", "The address to expose the pprof server. Empty string disables the pprof server.")
9092
opts := zap.Options{
9193
Development: true,
9294
}
@@ -109,6 +111,7 @@ func main() {
109111
HealthProbeBindAddress: probeAddr,
110112
LeaderElection: enableLeaderElection,
111113
LeaderElectionID: "f75f3bba.integreatly.org",
114+
PprofBindAddress: pprofAddr,
112115
}
113116

114117
getNamespaceConfig := func(namespaces string) map[string]cache.Config {

0 commit comments

Comments
 (0)