Skip to content

Commit b7b62f1

Browse files
committed
chore: add pprof server to operator and sidecar
We add the pprof server to the operator and the sidecar, to avoid any conflict with the CloudNativePG operator and clusters we use the port 6061 Closes #421 Signed-off-by: Jonathan Gonzalez V. <[email protected]>
1 parent a225902 commit b7b62f1

File tree

7 files changed

+18
-1
lines changed

7 files changed

+18
-1
lines changed

internal/cmd/instance/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func NewCmd() *cobra.Command {
4040
_ = viper.BindEnv("spool-directory", "SPOOL_DIRECTORY")
4141
_ = viper.BindEnv("custom-cnpg-group", "CUSTOM_CNPG_GROUP")
4242
_ = viper.BindEnv("custom-cnpg-version", "CUSTOM_CNPG_VERSIONXS")
43+
_ = viper.BindEnv("pprof-server", "PLUGIN_PPROF_SERVER")
4344

4445
return cmd
4546
}

internal/cmd/operator/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,7 @@ func NewCmd() *cobra.Command {
8484

8585
_ = viper.BindEnv("sidecar-image", "SIDECAR_IMAGE")
8686

87+
_ = viper.BindEnv("pprof-server", "PPROF_SERVER")
88+
8789
return cmd
8890
}

internal/cnpgi/instance/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func Start(ctx context.Context) error {
4444
},
4545
},
4646
},
47+
PprofBindAddress: viper.GetString("pprof-server"),
4748
}
4849

4950
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), controllerOptions)

internal/cnpgi/operator/lifecycle.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,13 @@ func reconcilePodSpec(
332332
}
333333
sidecarTemplate.RestartPolicy = ptr.To(corev1.ContainerRestartPolicyAlways)
334334
sidecarTemplate.Resources = config.resources
335-
335+
sidecarTemplate.Ports = []corev1.ContainerPort{
336+
{
337+
Name: "pprof",
338+
ContainerPort: 6061,
339+
Protocol: corev1.ProtocolTCP,
340+
},
341+
}
336342
// merge the main container envs if they aren't already set
337343
for _, container := range spec.Containers {
338344
if container.Name == mainContainerName {

internal/cnpgi/operator/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func Start(ctx context.Context) error {
104104
Metrics: metricsServerOptions,
105105
WebhookServer: webhookServer,
106106
HealthProbeBindAddress: viper.GetString("health-probe-bind-address"),
107+
PprofBindAddress: viper.GetString("pprof-server"),
107108
LeaderElection: viper.GetBool("leader-elect"),
108109
LeaderElectionID: "822e3f5c.cnpg.io",
109110
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily

kubernetes/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ spec:
2727
ports:
2828
- containerPort: 9090
2929
protocol: TCP
30+
- containerPort: 6060
31+
protocol: TCP
32+
name: "pprof"
3033
env:
3134
- name: SIDECAR_IMAGE
3235
valueFrom:

manifest.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,9 @@ spec:
932932
ports:
933933
- containerPort: 9090
934934
protocol: TCP
935+
- containerPort: 6060
936+
name: pprof
937+
protocol: TCP
935938
readinessProbe:
936939
initialDelaySeconds: 10
937940
periodSeconds: 10

0 commit comments

Comments
 (0)