Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions api/v1beta1/temporalcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ type ServiceSpec struct {
// 7243 for Frontend service
// +optional
HTTPPort *int `json:"httpPort"`
// PProfPort defines a custom pprof port for the service.
// The port is defined by the global config.
// +optional
PProfPort *int `json:"pprofPort,omitempty"`
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this field is useless. If spec.pprof != nil the container will expose spec.pprof.port.

// Number of desired replicas for the service. Default to 1.
// +kubebuilder:validation:Minimum=1
// +optional
Expand Down Expand Up @@ -787,6 +791,15 @@ func (m *MetricsSpec) IsEnabled() bool {
return m != nil && m.Enabled
}

// PProfSpec determines parameters for configuring pprof.
type PProfSpec struct {
// Specifies the port that pprof's web server should run on. This must be specified to enable pprof.
Port int `json:"port"`
// Specifies the host that pprof's web server should run on. Defaults to "localhost" if not provided.
// +optional
Host *string `json:"host,omitempty"`
}

// Constraints is an alias for temporal's dynamicconfig.Constraints.
// It describes under what conditions a ConstrainedValue should be used.
type Constraints struct {
Expand Down Expand Up @@ -1041,6 +1054,9 @@ type TemporalClusterSpec struct {
// Metrics allows configuration of scraping endpoints for stats. prometheus or m3.
// +optional
Metrics *MetricsSpec `json:"metrics,omitempty"`
// PProf allows configuration of pprof.
// +optional
PProf *PProfSpec `json:"pprof,omitempty"`
// DynamicConfig allows advanced configuration for the temporal cluster.
// +optional
DynamicConfig *DynamicConfigSpec `json:"dynamicConfig,omitempty"`
Expand Down
30 changes: 30 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions config/crd/bases/temporal.io_temporalclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,18 @@ spec:
- defaultStore
- visibilityStore
type: object
pprof:
description: PProf allows configuration of pprof.
properties:
host:
description: Specifies the host that pprof's web server should run on. Defaults to "localhost" if not provided.
type: string
port:
description: Specifies the port that pprof's web server should run on. This must be specified to enable pprof.
type: integer
required:
- port
type: object
services:
description: Services allows customizations for each temporal services deployment.
properties:
Expand Down Expand Up @@ -2158,6 +2170,9 @@ spec:
port:
description: 'Port defines a custom gRPC port for the service. Default values are: 7233 for Frontend service 7234 for History service 7235 for Matching service 7239 for Worker service'
type: integer
pprofPort:
description: PProfPort defines a custom pprof port for the service. The port is defined by the global config.
type: integer
replicas:
description: Number of desired replicas for the service. Default to 1.
format: int32
Expand Down Expand Up @@ -2268,6 +2283,9 @@ spec:
port:
description: 'Port defines a custom gRPC port for the service. Default values are: 7233 for Frontend service 7234 for History service 7235 for Matching service 7239 for Worker service'
type: integer
pprofPort:
description: PProfPort defines a custom pprof port for the service. The port is defined by the global config.
type: integer
replicas:
description: Number of desired replicas for the service. Default to 1.
format: int32
Expand Down Expand Up @@ -2382,6 +2400,9 @@ spec:
port:
description: 'Port defines a custom gRPC port for the service. Default values are: 7233 for Frontend service 7234 for History service 7235 for Matching service 7239 for Worker service'
type: integer
pprofPort:
description: PProfPort defines a custom pprof port for the service. The port is defined by the global config.
type: integer
replicas:
description: Number of desired replicas for the service. Default to 1.
format: int32
Expand Down Expand Up @@ -2492,6 +2513,9 @@ spec:
port:
description: 'Port defines a custom gRPC port for the service. Default values are: 7233 for Frontend service 7234 for History service 7235 for Matching service 7239 for Worker service'
type: integer
pprofPort:
description: PProfPort defines a custom pprof port for the service. The port is defined by the global config.
type: integer
replicas:
description: Number of desired replicas for the service. Default to 1.
format: int32
Expand Down Expand Up @@ -2650,6 +2674,9 @@ spec:
port:
description: 'Port defines a custom gRPC port for the service. Default values are: 7233 for Frontend service 7234 for History service 7235 for Matching service 7239 for Worker service'
type: integer
pprofPort:
description: PProfPort defines a custom pprof port for the service. The port is defined by the global config.
type: integer
replicas:
description: Number of desired replicas for the service. Default to 1.
format: int32
Expand Down
85 changes: 85 additions & 0 deletions docs/api/v1beta1.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,20 @@ MetricsSpec
</tr>
<tr>
<td>
<code>pprof</code><br>
<em>
<a href="#temporal.io/v1beta1.PProfSpec">
PProfSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>PProf allows configuration of pprof.</p>
</td>
</tr>
<tr>
<td>
<code>dynamicConfig</code><br>
<em>
<a href="#temporal.io/v1beta1.DynamicConfigSpec">
Expand Down Expand Up @@ -2199,6 +2213,50 @@ set by external tools to store and retrieve arbitrary metadata.</p>
</table>
</div>
</div>
<h3 id="temporal.io/v1beta1.PProfSpec">PProfSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#temporal.io/v1beta1.TemporalClusterSpec">TemporalClusterSpec</a>)
</p>
<p>PProfSpec determines parameters for configuring pprof.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>port</code><br>
<em>
int
</em>
</td>
<td>
<p>Specifies the port that pprof&rsquo;s web server should run on. This must be specified to enable pprof.</p>
</td>
</tr>
<tr>
<td>
<code>host</code><br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Specifies the host that pprof&rsquo;s web server should run on. Defaults to &ldquo;localhost&rdquo; if not provided.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="temporal.io/v1beta1.PodTemplateSpecOverride">PodTemplateSpecOverride
</h3>
<p>
Expand Down Expand Up @@ -2824,6 +2882,19 @@ Default values are:
</tr>
<tr>
<td>
<code>pprofPort</code><br>
<em>
int
</em>
</td>
<td>
<em>(Optional)</em>
<p>PProfPort defines a custom pprof port for the service.
The port is defined by the global config.</p>
</td>
</tr>
<tr>
<td>
<code>replicas</code><br>
<em>
int32
Expand Down Expand Up @@ -3560,6 +3631,20 @@ MetricsSpec
</tr>
<tr>
<td>
<code>pprof</code><br>
<em>
<a href="#temporal.io/v1beta1.PProfSpec">
PProfSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>PProf allows configuration of pprof.</p>
</td>
</tr>
<tr>
<td>
<code>dynamicConfig</code><br>
<em>
<a href="#temporal.io/v1beta1.DynamicConfigSpec">
Expand Down
10 changes: 10 additions & 0 deletions internal/resource/base/deployment_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ func (b *DeploymentBuilder) Update(object client.Object) error {
}
}

if b.instance.Spec.PProf != nil && b.instance.Spec.PProf.Port > 0 {
b.service.PProfPort = &b.instance.Spec.PProf.Port
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To follow my comment on the spec, you can remove this assignment.


containerPorts = append(containerPorts, corev1.ContainerPort{
Name: "pprof",
ContainerPort: int32(*b.service.PProfPort),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ContainerPort: int32(*b.service.PProfPort),
ContainerPort: int32(b.instance.Spec.PProf.Port),

Protocol: corev1.ProtocolTCP,
})
}

if b.serviceName == string(primitives.FrontendService) && b.instance.Spec.Services.Frontend.HTTPPort != nil {
containerPorts = append(containerPorts, corev1.ContainerPort{
Name: "http",
Expand Down
18 changes: 18 additions & 0 deletions internal/resource/config/configmap_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,24 @@ func (b *ConfigmapBuilder) Update(object client.Object) error {
}
}

if b.instance.Spec.PProf != nil {
var pprofConfig = config.PProf{}

// Host is optional.
if b.instance.Spec.PProf.Host != nil {
if *b.instance.Spec.PProf.Host != "" {
pprofConfig.Host = *b.instance.Spec.PProf.Host
}
}

// Port is required.
// Do not set a pprof config if the port is 0.
if b.instance.Spec.PProf.Port > 0 {
pprofConfig.Port = b.instance.Spec.PProf.Port
temporalCfg.Global.PProf = pprofConfig
}
}

if b.instance.MTLSWithCertManagerEnabled() {
temporalCfg.Global.TLS = config.RootTLS{
RefreshInterval: b.instance.Spec.MTLS.RefreshInterval.Duration,
Expand Down