OpenMCF logoOpenMCF

Loading...

OpenStack Subnet

Deploys an OpenStack Neutron subnet within a network, providing IP address allocation via a CIDR block with configurable gateway, DHCP, DNS, and allocation pool settings.

What Gets Created

When you deploy an OpenStackSubnet resource, OpenMCF provisions:

  • Neutron Subnet — an openstack.networking.Subnet resource with the configured CIDR, IP version, gateway, DHCP settings, DNS nameservers, allocation pools, and tags

Prerequisites

  • OpenStack credentials configured via environment variables or OpenMCF provider config
  • An existing Neutron network — every subnet belongs to exactly one network, referenced by networkId

Quick Start

Create a file subnet.yaml:

apiVersion: openstack.openmcf.org/v1
kind: OpenStackSubnet
metadata:
  name: my-subnet
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.OpenStackSubnet.my-subnet
spec:
  networkId:
    value: "<network-uuid>"
  cidr: "192.168.1.0/24"

Deploy:

openmcf apply -f subnet.yaml

This creates a Neutron subnet named my-subnet on the specified network with a /24 CIDR, IPv4, DHCP enabled, and an auto-assigned gateway.

Configuration Reference

Required Fields

FieldTypeDescriptionValidation
networkIdStringValueOrRefID of the network this subnet belongs to. Can reference an OpenStackNetwork resource via valueFrom.Required
cidrstringIP address range in CIDR notation (e.g., 192.168.1.0/24 or 2001:db8::/64).Required. Must match CIDR format.

Optional Fields

FieldTypeDefaultDescription
ipVersionint324IP protocol version. Must be 4 (IPv4) or 6 (IPv6).
gatewayIpstringauto-assignedIP address of the subnet gateway. If omitted and noGateway is false, OpenStack assigns the first usable IP. Mutually exclusive with noGateway.
noGatewayboolfalseDisables the gateway on this subnet. Use for isolated subnets (e.g., storage networks). Mutually exclusive with gatewayIp.
enableDhcpbooltrueControls whether DHCP is enabled. When enabled, OpenStack's DHCP agent assigns IPs to ports on this subnet.
dnsNameserversstring[][]DNS server IP addresses pushed to instances via DHCP.
allocationPoolsAllocationPool[]entire CIDRSub-ranges of the CIDR from which IPs are allocated. Each pool has a start and end IP. If omitted, the entire CIDR minus gateway and broadcast addresses is used.
descriptionstring—Human-readable description visible in the OpenStack API and Horizon.
tagsstring[][]Tags for filtering and organization in the OpenStack API. Must be unique.
regionstringprovider defaultOverrides the region from the provider config for this subnet.

AllocationPool object:

FieldTypeDescriptionValidation
startstringFirst IP address in the allocation range (e.g., 192.168.1.100).Required
endstringLast IP address in the allocation range (e.g., 192.168.1.200).Required

Examples

Basic Subnet

A subnet with default settings on an existing network, suitable for development environments:

apiVersion: openstack.openmcf.org/v1
kind: OpenStackSubnet
metadata:
  name: dev-subnet
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.OpenStackSubnet.dev-subnet
spec:
  networkId:
    value: "abc12345-def6-7890-abcd-ef1234567890"
  cidr: "192.168.1.0/24"
  description: Development subnet

Subnet with DNS and Custom Gateway

A subnet referencing a managed OpenStackNetwork resource, with custom DNS servers and an explicit gateway:

apiVersion: openstack.openmcf.org/v1
kind: OpenStackSubnet
metadata:
  name: app-subnet
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: staging.OpenStackSubnet.app-subnet
spec:
  networkId:
    valueFrom:
      name: app-network
  cidr: "10.0.0.0/16"
  gatewayIp: "10.0.0.1"
  dnsNameservers:
    - "8.8.8.8"
    - "8.8.4.4"
  tags:
    - staging
    - app-tier

Full-Featured Subnet with Allocation Pools

A production subnet with allocation pools to reserve IP ranges, DNS servers, tags, and a specific region:

apiVersion: openstack.openmcf.org/v1
kind: OpenStackSubnet
metadata:
  name: prod-subnet
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.OpenStackSubnet.prod-subnet
spec:
  networkId:
    valueFrom:
      name: prod-network
  cidr: "10.100.0.0/16"
  ipVersion: 4
  gatewayIp: "10.100.0.1"
  enableDhcp: true
  dnsNameservers:
    - "10.100.0.10"
    - "8.8.8.8"
  allocationPools:
    - start: "10.100.1.0"
      end: "10.100.127.255"
    - start: "10.100.200.0"
      end: "10.100.254.255"
  description: Production application subnet with reserved ranges
  tags:
    - production
    - managed
  region: RegionOne

Stack Outputs

After deployment, the following outputs are available in status.outputs:

OutputTypeDescription
subnet_idstringUUID of the created Neutron subnet
namestringName of the subnet, derived from metadata.name
cidrstringCIDR block of the subnet
gateway_ipstringGateway IP address of the subnet (empty if noGateway was set)
network_idstringID of the parent network
regionstringOpenStack region where the subnet was created

Related Components

  • OpenStackNetwork — the parent network that this subnet belongs to
  • OpenStackRouterInterface — attaches a subnet to a router for inter-network routing
  • OpenStackLoadBalancer — places a load balancer VIP on a subnet
  • OpenStackLoadBalancerMember — registers backend members on a subnet
  • OpenStackInstance — attaches compute instances to networks via subnets

Next article

OpenStack Volume

OpenStack Volume Deploys an OpenStack Cinder block storage volume with configurable size, volume type, availability zone, and optional initialization from a Glance image, snapshot, or existing volume clone. What Gets Created When you deploy an OpenStackVolume resource, OpenMCF provisions: Cinder Block Storage Volume — an openstackblockstoragevolumev3 resource with the specified size and optional volume type. The volume can be created blank, initialized from a Glance image (bootable volume),...
Read next article
Presets
2 ready-to-deploy configurationsView presets →