Skip to content

Commit

Permalink
Merge pull request #318 from gthiemonge/fix-nad
Browse files Browse the repository at this point in the history
Use NAD parameters to configure the Octavia resources
  • Loading branch information
openshift-merge-bot[bot] authored Jun 10, 2024
2 parents 3a1a634 + d6ba3b2 commit 2992026
Show file tree
Hide file tree
Showing 17 changed files with 433 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down
29 changes: 24 additions & 5 deletions api/bases/octavia.openstack.org_octavias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ spec:
lbMgmtNetwork:
default:
manageLbMgmtNetworks: true
subnetIpVersion: 4
description: OctaviaLbMgmtNetworks Settings for Octavia management
networks
properties:
Expand All @@ -116,10 +115,6 @@ spec:
manageLbMgmtNetworks:
default: true
type: boolean
subnetIpVersion:
default: 4
description: IP Version of the managed subnets
type: integer
type: object
nodeSelector:
additionalProperties:
Expand Down Expand Up @@ -585,6 +580,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down Expand Up @@ -780,6 +781,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down Expand Up @@ -892,6 +899,11 @@ spec:
- secret
- serviceAccount
type: object
octaviaNetworkAttachment:
default: octavia
description: OctaviaNetworkAttachment is a NetworkAttachment resource
name for the Octavia Management Network
type: string
octaviaWorker:
description: OctaviaHousekeeping - Spec definition for the Octavia
Housekeeping agent for the Octavia deployment
Expand Down Expand Up @@ -975,6 +987,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down Expand Up @@ -1197,6 +1215,7 @@ spec:
- apacheContainerImage
- databaseInstance
- octaviaAPI
- octaviaNetworkAttachment
- rabbitMqClusterName
- secret
type: object
Expand Down
8 changes: 8 additions & 0 deletions api/v1beta1/amphoracontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ type OctaviaAmphoraControllerSpecCore struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.Ca `json:"tls,omitempty"`

// +kubebuilder:validation:Optional
// OctaviaProviderSubnetGateway -
OctaviaProviderSubnetGateway string `json:"octaviaProviderSubnetGateway"`

// +kubebuilder:validation:Optional
// OctaviaProviderSubnetCIDR -
OctaviaProviderSubnetCIDR string `json:"octaviaProviderSubnetCIDR"`
}

// OctaviaAmphoraControllerStatus defines the observed state of the Octavia Amphora Controller
Expand Down
12 changes: 6 additions & 6 deletions api/v1beta1/octavia_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ type OctaviaSpecBase struct {
TenantName string `json:"tenantName"`

// +kubebuilder:validation:Optional
// +kubebuilder:default={manageLbMgmtNetworks: true, subnetIpVersion: 4}
// +kubebuilder:default={manageLbMgmtNetworks: true}
LbMgmtNetworks OctaviaLbMgmtNetworks `json:"lbMgmtNetwork"`

// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -192,6 +192,11 @@ type OctaviaSpecBase struct {
// +kubebuilder:validation:Required
// Apache Container Image URL
ApacheContainerImage string `json:"apacheContainerImage"`

// +kubebuilder:validation:Required
// +kubebuilder:default=octavia
// OctaviaNetworkAttachment is a NetworkAttachment resource name for the Octavia Management Network
OctaviaNetworkAttachment string `json:"octaviaNetworkAttachment"`
}

// PasswordSelector to identify the DB and AdminUser password from the Secret
Expand All @@ -213,11 +218,6 @@ type OctaviaLbMgmtNetworks struct {
// +kubebuilder:default=true
ManageLbMgmtNetworks bool `json:"manageLbMgmtNetworks,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=4
// IP Version of the managed subnets
SubnetIPVersion int `json:"subnetIpVersion,omitempty"`

// +kubebuilder:validation:Optional
// Availability zones for the octavia management network resources
AvailabilityZones []string `json:"availabilityZones,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down
29 changes: 24 additions & 5 deletions config/crd/bases/octavia.openstack.org_octavias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ spec:
lbMgmtNetwork:
default:
manageLbMgmtNetworks: true
subnetIpVersion: 4
description: OctaviaLbMgmtNetworks Settings for Octavia management
networks
properties:
Expand All @@ -116,10 +115,6 @@ spec:
manageLbMgmtNetworks:
default: true
type: boolean
subnetIpVersion:
default: 4
description: IP Version of the managed subnets
type: integer
type: object
nodeSelector:
additionalProperties:
Expand Down Expand Up @@ -585,6 +580,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down Expand Up @@ -780,6 +781,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down Expand Up @@ -892,6 +899,11 @@ spec:
- secret
- serviceAccount
type: object
octaviaNetworkAttachment:
default: octavia
description: OctaviaNetworkAttachment is a NetworkAttachment resource
name for the Octavia Management Network
type: string
octaviaWorker:
description: OctaviaHousekeeping - Spec definition for the Octavia
Housekeeping agent for the Octavia deployment
Expand Down Expand Up @@ -975,6 +987,12 @@ spec:
description: NodeSelector to target subset of worker nodes running
this service
type: object
octaviaProviderSubnetCIDR:
description: OctaviaProviderSubnetCIDR -
type: string
octaviaProviderSubnetGateway:
description: OctaviaProviderSubnetGateway -
type: string
passwordSelectors:
default:
service: OctaviaPassword
Expand Down Expand Up @@ -1197,6 +1215,7 @@ spec:
- apacheContainerImage
- databaseInstance
- octaviaAPI
- octaviaNetworkAttachment
- rabbitMqClusterName
- secret
type: object
Expand Down
13 changes: 13 additions & 0 deletions controllers/octavia_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,24 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav
// Amphora reconciliation
// ------------------------------------------------------------------------------------------------------------

nad, err := nad.GetNADWithName(ctx, helper, instance.Spec.OctaviaNetworkAttachment, instance.Namespace)
if err != nil {
return ctrl.Result{}, err
}

networkParameters, err := octavia.GetNetworkParametersFromNAD(nad)
if err != nil {
return ctrl.Result{}, err
}

// Create load balancer management network and get its Id (networkInfo is actually a struct and contains
// multiple details.
networkInfo, err := octavia.EnsureAmphoraManagementNetwork(
ctx,
instance.Namespace,
instance.Spec.TenantName,
&instance.Spec.LbMgmtNetworks,
networkParameters,
&Log,
helper,
)
Expand Down Expand Up @@ -1322,6 +1333,8 @@ func (r *OctaviaReconciler) amphoraControllerDaemonSetCreateOrUpdate(
daemonset.Spec.AmphoraCustomFlavors = instance.Spec.AmphoraCustomFlavors
daemonset.Spec.TLS = instance.Spec.OctaviaAPI.TLS.Ca
daemonset.Spec.AmphoraImageOwnerID = ampImageOwnerID
daemonset.Spec.OctaviaProviderSubnetGateway = networkInfo.ManagementSubnetGateway
daemonset.Spec.OctaviaProviderSubnetCIDR = networkInfo.ManagementSubnetCIDR
if len(daemonset.Spec.NodeSelector) == 0 {
daemonset.Spec.NodeSelector = instance.Spec.NodeSelector
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/amphoracontrollers/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func DaemonSet(
envVars["KOLLA_CONFIG_STRATEGY"] = env.SetValue("COPY_ALWAYS")
envVars["CONFIG_HASH"] = env.SetValue(configHash)

envVars["MGMT_CIDR"] = env.SetValue(instance.Spec.OctaviaProviderSubnetCIDR)
envVars["MGMT_GATEWAY"] = env.SetValue(instance.Spec.OctaviaProviderSubnetGateway)

// Add the CA bundle
if instance.Spec.TLS.CaBundleSecretName != "" {
volumes = append(volumes, instance.Spec.TLS.CreateVolume())
Expand Down
Loading

0 comments on commit 2992026

Please sign in to comment.