mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-28 13:45:50 +00:00
Rename NoSwap to LimitedSwap as workloads may still swap
Also made the options a kubelet type, address API review feedback
This commit is contained in:
@@ -326,7 +326,7 @@ 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.
|
||||
// memorySwap configures swap memory available to container workloads.
|
||||
// +featureGate=NodeSwapEnabled
|
||||
// +optional
|
||||
MemorySwap MemorySwapConfiguration
|
||||
@@ -574,8 +574,10 @@ type MemoryReservation struct {
|
||||
}
|
||||
|
||||
type MemorySwapConfiguration struct {
|
||||
// Configure swap memory available to container workloads. May be one of
|
||||
// "", "NoSwap": workloads cannot use swap
|
||||
// swapBehavior configures swap memory available to container workloads. May be one of
|
||||
// "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit
|
||||
// "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit.
|
||||
// +featureGate=NodeSwapEnabled
|
||||
// +optional
|
||||
SwapBehavior string
|
||||
}
|
||||
|
@@ -156,8 +156,8 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: Specifying ShutdownGracePeriod or ShutdownGracePeriodCriticalPods requires feature gate GracefulNodeShutdown"))
|
||||
}
|
||||
if localFeatureGate.Enabled(features.NodeSwapEnabled) {
|
||||
if kc.MemorySwap.SwapBehavior != "" && kc.MemorySwap.SwapBehavior != "NoSwap" && kc.MemorySwap.SwapBehavior != "UnlimitedSwap" {
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior %v must be one of: NoSwap, UnlimitedSwap", kc.MemorySwap.SwapBehavior))
|
||||
if kc.MemorySwap.SwapBehavior != "" && kc.MemorySwap.SwapBehavior != kubetypes.LimitedSwap && kc.MemorySwap.SwapBehavior != kubetypes.UnlimitedSwap {
|
||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior %v must be one of: LimitedSwap, UnlimitedSwap", kc.MemorySwap.SwapBehavior))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import (
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
)
|
||||
|
||||
func TestValidateKubeletConfiguration(t *testing.T) {
|
||||
@@ -145,7 +146,7 @@ func TestValidateKubeletConfiguration(t *testing.T) {
|
||||
TopologyManagerPolicy: kubeletconfig.NoneTopologyManagerPolicy,
|
||||
ShutdownGracePeriod: metav1.Duration{Duration: 10 * time.Minute},
|
||||
ShutdownGracePeriodCriticalPods: metav1.Duration{Duration: 0},
|
||||
MemorySwap: kubeletconfig.MemorySwapConfiguration{SwapBehavior: "UnlimitedSwap"},
|
||||
MemorySwap: kubeletconfig.MemorySwapConfiguration{SwapBehavior: kubetypes.UnlimitedSwap},
|
||||
FeatureGates: map[string]bool{
|
||||
"CustomCPUCFSQuotaPeriod": true,
|
||||
"GracefulNodeShutdown": true,
|
||||
|
Reference in New Issue
Block a user