diff --git a/pkg/kubelet/apis/config/helpers_test.go b/pkg/kubelet/apis/config/helpers_test.go index 72a4d59b34f..5f150297dd4 100644 --- a/pkg/kubelet/apis/config/helpers_test.go +++ b/pkg/kubelet/apis/config/helpers_test.go @@ -209,6 +209,7 @@ var ( "MaxOpenFiles", "MaxPods", "MemoryManagerPolicy", + "MemorySwap.SwapBehavior", "NodeLeaseDurationSeconds", "NodeStatusMaxImages", "NodeStatusUpdateFrequency.Duration", diff --git a/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/after/v1beta1.yaml b/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/after/v1beta1.yaml index 6429d5ad253..6dd170f4920 100644 --- a/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/after/v1beta1.yaml +++ b/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/after/v1beta1.yaml @@ -58,6 +58,7 @@ makeIPTablesUtilChains: true maxOpenFiles: 1000000 maxPods: 110 memoryManagerPolicy: None +memorySwap: {} nodeLeaseDurationSeconds: 40 nodeStatusMaxImages: 50 nodeStatusReportFrequency: 5m0s diff --git a/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/roundtrip/default/v1beta1.yaml b/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/roundtrip/default/v1beta1.yaml index 6429d5ad253..6dd170f4920 100644 --- a/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/roundtrip/default/v1beta1.yaml +++ b/pkg/kubelet/apis/config/scheme/testdata/KubeletConfiguration/roundtrip/default/v1beta1.yaml @@ -58,6 +58,7 @@ makeIPTablesUtilChains: true maxOpenFiles: 1000000 maxPods: 110 memoryManagerPolicy: None +memorySwap: {} nodeLeaseDurationSeconds: 40 nodeStatusMaxImages: 50 nodeStatusReportFrequency: 5m0s diff --git a/pkg/kubelet/apis/config/types.go b/pkg/kubelet/apis/config/types.go index 7502d24ace1..fd8b63bfb81 100644 --- a/pkg/kubelet/apis/config/types.go +++ b/pkg/kubelet/apis/config/types.go @@ -326,6 +326,10 @@ type KubeletConfiguration struct { FeatureGates map[string]bool // Tells the Kubelet to fail to start if swap is enabled on the node. FailSwapOn bool + // Configure swap memory available to container workloads. + // +featureGate=NodeSwapEnabled + // +optional + MemorySwap MemorySwapConfiguration // A quantity defines the maximum size of the container log file before it is rotated. For example: "5Mi" or "256Ki". ContainerLogMaxSize string // Maximum number of container log files that can be present for a container. @@ -568,3 +572,10 @@ type MemoryReservation struct { NumaNode int32 Limits v1.ResourceList } + +type MemorySwapConfiguration struct { + // Configure swap memory available to container workloads. May be one of + // "", "NoSwap": workloads cannot use swap + // "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit. + SwapBehavior string +} diff --git a/staging/src/k8s.io/kubelet/config/v1beta1/types.go b/staging/src/k8s.io/kubelet/config/v1beta1/types.go index f4632656b83..651148cf337 100644 --- a/staging/src/k8s.io/kubelet/config/v1beta1/types.go +++ b/staging/src/k8s.io/kubelet/config/v1beta1/types.go @@ -752,6 +752,10 @@ type KubeletConfiguration struct { // Default: true // +optional FailSwapOn *bool `json:"failSwapOn,omitempty"` + // Configure swap memory available to container workloads. + // +featureGate=NodeSwapEnabled + // +optional + MemorySwap MemorySwapConfiguration `json:"memorySwap,omitempty"` // containerLogMaxSize is a quantity defining the maximum size of the container log // file before it is rotated. For example: "5Mi" or "256Ki". // Dynamic Kubelet Config (beta): If dynamically updating this field, consider that @@ -1035,3 +1039,10 @@ type MemoryReservation struct { NumaNode int32 `json:"numaNode"` Limits v1.ResourceList `json:"limits"` } + +// Configure swap memory available to container workloads. May be one of +// "", "NoSwap": workloads cannot use swap +// "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit. +type MemorySwapConfiguration struct { + SwapBehavior string `json:"swapBehavior,omitempty"` +}