Skip to content

Commit c9e0a3a

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 c9e0a3a

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-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/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 {

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)