Skip to content

Commit

Permalink
Add DisableBootstrappingVMExtension field
Browse files Browse the repository at this point in the history
  • Loading branch information
RadekManak committed May 3, 2024
1 parent 39189af commit 8d4749a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api/v1beta1/azuremachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ type AzureMachineSpec struct {
// +optional
DNSServers []string `json:"dnsServers,omitempty"`

// DisableBootstrappingVMExtension disables CAPZ Bootstrapping VM extension.
// Its role is to detect and report Kubernetes bootstrap failure or success.
// Use this setting if VMExtensions are not supported by your image.
// +optional
DisableBootstrappingVMExtension *bool `json:"disableBootstrappingVMExtension,omitempty"`

// VMExtensions specifies a list of extensions to be added to the virtual machine.
// +optional
VMExtensions []VMExtension `json:"vmExtensions,omitempty"`
Expand Down
5 changes: 5 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.

6 changes: 5 additions & 1 deletion azure/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,11 @@ func (m *MachineScope) VMExtensionSpecs() []azure.ResourceSpecGetter {
}

cpuArchitectureType, _ := m.cache.VMSKU.GetCapability(resourceskus.CPUArchitectureType)
bootstrapExtensionSpec := azure.GetBootstrappingVMExtension(m.AzureMachine.Spec.OSDisk.OSType, m.CloudEnvironment(), m.Name(), cpuArchitectureType)

var bootstrapExtensionSpec *azure.ExtensionSpec
if !ptr.Deref(m.AzureMachine.Spec.DisableBootstrappingVMExtension, false) {
bootstrapExtensionSpec = azure.GetBootstrappingVMExtension(m.AzureMachine.Spec.OSDisk.OSType, m.CloudEnvironment(), m.Name(), cpuArchitectureType)
}

if bootstrapExtensionSpec != nil {
extensionSpecs = append(extensionSpecs, &vmextensions.VMExtensionSpec{
Expand Down
38 changes: 38 additions & 0 deletions azure/scope/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,44 @@ func TestMachineScope_VMExtensionSpecs(t *testing.T) {
},
},
},
{
name: "If OS type is Linux and cloud is AzurePublicCloud and DisableBootstrappingVMExtension is true, it returns empty",
machineScope: MachineScope{
Machine: &clusterv1.Machine{},
AzureMachine: &infrav1.AzureMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "machine-name",
},
Spec: infrav1.AzureMachineSpec{
DisableBootstrappingVMExtension: ptr.To(true),
OSDisk: infrav1.OSDisk{
OSType: "Linux",
},
},
},
ClusterScoper: &ClusterScope{
AzureClients: AzureClients{
EnvironmentSettings: auth.EnvironmentSettings{
Environment: azureautorest.Environment{
Name: azureautorest.PublicCloud.Name,
},
},
},
AzureCluster: &infrav1.AzureCluster{
Spec: infrav1.AzureClusterSpec{
ResourceGroup: "my-rg",
AzureClusterClassSpec: infrav1.AzureClusterClassSpec{
Location: "westus",
},
},
},
},
cache: &MachineCache{
VMSKU: resourceskus.SKU{},
},
},
want: []azure.ResourceSpecGetter{},
},
{
name: "If OS type is Linux and cloud is not AzurePublicCloud, it returns empty",
machineScope: MachineScope{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ spec:
- storageAccountType
type: object
type: object
disableBootstrappingVMExtension:
description: |-
DisableBootstrappingVMExtension disables CAPZ Bootstrapping VM extension.
Its role is to detect and report Kubernetes bootstrap failure or success.
Use this setting if VMExtensions are not supported by your image.
type: boolean
dnsServers:
description: DNSServers adds a list of DNS Server IP addresses to
the VM NICs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ spec:
- storageAccountType
type: object
type: object
disableBootstrappingVMExtension:
description: |-
DisableBootstrappingVMExtension disables CAPZ Bootstrapping VM extension.
Its role is to detect and report Kubernetes bootstrap failure or success.
Use this setting if VMExtensions are not supported by your image.
type: boolean
dnsServers:
description: DNSServers adds a list of DNS Server IP addresses
to the VM NICs.
Expand Down

0 comments on commit 8d4749a

Please sign in to comment.