Skip to content

Commit

Permalink
Enable more optional configurations for AKS node pools
Browse files Browse the repository at this point in the history
  • Loading branch information
meixingdb committed Nov 9, 2021
1 parent 909f3a0 commit 76f97a1
Show file tree
Hide file tree
Showing 20 changed files with 2,122 additions and 16 deletions.
26 changes: 26 additions & 0 deletions api/v1alpha4/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,32 @@ type AzureBastion struct {
PublicIP PublicIPSpec `json:"publicIP,omitempty"`
}

// KubeletConfig kubelet configurations of agent nodes.
type KubeletConfig struct {
// CPUManagerPolicy - CPU Manager policy to use.
CPUManagerPolicy *string `json:"cpuManagerPolicy,omitempty"`
// CPUCfsQuota - Enable CPU CFS quota enforcement for containers that specify CPU limits.
CPUCfsQuota *bool `json:"cpuCfsQuota,omitempty"`
// CPUCfsQuotaPeriod - Sets CPU CFS quota period value.
CPUCfsQuotaPeriod *string `json:"cpuCfsQuotaPeriod,omitempty"`
// ImageGcHighThreshold - The percent of disk usage after which image garbage collection is always run.
ImageGcHighThreshold *int32 `json:"imageGcHighThreshold,omitempty"`
// ImageGcLowThreshold - The percent of disk usage before which image garbage collection is never run.
ImageGcLowThreshold *int32 `json:"imageGcLowThreshold,omitempty"`
// TopologyManagerPolicy - Topology Manager policy to use.
TopologyManagerPolicy *string `json:"topologyManagerPolicy,omitempty"`
// AllowedUnsafeSysctls - Allowlist of unsafe sysctls or unsafe sysctl patterns (ending in `*`).
AllowedUnsafeSysctls *[]string `json:"allowedUnsafeSysctls,omitempty"`
// FailSwapOn - If set to true it will make the Kubelet fail to start if swap is enabled on the node.
FailSwapOn *bool `json:"failSwapOn,omitempty"`
// ContainerLogMaxSizeMB - The maximum size (e.g. 10Mi) of container log file before it is rotated.
ContainerLogMaxSizeMB *int32 `json:"containerLogMaxSizeMB,omitempty"`
// ContainerLogMaxFiles - The maximum number of container log files that can be present for a container. The number must be ≥ 2.
ContainerLogMaxFiles *int32 `json:"containerLogMaxFiles,omitempty"`
// PodMaxPids - The maximum number of processes per pod.
PodMaxPids *int32 `json:"podMaxPids,omitempty"`
}

// IsTerminalProvisioningState returns true if the ProvisioningState is a terminal state for an Azure resource.
func IsTerminalProvisioningState(state ProvisioningState) bool {
return state == Failed || state == Succeeded
Expand Down
50 changes: 50 additions & 0 deletions api/v1alpha4/zz_generated.conversion.go

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

74 changes: 74 additions & 0 deletions api/v1alpha4/zz_generated.deepcopy.go

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

26 changes: 26 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,29 @@ type AzureBastion struct {
func IsTerminalProvisioningState(state ProvisioningState) bool {
return state == Failed || state == Succeeded
}

// KubeletConfig kubelet configurations of agent nodes.
type KubeletConfig struct {
// CPUManagerPolicy - CPU Manager policy to use.
CPUManagerPolicy *string `json:"cpuManagerPolicy,omitempty"`
// CPUCfsQuota - Enable CPU CFS quota enforcement for containers that specify CPU limits.
CPUCfsQuota *bool `json:"cpuCfsQuota,omitempty"`
// CPUCfsQuotaPeriod - Sets CPU CFS quota period value.
CPUCfsQuotaPeriod *string `json:"cpuCfsQuotaPeriod,omitempty"`
// ImageGcHighThreshold - The percent of disk usage after which image garbage collection is always run.
ImageGcHighThreshold *int32 `json:"imageGcHighThreshold,omitempty"`
// ImageGcLowThreshold - The percent of disk usage before which image garbage collection is never run.
ImageGcLowThreshold *int32 `json:"imageGcLowThreshold,omitempty"`
// TopologyManagerPolicy - Topology Manager policy to use.
TopologyManagerPolicy *string `json:"topologyManagerPolicy,omitempty"`
// AllowedUnsafeSysctls - Allowlist of unsafe sysctls or unsafe sysctl patterns (ending in `*`).
AllowedUnsafeSysctls *[]string `json:"allowedUnsafeSysctls,omitempty"`
// FailSwapOn - If set to true it will make the Kubelet fail to start if swap is enabled on the node.
FailSwapOn *bool `json:"failSwapOn,omitempty"`
// ContainerLogMaxSizeMB - The maximum size (e.g. 10Mi) of container log file before it is rotated.
ContainerLogMaxSizeMB *int32 `json:"containerLogMaxSizeMB,omitempty"`
// ContainerLogMaxFiles - The maximum number of container log files that can be present for a container. The number must be ≥ 2.
ContainerLogMaxFiles *int32 `json:"containerLogMaxFiles,omitempty"`
// PodMaxPids - The maximum number of processes per pod.
PodMaxPids *int32 `json:"podMaxPids,omitempty"`
}
74 changes: 74 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

45 changes: 45 additions & 0 deletions azure/scope/managedcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"

"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/to"
"github.com/go-logr/logr"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -504,6 +505,28 @@ func (s *ManagedControlPlaneScope) GetAgentPoolSpecs(ctx context.Context) ([]azu
ammp.Replicas = *ownerPool.Spec.Replicas
}

if pool.Spec.VnetSubnetID != nil {
ammp.VnetSubnetID = *pool.Spec.VnetSubnetID
}

if pool.Spec.KubeletConfig != nil {
ammp.KubeletConfig = (*infrav1.KubeletConfig)(pool.Spec.KubeletConfig)
}

if pool.Spec.AutoScaling != nil {
ammp.EnableAutoScaling = to.BoolPtr(true)
ammp.MaxCount = pool.Spec.AutoScaling.MaxCount
ammp.MinCount = pool.Spec.AutoScaling.MinCount
}
ammp.EnableFIPS = pool.Spec.EnableFIPS
ammp.EnableNodePublicIP = pool.Spec.EnableNodePublicIP
ammp.AvailabilityZones = pool.Spec.AvailabilityZones
ammp.NodeLabels = pool.Spec.NodeLabels
ammp.NodeTaints = pool.Spec.NodeTaints
ammp.OsDiskType = pool.Spec.OsDiskType
ammp.ScaleSetPriority = pool.Spec.ScaleSetPriority
ammp.MaxPods = pool.Spec.MaxPods

ammps = append(ammps, ammp)
}

Expand Down Expand Up @@ -547,6 +570,28 @@ func (s *ManagedControlPlaneScope) AgentPoolSpec() azure.AgentPoolSpec {
agentPoolSpec.OSDiskSizeGB = *s.InfraMachinePool.Spec.OSDiskSizeGB
}

if s.InfraMachinePool.Spec.VnetSubnetID != nil {
agentPoolSpec.VnetSubnetID = *s.InfraMachinePool.Spec.VnetSubnetID
}

if s.InfraMachinePool.Spec.KubeletConfig != nil {
agentPoolSpec.KubeletConfig = (*infrav1.KubeletConfig)(s.InfraMachinePool.Spec.KubeletConfig)
}

if s.InfraMachinePool.Spec.AutoScaling != nil {
agentPoolSpec.EnableAutoScaling = to.BoolPtr(true)
agentPoolSpec.MaxCount = s.InfraMachinePool.Spec.AutoScaling.MaxCount
agentPoolSpec.MinCount = s.InfraMachinePool.Spec.AutoScaling.MinCount
}
agentPoolSpec.EnableFIPS = s.InfraMachinePool.Spec.EnableFIPS
agentPoolSpec.EnableNodePublicIP = s.InfraMachinePool.Spec.EnableNodePublicIP
agentPoolSpec.NodeLabels = s.InfraMachinePool.Spec.NodeLabels
agentPoolSpec.NodeTaints = s.InfraMachinePool.Spec.NodeTaints
agentPoolSpec.OsDiskType = s.InfraMachinePool.Spec.OsDiskType
agentPoolSpec.AvailabilityZones = s.InfraMachinePool.Spec.AvailabilityZones
agentPoolSpec.ScaleSetPriority = s.InfraMachinePool.Spec.ScaleSetPriority
agentPoolSpec.MaxPods = s.InfraMachinePool.Spec.MaxPods

return agentPoolSpec
}

Expand Down
Loading

0 comments on commit 76f97a1

Please sign in to comment.