:_mod-docs-content-type: PROCEDURE
[id="adopting-the-loadbalancer-service_{context}"]

= Adopting the {loadbalancer_service}

[role="_abstract"]
To adopt the {loadbalancer_first_ref}, you patch an existing `OpenStackControlPlane` custom resource (CR) where the {loadbalancer_service} is disabled. The patch starts the service with the configuration parameters that are provided by the {rhos_prev_long} ({OpenStackShort}) environment. After completing the data plane adoption, you must trigger a failover of existing load balancers to upgrade their amphora virtual machines to use the new image and to establish connectivity with the new control plane.

.Procedure

. Migrate the server certificate authority (CA) passphrase from the previous deployment:
+
----
include::../../tests/roles/octavia_adoption/tasks/octavia_certs.yaml[lines="6..16",indent=0]
----

. To isolate the management network, add the network interface for the VLAN base interface:
+
[subs="+quotes"]
----
$ oc get --no-headers nncp | cut -f 1 -d ' ' | grep -v nncp-dns | while read; do

interfaces=$(oc get nncp $REPLY -o jsonpath="{.spec.desiredState.interfaces[*].name}")

(echo $interfaces | grep -w -q "octbr\|enp6s0.24") || \
        oc patch nncp $REPLY --type json --patch '
[{
    "op": "add",
    "path": "/spec/desiredState/interfaces/-",
    "value": {
      "description": "Octavia VLAN host interface",
      "name": "enp6s0.24",
      "state": "up",
      "type": "vlan",
      "vlan": {
        "base-iface": "<enp6s0>",
        "id": 24
        }
    }
},
{
    "op": "add",
    "path": "/spec/desiredState/interfaces/-",
    "value": {
      "description": "Octavia Bridge",
      "mtu": <mtu>,
      "state": "up",
      "type": "linux-bridge",
      "name": "octbr",
      "bridge": {
        "options": { "stp": { "enabled": "false" } },
        "port": [ { "name": "enp6s0.24" } ]
        }
    }
}]'

done
----
+
where:

<enp6s0>::
Specifies the name of the network interface in your {OpenShiftShort} setup.
<mtu>::
Specifies the `mtu` value in your environment.

. To connect pods that manage load balancer virtual machines (amphorae) and the OpenvSwitch pods the OVN operator manages, configure the {loadbalancer_service} network attachment definition:
+
----
$ cat  octavia-nad.yaml << EOF_CAT
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  labels:
    osp/net: octavia
  name: octavia
spec:
  config: |
    {
      "cniVersion": "0.3.1",
      "name": "octavia",
      "type": "bridge",
      "bridge": "octbr",
      "ipam": {
        "type": "whereabouts",
        "range": "172.23.0.0/24",
        "range_start": "172.23.0.30",
        "range_end": "172.23.0.70",
        "routes": [
           {
             "dst": "172.24.0.0/16",
             "gw" : "172.23.0.150"
           }
         ]
      }
    }
EOF_CAT
----

. Create the `NetworkAttachmentDefinition` CR:
+
----
$ oc apply -f octavia-nad.yaml
----

. Enable the {loadbalancer_service} in {OpenShiftShort}:
+
----
$ oc patch openstackcontrolplane openstack --type=merge --patch '
spec:
  ovn:
    template:
      ovnController:
        networkAttachment: tenant
        nicMappings:
          octavia: octbr
  octavia:
    enabled: true
    template:
      amphoraImageContainerImage: quay.io/gthiemonge/octavia-amphora-image
      octaviaHousekeeping:
        networkAttachments:
          - octavia
      octaviaHealthManager:
        networkAttachments:
          - octavia
      octaviaWorker:
        networkAttachments:
          - octavia
'
----

. Wait for the {loadbalancer_service} control plane services CRs to be ready:
+
----
$ oc wait --for condition=Ready --timeout=600s octavia.octavia.openstack.org/octavia
----

. Ensure that the {loadbalancer_service} is registered in the {identity_service}:
+
----
$ alias openstack="oc exec -t openstackclient -- openstack"
$ openstack service list | grep load-balancer
| bd078ca6f90c4b86a48801f45eb6f0d7 | octavia   | load-balancer |
$ openstack endpoint list --service load-balancer
+----------------------------------+-----------+--------------+---------------+---------+-----------+---------------------------------------------------+
| ID                               | Region    | Service Name | Service Type  | Enabled | Interface | URL                                               |
+----------------------------------+-----------+--------------+---------------+---------+-----------+---------------------------------------------------+
| f1ae7756b6164baf9cb82a1a670067a2 | regionOne | octavia      | load-balancer | True    | public    | https://octavia-public-openstack.apps-crc.testing |
| ff3222b4621843669e89843395213049 | regionOne | octavia      | load-balancer | True    | internal  | http://octavia-internal.openstack.svc:9876        |
+----------------------------------+-----------+--------------+---------------+---------+-----------+---------------------------------------------------+
----

.Next steps

After you complete the data plane adoption, you must upgrade existing load balancers and remove old resources. For more information, see xref:performing-post-adoption-cleanup-of-load-balancers_data-plane[Post-adoption tasks for the {loadbalancer_service}].
