Skip to content

Commit

Permalink
Merge pull request #16918 from rsafonseca/mem_options
Browse files Browse the repository at this point in the history
API Server: memory management related flags
  • Loading branch information
k8s-ci-robot authored Oct 25, 2024
2 parents d633cde + 7d673c0 commit 17e7cb1
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 21 deletions.
20 changes: 16 additions & 4 deletions docs/cluster_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,27 @@ spec:
disableBasicAuth: true
```

### targetRamMb
### watchCache
Used to disable watch caching in the apiserver, defaults to enabling caching by omission

Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
```yaml
spec:
kubeAPIServer:
watchCache: false
```

### watchCacheSizes

Set the watch-cache-sizes parameter for the apiserver
The only currently useful value is setting to 0, which disable caches for specific object types.
Setting any values other than 0 for a resource will yield no effect since the caches are dynamic

```yaml
spec:
kubeAPIServer:
targetRamMb: 4096
watchCacheSizes:
- secrets#0
- pods#0
```

### eventTTL
Expand Down Expand Up @@ -1585,7 +1598,6 @@ the removal of fields no longer in use.
| kubeAPIServer.oidcRequiredClaim (list) | authentication.oidc.oidcRequiredClaims (map) |
| kubeAPIServer.oidcUsernameClaim | authentication.oidc.usernameClaim |
| kubeAPIServer.oidcUsernamePrefix | authentication.oidc.usernamePrefix |
| kubeAPIServer.targetRamMb | kubeAPIServer.targetRamMB |
| kubeControllerManager.concurrentRcSyncs | kubeControllerManager.concurrentRCSyncs |
| kubelet.authenticationTokenWebhookCacheTtl | kubelet.authenticationTokenWebhookCacheTTL |
| kubelet.clientCaFile | kubelet.clientCAFile |
Expand Down
17 changes: 12 additions & 5 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2132,11 +2132,6 @@ spec:
storageBackend:
description: StorageBackend is the backend storage
type: string
targetRamMb:
description: Memory limit for apiserver in MB (used to configure
sizes of caches, etc.)
format: int32
type: integer
tlsCertFile:
type: string
tlsCipherSuites:
Expand All @@ -2152,6 +2147,18 @@ spec:
type: string
tokenAuthFile:
type: string
watchCache:
description: Used to disable watch caching in the apiserver, defaults
to enabling caching by omission
type: boolean
watchCacheSizes:
description: |-
Set the watch-cache-sizes parameter for the apiserver
The only meaningful value is setting to 0, which disable caches for specific object types.
Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
items:
type: string
type: array
type: object
kubeControllerManager:
description: KubeControllerManagerConfig is the configuration for
Expand Down
11 changes: 9 additions & 2 deletions nodeup/pkg/model/kube_apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/util/pkg/architectures"
"k8s.io/utils/pointer"
)

func Test_KubeAPIServer_BuildFlags(t *testing.T) {
Expand Down Expand Up @@ -92,9 +93,15 @@ func Test_KubeAPIServer_BuildFlags(t *testing.T) {
},
{
kops.KubeAPIServerConfig{
TargetRamMB: 320,
WatchCache: pointer.Bool(false),
},
"--secure-port=0 --target-ram-mb=320",
"--secure-port=0 --watch-cache=false",
},
{
kops.KubeAPIServerConfig{
WatchCacheSizes: []string{"secrets#0", "pods#0"},
},
"--secure-port=0 --watch-cache-sizes=secrets#0,pods#0",
},
{
kops.KubeAPIServerConfig{
Expand Down
9 changes: 7 additions & 2 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,13 @@ type KubeAPIServerConfig struct {
// Currently only honored by the watch request handler
MinRequestTimeout *int32 `json:"minRequestTimeout,omitempty" flag:"min-request-timeout"`

// Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
TargetRamMB int32 `json:"targetRamMB,omitempty" flag:"target-ram-mb" flag-empty:"0"`
// Used to disable watch caching in the apiserver, defaults to enabling caching by omission
WatchCache *bool `json:"watchCache,omitempty" flag:"watch-cache"`

// Set the watch-cache-sizes parameter for the apiserver
// The only meaningful value is setting to 0, which disable caches for specific object types.
// Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
WatchCacheSizes []string `json:"watchCacheSizes,omitempty" flag:"watch-cache-sizes" flag-empty:"0"`

// File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens.
// The specified file can contain multiple keys, and the flag can be specified multiple times with different files.
Expand Down
9 changes: 7 additions & 2 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,13 @@ type KubeAPIServerConfig struct {
// Currently only honored by the watch request handler
MinRequestTimeout *int32 `json:"minRequestTimeout,omitempty" flag:"min-request-timeout"`

// Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
TargetRamMB int32 `json:"targetRamMb,omitempty" flag:"target-ram-mb" flag-empty:"0"`
// Used to disable watch caching in the apiserver, defaults to enabling caching by omission
WatchCache *bool `json:"watchCache,omitempty" flag:"watch-cache"`

// Set the watch-cache-sizes parameter for the apiserver
// The only meaningful value is setting to 0, which disable caches for specific object types.
// Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
WatchCacheSizes []string `json:"watchCacheSizes,omitempty" flag:"watch-cache-sizes" flag-empty:"0"`

// File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens.
// The specified file can contain multiple keys, and the flag can be specified multiple times with different files.
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

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

10 changes: 10 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

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

9 changes: 7 additions & 2 deletions pkg/apis/kops/v1alpha3/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,13 @@ type KubeAPIServerConfig struct {
// Currently only honored by the watch request handler
MinRequestTimeout *int32 `json:"minRequestTimeout,omitempty" flag:"min-request-timeout"`

// Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
TargetRamMB int32 `json:"targetRamMB,omitempty" flag:"target-ram-mb" flag-empty:"0"`
// Used to disable watch caching in the apiserver, defaults to enabling caching by omission
WatchCache *bool `json:"watchCache,omitempty" flag:"watch-cache"`

// Set the watch-cache-sizes parameter for the apiserver
// The only meaningful value is setting to 0, which disable caches for specific object types.
// Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
WatchCacheSizes []string `json:"watchCacheSizes,omitempty" flag:"watch-cache-sizes" flag-empty:"0"`

// File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens.
// The specified file can contain multiple keys, and the flag can be specified multiple times with different files.
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/kops/v1alpha3/zz_generated.conversion.go

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

10 changes: 10 additions & 0 deletions pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go

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

10 changes: 10 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

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

0 comments on commit 17e7cb1

Please sign in to comment.