XVirtualMachine¶
Experimental
This API is experimental and may change without notice.
A Linux or Windows virtual machine with its network interface, attached to an existing virtual network subnet.
API¶
| Group | azure.platform.example.org |
| Kind | XVirtualMachine |
| Plural | xvirtualmachines |
| Scope | Namespaced |
| Versions | v1alpha1 (referenceable) |
| Source | compositions/azure/virtualmachine/xrd.yaml |
Spec¶
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name immutable |
string |
yes | — | Name of the virtual machine. Constraints: maxLength: 12. |
os |
string |
yes | — | Operating system: linux installs the latest AlmaLinux, windows installs the latest Windows Server. One of: linux, windows. |
size |
string |
no | small |
T-shirt size: small = 2 vCPU, medium = 4 vCPU, large = 8 vCPU. One of: small, medium, large. |
resourceGroupRef |
object |
yes | — | Resource group hosting the virtual machine. |
resourceGroupRef.name |
string |
yes | — | Logical name of the XResourceGroup. |
virtualNetworkRef |
object |
yes | — | Virtual network and subnet hosting the NIC. |
virtualNetworkRef.name |
string |
yes | — | Logical name of the XVirtualNetwork. |
virtualNetworkRef.subnet |
string |
yes | — | Name of the subnet within that network. |
adminUsername |
string |
no | azureuser |
Local administrator user name. |
adminPasswordSecretRef immutable |
object |
no | — | Windows only. Secret in the same namespace holding the local administrator password. |
adminPasswordSecretRef.name |
string |
yes | — | — |
adminPasswordSecretRef.key |
string |
yes | password |
— |
sshPublicKeySecretRef immutable |
object |
no | — | Linux only. Secret in the same namespace holding the OpenSSH public key authorised for the admin user. |
sshPublicKeySecretRef.name |
string |
yes | — | — |
sshPublicKeySecretRef.key |
string |
yes | id_rsa.pub |
— |
location |
string |
no | swedencentral |
Azure region for the virtual machine. |
Fields marked immutable are fixed once the resource is created; changing one is rejected by the API server. An immutable object pins the fields nested under it too. To change one, delete the resource and create it again.
Example¶
Pick the operating system with spec.os and the sizing with the spec.size t-shirt size; the composition maps that to an Azure SKU. Linux machines authenticate with an SSH public key, Windows machines with an administrator password, each read from a Secret in the same namespace. The Azure resource is named vm-<spec.name>.
apiVersion: azure.platform.example.org/v1alpha1
kind: XVirtualMachine
metadata:
name: linuxdemo01
spec:
name: linuxdemo01
os: linux
size: small
resourceGroupRef:
name: crd-dev-virtualmachines
virtualNetworkRef:
name: crd-dev
subnet: management
sshPublicKeySecretRef:
name: linuxdemo01-ssh
key: id_ed25519.pub
Taken from teams/crd-dev/virtualmachines.yaml,
which is applied to the cluster by Flux, so it cannot drift from a working
manifest.
Status¶
Populated by Crossplane once the underlying Azure resources exist. Every
composite in this repository exposes the provisioned Azure resource ID as
status.id.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string |
no | — | Azure resource ID of the virtual machine. |
vmSize |
string |
no | — | Azure VM SKU resolved from the requested size. |
privateIp |
string |
no | — | Private IP address assigned to the NIC. |
networkInterfaceId |
string |
no | — | Azure resource ID of the network interface. |
Common problems¶
The XR is rejected on apply with "linux virtual machines require sshPublicKeySecretRef".
Cause. A CEL rule enforces that the credential reference matches spec.os.
Fix. Supply sshPublicKeySecretRef for Linux or adminPasswordSecretRef for Windows, and remove the other one.
The machine never gets an IP and the NIC stays not-Ready.
Cause. spec.virtualNetworkRef.subnet does not match any subnet name on the referenced XVirtualNetwork.
Fix. Check the subnet names in the virtual network's status.subnets.
Provisioning fails while reading the credential Secret.
Cause. The Secret does not exist in the XR's namespace, or the key does not match the key inside it.
Fix. Create the Secret first; the reference is immutable, so a wrong value means recreating the XR.
The XR is rejected because the name is too long.
Cause. spec.name is limited to 12 characters.
Fix. Shorten the name; it is immutable once set.