Skip to content

Commit

Permalink
add flag --disable-qps-limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuzhenghao committed Jun 13, 2023
1 parent 6374ae6 commit cce4c57
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/apis/config/v1alpha1/kwokctl_configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ type KwokctlConfigurationOptions struct {

// KubeApiserverCertSANs sets extra Subject Alternative Names for the API Server signing cert.
KubeApiserverCertSANs []string `json:"kubeApiserverCertSANs,omitempty"`

// DisableQPSLimits specifies whether to disable QPS limits for components.
// +default=false
DisableQPSLimits *bool `json:"disableQPSLimits,omitempty"`
}

// Component is a component of the cluster.
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions pkg/apis/config/v1alpha1/zz_generated.defaults.go

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

3 changes: 3 additions & 0 deletions pkg/apis/internalversion/kwokctl_configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ type KwokctlConfigurationOptions struct {

// KubeApiserverCertSANs sets extra Subject Alternative Names for the API Server signing cert.
KubeApiserverCertSANs []string

// DisableQPSLimits specifies whether to disable QPS limits for components.
DisableQPSLimits bool
}

// Component is a component of the cluster.
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/internalversion/zz_generated.conversion.go

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

3 changes: 3 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ var (
PrometheusImagePrefix = "docker.io/prom"

KindNodeImagePrefix = "docker.io/kindest"

DefaultUnlimitedQPS = 5000.0
DefaultUnlimitedBurst = 10000
)

// The following runtime is provided.
Expand Down
1 change: 1 addition & 0 deletions pkg/kwokctl/cmd/create/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func NewCommand(ctx context.Context) *cobra.Command {
cmd.Flags().DurationVar(&flags.Timeout, "timeout", 0, "Timeout for waiting for the cluster to be created")
cmd.Flags().DurationVar(&flags.Wait, "wait", 0, "Wait for the cluster to be ready")
cmd.Flags().StringVar(&flags.Kubeconfig, "kubeconfig", flags.Kubeconfig, "The path to the kubeconfig file will be added to the newly created cluster and set to current-context")
cmd.Flags().BoolVar(&flags.Options.DisableQPSLimits, "disable-qps-limits", flags.Options.DisableQPSLimits, "Disable QPS limits for components")
return cmd
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/kwokctl/components/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type BuildKubeApiserverComponentConfig struct {
AdminCertPath string
AdminKeyPath string
Verbosity log.Level
DisableQPSLimits bool
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
}
Expand Down Expand Up @@ -84,6 +85,20 @@ func BuildKubeApiserverComponent(conf BuildKubeApiserverComponentConfig) (compon
)
}

if conf.DisableQPSLimits {
kubeApiserverArgs = append(kubeApiserverArgs,
"--max-requests-inflight=0",
"--max-mutating-requests-inflight=0",
)

// FeatureGate APIPriorityAndFairness is not available before 1.17.0
if conf.Version.GE(version.NewVersion(1, 18, 0)) {
kubeApiserverArgs = append(kubeApiserverArgs,
"--enable-priority-and-fairness=false",
)
}
}

var ports []internalversion.Port
var volumes []internalversion.Volume
volumes = append(volumes, conf.ExtraVolumes...)
Expand Down
9 changes: 9 additions & 0 deletions pkg/kwokctl/components/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"

"sigs.k8s.io/kwok/pkg/apis/internalversion"
"sigs.k8s.io/kwok/pkg/consts"
"sigs.k8s.io/kwok/pkg/log"
"sigs.k8s.io/kwok/pkg/utils/format"
"sigs.k8s.io/kwok/pkg/utils/version"
Expand All @@ -43,6 +44,7 @@ type BuildKubeControllerManagerComponentConfig struct {
NodeMonitorPeriodMilliseconds int64
NodeMonitorGracePeriodMilliseconds int64
Verbosity log.Level
DisableQPSLimits bool
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
}
Expand Down Expand Up @@ -180,6 +182,13 @@ func BuildKubeControllerManagerComponent(conf BuildKubeControllerManagerComponen
}
}

if conf.DisableQPSLimits {
kubeControllerManagerArgs = append(kubeControllerManagerArgs,
"--kube-api-qps="+format.String(consts.DefaultUnlimitedQPS),
"--kube-api-burst="+format.String(consts.DefaultUnlimitedBurst),
)
}

if conf.Verbosity != log.LevelInfo {
kubeControllerManagerArgs = append(kubeControllerManagerArgs, "--v="+format.String(log.ToKlogLevel(conf.Verbosity)))
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/kwokctl/components/kube_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package components

import (
"sigs.k8s.io/kwok/pkg/apis/internalversion"
"sigs.k8s.io/kwok/pkg/consts"
"sigs.k8s.io/kwok/pkg/log"
"sigs.k8s.io/kwok/pkg/utils/format"
"sigs.k8s.io/kwok/pkg/utils/version"
Expand All @@ -39,6 +40,7 @@ type BuildKubeSchedulerComponentConfig struct {
KubeconfigPath string
KubeFeatureGates string
Verbosity log.Level
DisableQPSLimits bool
ExtraArgs []internalversion.ExtraArgs
ExtraVolumes []internalversion.Volume
}
Expand Down Expand Up @@ -170,6 +172,13 @@ func BuildKubeSchedulerComponent(conf BuildKubeSchedulerComponentConfig) (compon
// )
}

if conf.DisableQPSLimits {
kubeSchedulerArgs = append(kubeSchedulerArgs,
"--kube-api-qps="+format.String(consts.DefaultUnlimitedQPS),
"--kube-api-burst="+format.String(consts.DefaultUnlimitedBurst),
)
}

if conf.Verbosity != log.LevelInfo {
kubeSchedulerArgs = append(kubeSchedulerArgs, "--v="+format.String(log.ToKlogLevel(conf.Verbosity)))
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/kwokctl/runtime/binary/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func (c *Cluster) Install(ctx context.Context) error {
AdminCertPath: adminCertPath,
AdminKeyPath: adminKeyPath,
Verbosity: verbosity,
DisableQPSLimits: conf.DisableQPSLimits,
ExtraArgs: kubeApiserverComponentPatches.ExtraArgs,
ExtraVolumes: kubeApiserverComponentPatches.ExtraVolumes,
})
Expand Down Expand Up @@ -335,6 +336,7 @@ func (c *Cluster) Install(ctx context.Context) error {
NodeMonitorPeriodMilliseconds: conf.KubeControllerManagerNodeMonitorPeriodMilliseconds,
NodeMonitorGracePeriodMilliseconds: conf.KubeControllerManagerNodeMonitorGracePeriodMilliseconds,
Verbosity: verbosity,
DisableQPSLimits: conf.DisableQPSLimits,
ExtraArgs: kubeControllerManagerPatches.ExtraArgs,
ExtraVolumes: kubeControllerManagerPatches.ExtraVolumes,
})
Expand Down Expand Up @@ -382,6 +384,7 @@ func (c *Cluster) Install(ctx context.Context) error {
KubeconfigPath: kubeconfigPath,
KubeFeatureGates: conf.KubeFeatureGates,
Verbosity: verbosity,
DisableQPSLimits: conf.DisableQPSLimits,
ExtraArgs: kubeSchedulerComponentPatches.ExtraArgs,
ExtraVolumes: kubeSchedulerComponentPatches.ExtraVolumes,
})
Expand Down
3 changes: 3 additions & 0 deletions pkg/kwokctl/runtime/compose/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func (c *Cluster) Install(ctx context.Context) error {
EtcdPort: conf.EtcdPort,
EtcdAddress: c.Name() + "-etcd",
Verbosity: verbosity,
DisableQPSLimits: conf.DisableQPSLimits,
ExtraArgs: kubeApiserverComponentPatches.ExtraArgs,
ExtraVolumes: kubeApiserverComponentPatches.ExtraVolumes,
})
Expand Down Expand Up @@ -356,6 +357,7 @@ func (c *Cluster) Install(ctx context.Context) error {
KubeconfigPath: inClusterOnHostKubeconfigPath,
KubeFeatureGates: conf.KubeFeatureGates,
Verbosity: verbosity,
DisableQPSLimits: conf.DisableQPSLimits,
NodeMonitorPeriodMilliseconds: conf.KubeControllerManagerNodeMonitorPeriodMilliseconds,
NodeMonitorGracePeriodMilliseconds: conf.KubeControllerManagerNodeMonitorGracePeriodMilliseconds,
ExtraArgs: kubeControllerManagerComponentPatches.ExtraArgs,
Expand Down Expand Up @@ -402,6 +404,7 @@ func (c *Cluster) Install(ctx context.Context) error {
KubeconfigPath: inClusterOnHostKubeconfigPath,
KubeFeatureGates: conf.KubeFeatureGates,
Verbosity: verbosity,
DisableQPSLimits: conf.DisableQPSLimits,
ExtraArgs: kubeSchedulerComponentPatches.ExtraArgs,
ExtraVolumes: kubeSchedulerComponentPatches.ExtraVolumes,
})
Expand Down
8 changes: 8 additions & 0 deletions pkg/kwokctl/runtime/kind/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"sigs.k8s.io/kwok/pkg/utils/net"
"sigs.k8s.io/kwok/pkg/utils/path"
"sigs.k8s.io/kwok/pkg/utils/slices"
"sigs.k8s.io/kwok/pkg/utils/version"
"sigs.k8s.io/kwok/pkg/utils/wait"
)

Expand Down Expand Up @@ -132,6 +133,11 @@ func (c *Cluster) Install(ctx context.Context) error {

configPath := c.GetWorkdirPath(runtime.ConfigName)

kubeVersion, err := version.ParseVersion(conf.KubeVersion)
if err != nil {
return err
}

etcdComponentPatches := runtime.GetComponentPatches(config, "etcd")
kubeApiserverComponentPatches := runtime.GetComponentPatches(config, "kube-apiserver")
kubeSchedulerComponentPatches := runtime.GetComponentPatches(config, "kube-scheduler")
Expand Down Expand Up @@ -162,6 +168,8 @@ func (c *Cluster) Install(ctx context.Context) error {
ControllerManagerExtraArgs: kubeControllerManagerComponentPatches.ExtraArgs,
ControllerManagerExtraVolumes: kubeControllerManagerComponentPatches.ExtraVolumes,
KwokControllerExtraVolumes: kwokControllerExtraVolumes,
DisableQPSLimits: conf.DisableQPSLimits,
KubeVersion: kubeVersion,
})
if err != nil {
return err
Expand Down
49 changes: 48 additions & 1 deletion pkg/kwokctl/runtime/kind/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import (
"text/template"

"sigs.k8s.io/kwok/pkg/apis/internalversion"
"sigs.k8s.io/kwok/pkg/consts"
"sigs.k8s.io/kwok/pkg/kwokctl/runtime"
"sigs.k8s.io/kwok/pkg/log"
"sigs.k8s.io/kwok/pkg/utils/format"
"sigs.k8s.io/kwok/pkg/utils/version"

_ "embed"
)
Expand Down Expand Up @@ -137,6 +139,49 @@ func expendExtrasForBuildKind(conf BuildKindConfig) BuildKindConfig {
},
)
}

if conf.DisableQPSLimits {
conf.ApiserverExtraArgs = append(conf.ApiserverExtraArgs,
internalversion.ExtraArgs{
Key: "max-requests-inflight",
Value: "0",
},
internalversion.ExtraArgs{
Key: "max-mutating-requests-inflight",
Value: "0",
},
)

// FeatureGate APIPriorityAndFairness is not available before 1.17.0
if conf.KubeVersion.GE(version.NewVersion(1, 18, 0)) {
conf.ApiserverExtraArgs = append(conf.ApiserverExtraArgs,
internalversion.ExtraArgs{
Key: "enable-priority-and-fairness",
Value: "false",
},
)
}
conf.ControllerManagerExtraArgs = append(conf.ControllerManagerExtraArgs,
internalversion.ExtraArgs{
Key: "kube-api-qps",
Value: format.String(consts.DefaultUnlimitedQPS),
},
internalversion.ExtraArgs{
Key: "kube-api-burst",
Value: format.String(consts.DefaultUnlimitedBurst),
},
)
conf.SchedulerExtraArgs = append(conf.SchedulerExtraArgs,
internalversion.ExtraArgs{
Key: "kube-api-qps",
Value: format.String(consts.DefaultUnlimitedQPS),
},
internalversion.ExtraArgs{
Key: "kube-api-burst",
Value: format.String(consts.DefaultUnlimitedBurst),
},
)
}
return conf
}

Expand Down Expand Up @@ -203,5 +248,7 @@ type BuildKindConfig struct {
ControllerManagerExtraVolumes []internalversion.Volume
KwokControllerExtraVolumes []internalversion.Volume

BindAddress string
BindAddress string
DisableQPSLimits bool
KubeVersion version.Version
}
11 changes: 11 additions & 0 deletions site/content/en/docs/generated/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,17 @@ string
<p>KubeApiserverCertSANs sets extra Subject Alternative Names for the API Server signing cert.</p>
</td>
</tr>
<tr>
<td>
<code>disableQPSLimits</code>
<em>
bool
</em>
</td>
<td>
<p>DisableQPSLimits specifies whether to disable QPS limits for components.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="config.kwok.x-k8s.io/v1alpha1.Port">
Expand Down
1 change: 1 addition & 0 deletions site/content/en/docs/generated/kwokctl_create_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ kwokctl create cluster [flags]
--controller-port uint32 Port of kwok-controller given to the host
--disable-kube-controller-manager Disable the kube-controller-manager
--disable-kube-scheduler Disable the kube-scheduler
--disable-qps-limits Disable QPS limits for components
--etcd-binary string Binary of etcd, only for binary runtime
--etcd-binary-tar string Tar of etcd, if --etcd-binary is set, this is ignored, only for binary runtime
(default "https://github.com/etcd-io/etcd/releases/download/v3.5.7/etcd-v3.5.7-linux-amd64.tar.gz")
Expand Down
1 change: 1 addition & 0 deletions test/kwokctl/suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function create_cluster() {
--timeout 30m \
--wait 30m \
--quiet-pull \
--disable-qps-limits \
"$@"; then
echo "Error: Cluster ${name} creation failed"
show_all
Expand Down

0 comments on commit cce4c57

Please sign in to comment.