Request a static IP address for a machine

Experimental

Warning

The staticIPRequest option described in this section is under development and is considered experimental. The API and behavior may change in future releases. It is intended only for testing and evaluation purposes on staging clusters. Do not use it for production deployments.

When you create a Machine object, you can request a specific IPv4 address from a selected cluster subnet using the staticIPRequest field. IPAM assigns that IP address to the machine instead of allocating the next free IP address from the subnet range.

The staticIPRequest field is intended only for adding or replacing one machine at a time. The target use case is the replacement of a single Ceph Monitor node: OpenStack instances that boot from a Ceph RBD image or volume store the Ceph Monitor IP addresses and keep using them for as long as the instance exists.

Note

You can set staticIPRequest only through the management API or CLI. The MOSK management console does not expose this field.

Why Ceph Monitor IP addresses must stay stable

Each Ceph Monitor daemon uses a fixed IP address. In production deployments, that address is defined by the monitorIP value of the corresponding node in the CephDeployment object and belongs to the Ceph public network. For details, see Add a Ceph cluster and Nodes parameters.

The OpenStack Compute and Block Storage services pass these Monitor IP addresses to instances that use Ceph RBD, including instances booted from a volume. The IP addresses become part of the instance connection configuration. If you later replace a Monitor node and the new machine receives a different IP address, existing instances keep the old Monitor IP address and lose access to their disks until you reconfigure them.

Requesting the previous Monitor IP address for the new machine avoids that reconfiguration. After the old machine is deleted and its address is released, the new machine obtains the same IP address, and you set the same monitorIP in CephDeployment.

Requirements

  • The requested address must be unused. Delete the old machine and wait until IPAM releases the address before you create the new machine.

  • The requested address must belong to the subnet CIDR and to one of the includeRanges values of the Subnet object. For the range format, see API Reference: Subnet resource.

  • The target subnet must be present in the L2 template that IPAM renders for the machine.

Limitations

  • IPAM copies staticIPRequest to the corresponding IpamHost object only when that object is created. Later edits of staticIPRequest on an existing Machine object have no effect. This behavior matches that of l2TemplateIfMappingOverride. For details, see Override network interfaces naming and order.

  • If IPAM cannot satisfy the request, machine provisioning does not complete until you correct the request or release the address.

  • Create and replace only one machine with staticIPRequest at a time. Do not use this field to add several nodes with static addresses in one operation.

Request a static IP address when creating a machine

  1. Identify the Subnet object that must provide the IP address. For a Ceph Monitor, use the subnet of the Ceph public network that you set in publicNet of CephDeployment.

    kubectl --kubeconfig <pathToManagementClusterKubeconfig> -n <projectName> get subnet
    
  2. Verify that the requested IP address is not allocated:

    kubectl --kubeconfig <pathToManagementClusterKubeconfig> -n <projectName> get ipaddr -o wide
    
  3. While creating the Machine object as described in Create a machine using CLI, add staticIPRequest to spec.providerSpec.value. For example:

    apiVersion: cluster.k8s.io/v1alpha1
    kind: Machine
    metadata:
      name: <machineName>
      namespace: <projectName>
      labels:
        kaas.mirantis.com/provider: baremetal
        cluster.sigs.k8s.io/cluster-name: <clusterName>
    spec:
      providerSpec:
        value:
          apiVersion: baremetal.k8s.io/v1alpha1
          kind: BareMetalMachineProviderSpec
          bareMetalHostProfile:
            name: <hostProfileName>
            namespace: <projectName>
          l2TemplateSelector:
            name: <l2TemplateName>
          staticIPRequest:
          - scope: namespace
            subnetName: <cephPublicSubnetName>
            ipaddr: <cephMonitorIP>
    

    For a description of the staticIPRequest fields, see API Reference: Machine resource.

    Identify the subnet by name or by labels. Do not mix the two methods in one request item: if labelSelector is set, IPAM matches the subnet by labels and ignores subnetName.

    Note

    You can add several staticIPRequest list items to request IP addresses from different subnets.

  4. Apply the Machine object:

    kubectl --kubeconfig <pathToManagementClusterKubeconfig> create -f <pathToMachineFile>
    
  5. Verify that IPAM allocated the requested IP address:

    kubectl --kubeconfig <pathToManagementClusterKubeconfig> -n <projectName> get ipaddr -o wide
    

    The IPaddr object that belongs to the new machine must contain the requested IP address in status.

Keep the Ceph Monitor IP address when replacing a node

This procedure follows the standard Monitor migration flow described in Move Ceph Monitor before node replacement, adding the steps that preserve the Ceph Monitor IP address.

To keep the existing Ceph Monitor IP address on a new node:

  1. Capture the current Monitor IP address from spec.nodes of the CephDeployment object. Use the monitorIP value of the node that you will replace.

    kubectl --kubeconfig <pathToMOSKClusterKubeconfig> -n ceph-lcm-mirantis get cephdeployment -o yaml
    
  2. Move the Ceph Monitor (and Manager, if colocated) off the affected node and delete that node as described in Move Ceph Monitor before node replacement.

  3. Wait until IPAM releases the captured IP address. The address must no longer appear in the IPaddr list of the cluster project:

    kubectl --kubeconfig <pathToManagementClusterKubeconfig> -n <projectName> get ipaddr -o wide
    

    Caution

    If the previous Monitor IP address is still allocated, IPAM rejects the static IP request.

  4. Add the new machine with staticIPRequest set to the captured IP address from the Ceph public network subnet. For the procedure, see Request a static IP address when creating a machine.

  5. After the new node is Ready, set the same monitorIP on the new node in CephDeployment and move the Monitor daemon to that node as described in Move a Ceph Monitor daemon to another node.