kubernetes/kops · error
cluster is not an Azure cluster
Error message
cluster is not an Azure cluster
What it means
BuildCloudConfig validates that cluster.Spec.CloudProvider.Azure is non-nil before assembling the Azure cloud-controller-manager/CSI cloud-config. It throws "cluster is not an Azure cluster" when the cluster's cloudProvider block targets another provider (AWS, GCP, etc.) or is absent, so there is no Azure configuration to publish into the azure-cloud-provider Secret.
Source
Thrown at upup/pkg/fi/cloudup/azure/cloudconfig.go:52
// Cluster config
ResourceGroup string `json:"resourceGroup,omitempty"`
Location string `json:"location,omitempty"`
VnetName string `json:"vnetName,omitempty"`
SubnetName string `json:"subnetName,omitempty"`
RouteTableName string `json:"routeTableName,omitempty"`
SecurityGroupName string `json:"securityGroupName,omitempty"`
UseInstanceMetadata bool `json:"useInstanceMetadata,omitempty"`
DisableAvailabilitySetNodes bool `json:"disableAvailabilitySetNodes,omitempty"`
}
// BuildCloudConfig assembles the Azure cloud provider configuration for a
// cluster. kOps publishes the result in the azure-cloud-provider Secret, which
// the cloud-controller-manager and CSI drivers load via the
// --cloud-config-secret-name flag.
func BuildCloudConfig(cluster *kops.Cluster) (*CloudConfig, error) {
azure := cluster.Spec.CloudProvider.Azure
if azure == nil {
return nil, fmt.Errorf("cluster is not an Azure cluster")
}
subnets := cluster.Spec.Networking.Subnets
if len(subnets) == 0 {
return nil, fmt.Errorf("cluster has no subnets")
}
// In kOps the virtual network and the network security group share a name.
networkName := cluster.AzureNetworkSecurityGroupName()
return &CloudConfig{
TenantID: azure.TenantID,
SubscriptionID: azure.SubscriptionID,
UseManagedIdentityExtension: true,
ResourceGroup: cluster.AzureResourceGroupName(),
Location: subnets[0].Region,
VnetName: networkName,
SubnetName: subnets[0].Name,View on GitHub (pinned to 4c8573c808)
Solutions
- Ensure the cluster spec actually sets cloudProvider: azure (kops edit cluster / spec file) before building Azure cloud config
- Route BuildCloudConfig only from Azure-specific code paths; guard generic callers with a cloudProvider check
- Verify you are operating on the intended cluster manifest (right --name / state store)
- Check that the CloudProvider field is populated after loading/validating the cluster (apply defaulting/validation if constructing specs programmatically)
Example fix
// before
BuildCloudConfig(awsCluster) // panics path: azure == nil -> error
// after
if cluster.Spec.CloudProvider.Azure != nil {
cfg, err := BuildCloudConfig(cluster)
...
} Defensive patterns
Strategy: validation
Validate before calling
// Guard the call site: only build Azure cloud config for Azure clusters
if cluster.Spec.CloudProvider.Azure == nil {
return nil // or use the provider-appropriate cloud config builder
}
cfg, err := BuildCloudConfig(cluster)
if err != nil { return err } Type guard
func isAzureCluster(c *kops.Cluster) bool {
return c != nil && c.Spec.CloudProvider.Azure != nil
} Prevention
- Dispatch cloud-config building on cluster.Spec.CloudProvider type instead of hardcoding Azure
- Validate cluster specs (kops toolkit validate) so cloudProvider is always set before rendering
- Keep one cluster manifest per operation; verify --name/state store target the right cluster
- When constructing kops.Cluster programmatically, always populate CloudProvider before calling builders
When it happens
Trigger: BuildCloudConfig(cluster) called during cluster rendering (via AzureCloudConfig or an anonymous builder hook) on a kops.Cluster whose Spec.CloudProvider.Azure is nil — i.e. the cluster spec has no Azure cloud provider section.
Common situations: Calling an Azure-only build path on an AWS/GCP/DigitalOcean cluster; a cluster spec missing the cloudProvider block entirely; wiring a generic cloudconfig builder to the Azure implementation; tooling/scripts invoking BuildCloudConfig directly with the wrong cluster manifest.
Related errors
- cluster has no subnets
- unknown CloudProvider %q
- DNS not implemented on azureCloud
- --azure-subscription-id is required
- error populating configuration: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/a2287f4e791c86ac.
Report an issue: GitHub.