Skip to content

Commit bb7da6b

Browse files
authored
Merge pull request #16928 from hakman/automated-cherry-pick-of-#16918-upstream-release-1.30
Automated cherry pick of #16918: API Server: memory management related flags
2 parents 6fc04ff + e51c751 commit bb7da6b

File tree

11 files changed

+96
-21
lines changed

11 files changed

+96
-21
lines changed

docs/cluster_spec.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,14 +586,27 @@ spec:
586586
disableBasicAuth: true
587587
```
588588

589-
### targetRamMb
589+
### watchCache
590+
Used to disable watch caching in the apiserver, defaults to enabling caching by omission
590591

591-
Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
592+
```yaml
593+
spec:
594+
kubeAPIServer:
595+
watchCache: false
596+
```
597+
598+
### watchCacheSizes
599+
600+
Set the watch-cache-sizes parameter for the apiserver
601+
The only currently useful value is setting to 0, which disable caches for specific object types.
602+
Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
592603

593604
```yaml
594605
spec:
595606
kubeAPIServer:
596-
targetRamMb: 4096
607+
watchCacheSizes:
608+
- secrets#0
609+
- pods#0
597610
```
598611

599612
### eventTTL
@@ -1585,7 +1598,6 @@ the removal of fields no longer in use.
15851598
| kubeAPIServer.oidcRequiredClaim (list) | authentication.oidc.oidcRequiredClaims (map) |
15861599
| kubeAPIServer.oidcUsernameClaim | authentication.oidc.usernameClaim |
15871600
| kubeAPIServer.oidcUsernamePrefix | authentication.oidc.usernamePrefix |
1588-
| kubeAPIServer.targetRamMb | kubeAPIServer.targetRamMB |
15891601
| kubeControllerManager.concurrentRcSyncs | kubeControllerManager.concurrentRCSyncs |
15901602
| kubelet.authenticationTokenWebhookCacheTtl | kubelet.authenticationTokenWebhookCacheTTL |
15911603
| kubelet.clientCaFile | kubelet.clientCAFile |

k8s/crds/kops.k8s.io_clusters.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,11 +2129,6 @@ spec:
21292129
storageBackend:
21302130
description: StorageBackend is the backend storage
21312131
type: string
2132-
targetRamMb:
2133-
description: Memory limit for apiserver in MB (used to configure
2134-
sizes of caches, etc.)
2135-
format: int32
2136-
type: integer
21372132
tlsCertFile:
21382133
description: 'TODO: Remove unused TLSCertFile'
21392134
type: string
@@ -2152,6 +2147,18 @@ spec:
21522147
tokenAuthFile:
21532148
description: 'TODO: Remove unused TokenAuthFile'
21542149
type: string
2150+
watchCache:
2151+
description: Used to disable watch caching in the apiserver, defaults
2152+
to enabling caching by omission
2153+
type: boolean
2154+
watchCacheSizes:
2155+
description: |-
2156+
Set the watch-cache-sizes parameter for the apiserver
2157+
The only meaningful value is setting to 0, which disable caches for specific object types.
2158+
Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
2159+
items:
2160+
type: string
2161+
type: array
21552162
type: object
21562163
kubeControllerManager:
21572164
description: KubeControllerManagerConfig is the configuration for

nodeup/pkg/model/kube_apiserver_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"k8s.io/kops/pkg/flagbuilder"
2424
"k8s.io/kops/upup/pkg/fi"
2525
"k8s.io/kops/util/pkg/architectures"
26+
"k8s.io/utils/pointer"
2627
)
2728

2829
func Test_KubeAPIServer_BuildFlags(t *testing.T) {
@@ -92,9 +93,15 @@ func Test_KubeAPIServer_BuildFlags(t *testing.T) {
9293
},
9394
{
9495
kops.KubeAPIServerConfig{
95-
TargetRamMB: 320,
96+
WatchCache: pointer.Bool(false),
9697
},
97-
"--secure-port=0 --target-ram-mb=320",
98+
"--secure-port=0 --watch-cache=false",
99+
},
100+
{
101+
kops.KubeAPIServerConfig{
102+
WatchCacheSizes: []string{"secrets#0", "pods#0"},
103+
},
104+
"--secure-port=0 --watch-cache-sizes=secrets#0,pods#0",
98105
},
99106
{
100107
kops.KubeAPIServerConfig{

pkg/apis/kops/componentconfig.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,13 @@ type KubeAPIServerConfig struct {
487487
// Currently only honored by the watch request handler
488488
MinRequestTimeout *int32 `json:"minRequestTimeout,omitempty" flag:"min-request-timeout"`
489489

490-
// Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
491-
TargetRamMB int32 `json:"targetRamMB,omitempty" flag:"target-ram-mb" flag-empty:"0"`
490+
// Used to disable watch caching in the apiserver, defaults to enabling caching by omission
491+
WatchCache *bool `json:"watchCache,omitempty" flag:"watch-cache"`
492+
493+
// Set the watch-cache-sizes parameter for the apiserver
494+
// The only meaningful value is setting to 0, which disable caches for specific object types.
495+
// Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
496+
WatchCacheSizes []string `json:"watchCacheSizes,omitempty" flag:"watch-cache-sizes" flag-empty:"0"`
492497

493498
// File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens.
494499
// The specified file can contain multiple keys, and the flag can be specified multiple times with different files.

pkg/apis/kops/v1alpha2/componentconfig.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,13 @@ type KubeAPIServerConfig struct {
494494
// Currently only honored by the watch request handler
495495
MinRequestTimeout *int32 `json:"minRequestTimeout,omitempty" flag:"min-request-timeout"`
496496

497-
// Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
498-
TargetRamMB int32 `json:"targetRamMb,omitempty" flag:"target-ram-mb" flag-empty:"0"`
497+
// Used to disable watch caching in the apiserver, defaults to enabling caching by omission
498+
WatchCache *bool `json:"watchCache,omitempty" flag:"watch-cache"`
499+
500+
// Set the watch-cache-sizes parameter for the apiserver
501+
// The only meaningful value is setting to 0, which disable caches for specific object types.
502+
// Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
503+
WatchCacheSizes []string `json:"watchCacheSizes,omitempty" flag:"watch-cache-sizes" flag-empty:"0"`
499504

500505
// File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens.
501506
// The specified file can contain multiple keys, and the flag can be specified multiple times with different files.

pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/componentconfig.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,13 @@ type KubeAPIServerConfig struct {
485485
// Currently only honored by the watch request handler
486486
MinRequestTimeout *int32 `json:"minRequestTimeout,omitempty" flag:"min-request-timeout"`
487487

488-
// Memory limit for apiserver in MB (used to configure sizes of caches, etc.)
489-
TargetRamMB int32 `json:"targetRamMB,omitempty" flag:"target-ram-mb" flag-empty:"0"`
488+
// Used to disable watch caching in the apiserver, defaults to enabling caching by omission
489+
WatchCache *bool `json:"watchCache,omitempty" flag:"watch-cache"`
490+
491+
// Set the watch-cache-sizes parameter for the apiserver
492+
// The only meaningful value is setting to 0, which disable caches for specific object types.
493+
// Setting any values other than 0 for a resource will yield no effect since the caches are dynamic
494+
WatchCacheSizes []string `json:"watchCacheSizes,omitempty" flag:"watch-cache-sizes" flag-empty:"0"`
490495

491496
// File containing PEM-encoded x509 RSA or ECDSA private or public keys, used to verify ServiceAccount tokens.
492497
// The specified file can contain multiple keys, and the flag can be specified multiple times with different files.

pkg/apis/kops/v1alpha3/zz_generated.conversion.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)