Skip to content

Commit

Permalink
Add support for kubeletDiskType
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Dec 22, 2022
1 parent 64b9713 commit 68f0198
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions azure/converters/managedagentpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func AgentPoolToManagedClusterAgentPoolProfile(pool containerservice.AgentPool)
NodePublicIPPrefixID: properties.NodePublicIPPrefixID,
ScaleSetPriority: properties.ScaleSetPriority,
Tags: properties.Tags,
KubeletDiskType: properties.KubeletDiskType,
}
if properties.KubeletConfig != nil {
agentPool.KubeletConfig = properties.KubeletConfig
Expand Down
1 change: 1 addition & 0 deletions azure/scope/managedmachinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func buildAgentPoolSpec(managedControlPlane *infrav1exp.AzureManagedControlPlane
NodePublicIPPrefixID: managedMachinePool.Spec.NodePublicIPPrefixID,
ScaleSetPriority: managedMachinePool.Spec.ScaleSetPriority,
AdditionalTags: managedMachinePool.Spec.AdditionalTags,
KubeletDiskType: managedMachinePool.Spec.KubeletDiskType,
}

if managedMachinePool.Spec.OSDiskSizeGB != nil {
Expand Down
4 changes: 4 additions & 0 deletions azure/services/agentpools/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ type AgentPoolSpec struct {
// KubeletConfig specifies the kubelet configurations for nodes.
KubeletConfig *KubeletConfig `json:"kubeletConfig,omitempty"`

// KubeletDiskType specifies the kubelet disk type for each node in the pool. Allowed values are 'OS' and 'Temporary'
KubeletDiskType *string `json:"kubeletDiskType,omitempty"`

// AdditionalTags is an optional set of tags to add to Azure resources managed by the Azure provider, in addition to the ones added by default.
AdditionalTags infrav1.Tags
}
Expand Down Expand Up @@ -278,6 +281,7 @@ func (s *AgentPoolSpec) Parameters(existing interface{}) (params interface{}, er
EnableAutoScaling: s.EnableAutoScaling,
EnableUltraSSD: s.EnableUltraSSD,
KubeletConfig: kubeletConfig,
KubeletDiskType: containerservice.KubeletDiskType(to.String(s.KubeletDiskType)),
MaxCount: s.MaxCount,
MaxPods: s.MaxPods,
MinCount: s.MinCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ spec:
- single-numa-node
type: string
type: object
kubeletDiskType:
description: 'KubeletDiskType specifies the kubelet disk type. Default
to OS. Possible values include: ''OS'', ''Temporary''. Requires
kubeletDisk preview feature to be set.'
enum:
- OS
- Temporary
type: string
maxPods:
description: MaxPods specifies the kubelet --max-pods configuration
for the node pool.
Expand Down
24 changes: 24 additions & 0 deletions docs/book/src/topics/managedcluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,30 @@ spec:
osDiskType: "Ephemeral"
```

## AKS Node Pool KubeletDiskType configuration

You can configure the `KubeletDiskType` value for each AKS node pool (`AzureManagedMachinePool`) that you define in your spec (see [here](https://learn.microsoft.com/en-us/rest/api/aks/agent-pools/create-or-update?tabs=HTTP#kubeletdisktype) for the official AKS documentation). There are two options to choose from: `"OS"` or `"Temporary"`.

Before this feature can be used, you must register the `KubeletDisk` feature on your Azure subscription with the following az cli command.

```bash
az feature register --namespace Microsoft.ContainerService --name KubeletDisk
```

Below an example `kubeletDiskType` configuration is assigned to `agentpool0`, specifying that the emptyDir volumes, container runtime data root, and Kubelet ephemeral storage will be stored on the temporary disk:

```yaml
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
metadata:
name: agentpool0
spec:
mode: System
osDiskSizeGB: 30
sku: Standard_D2s_v3
kubeletDiskType: "Temporary"
```

### AKS Node Pool Taints

You can configure the `Taints` value for each AKS node pool (`AzureManagedMachinePool`) that you define in your spec.
Expand Down
1 change: 1 addition & 0 deletions exp/api/v1alpha3/azuremanagedmachinepool_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (src *AzureManagedMachinePool) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.NodePublicIPPrefixID = restored.Spec.NodePublicIPPrefixID
dst.Spec.ScaleSetPriority = restored.Spec.ScaleSetPriority
dst.Spec.AdditionalTags = restored.Spec.AdditionalTags
dst.Spec.KubeletDiskType = restored.Spec.KubeletDiskType
if restored.Spec.KubeletConfig != nil {
dst.Spec.KubeletConfig = restored.Spec.KubeletConfig
}
Expand Down
1 change: 1 addition & 0 deletions exp/api/v1alpha3/zz_generated.conversion.go

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

1 change: 1 addition & 0 deletions exp/api/v1alpha4/azuremanagedmachinepool_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (src *AzureManagedMachinePool) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.NodePublicIPPrefixID = restored.Spec.NodePublicIPPrefixID
dst.Spec.ScaleSetPriority = restored.Spec.ScaleSetPriority
dst.Spec.AdditionalTags = restored.Spec.AdditionalTags
dst.Spec.KubeletDiskType = restored.Spec.KubeletDiskType
if restored.Spec.KubeletConfig != nil {
dst.Spec.KubeletConfig = restored.Spec.KubeletConfig
}
Expand Down
1 change: 1 addition & 0 deletions exp/api/v1alpha4/zz_generated.conversion.go

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

6 changes: 6 additions & 0 deletions exp/api/v1beta1/azuremanagedmachinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ type AzureManagedMachinePoolSpec struct {
// KubeletConfig specifies the kubelet configurations for nodes.
// +optional
KubeletConfig *KubeletConfig `json:"kubeletConfig,omitempty"`

// KubeletDiskType specifies the kubelet disk type. Default to OS. Possible values include: 'OS', 'Temporary'.
// Requires kubeletDisk preview feature to be set.
// +kubebuilder:validation:Enum=OS;Temporary
// +optional
KubeletDiskType *string `json:"kubeletDiskType,omitempty"`
}

// ManagedMachinePoolScaling specifies scaling options.
Expand Down
7 changes: 7 additions & 0 deletions exp/api/v1beta1/azuremanagedmachinepool_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ func (m *AzureManagedMachinePool) ValidateUpdate(oldRaw runtime.Object, client c
allErrs = append(allErrs, err)
}

if err := webhookutils.ValidateImmutable(
field.NewPath("Spec", "KubeletDiskType"),
old.Spec.KubeletDiskType,
m.Spec.KubeletDiskType); err != nil {
allErrs = append(allErrs, err)
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedMachinePool").GroupKind(), m.Name, allErrs)
}
Expand Down
5 changes: 5 additions & 0 deletions exp/api/v1beta1/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 68f0198

Please sign in to comment.