Skip to content

Commit 50cf962

Browse files
authored
[POA-3567] Add rate-limit flag to kube run command (#116)
I started by adding all of the common apidump flags to the `kube run` command, but then decided against it. I'm not sure if it makes sense to set `Interfaces`, `HostAllowlist`, etc. at the daemonset level. So for now I am just adding the `rate-limit` flag.
1 parent 879c07b commit 50cf962

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

cmd/internal/kube/daemonset/daemonset.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ const (
2828

2929
type DaemonsetArgs struct {
3030
ReproMode bool
31+
RateLimit float64
3132
}
3233

3334
type Daemonset struct {
3435
ClusterName string
3536
InsightsEnvironment string
3637
InsightsReproModeEnabled bool
38+
InsightsRateLimit float64
3739

3840
KubeClient kube_apis.KubeClient
3941
CRIClient *cri_apis.CriClient
@@ -103,6 +105,7 @@ func StartDaemonset(args DaemonsetArgs) error {
103105
ClusterName: clusterName,
104106
InsightsEnvironment: os.Getenv(POSTMAN_INSIGHTS_ENV),
105107
InsightsReproModeEnabled: args.ReproMode,
108+
InsightsRateLimit: args.RateLimit,
106109
KubeClient: kubeClient,
107110
CRIClient: criClient,
108111
FrontClient: frontClient,

cmd/internal/kube/daemonset/kube_events_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (d *Daemonset) inspectPodForEnvVars(pod coreV1.Pod, podArgs *PodArgs) error
277277
// Check if ReproMode is explicitly disabled at the pod level
278278
podArgs.ReproMode = !parseBoolConfig(mainContainerConfig.disableReproMode, "disableReproMode", pod.Name, !d.InsightsReproModeEnabled)
279279

280-
podArgs.AgentRateLimit = 0.0
280+
podArgs.AgentRateLimit = d.InsightsRateLimit
281281
if mainContainerConfig.agentRateLimit != "" {
282282
if limit, err := strconv.ParseFloat(mainContainerConfig.agentRateLimit, 64); err == nil {
283283
podArgs.AgentRateLimit = limit

cmd/internal/kube/run.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ import (
88

99
var (
1010
reproMode bool
11+
rateLimit float64
1112
)
1213

1314
func StartDaemonsetAndHibernateOnError(_ *cobra.Command, args []string) error {
14-
err := daemonset.StartDaemonset(daemonset.DaemonsetArgs{ReproMode: reproMode})
15+
err := daemonset.StartDaemonset(daemonset.DaemonsetArgs{
16+
ReproMode: reproMode,
17+
RateLimit: rateLimit,
18+
})
1519
if err == nil {
1620
return nil
1721
}
@@ -31,6 +35,12 @@ var runCmd = &cobra.Command{
3135
}
3236

3337
func init() {
38+
runCmd.PersistentFlags().Float64Var(
39+
&rateLimit,
40+
"rate-limit",
41+
0.0,
42+
"Number of requests per minute to capture",
43+
)
3444
runCmd.PersistentFlags().BoolVar(
3545
&reproMode,
3646
"repro-mode",

0 commit comments

Comments
 (0)