Skip to content

Commit 2992026

Browse files
Merge pull request #318 from gthiemonge/fix-nad
Use NAD parameters to configure the Octavia resources
2 parents 3a1a634 + d6ba3b2 commit 2992026

17 files changed

+433
-132
lines changed

api/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ spec:
127127
description: NodeSelector to target subset of worker nodes running
128128
this service
129129
type: object
130+
octaviaProviderSubnetCIDR:
131+
description: OctaviaProviderSubnetCIDR -
132+
type: string
133+
octaviaProviderSubnetGateway:
134+
description: OctaviaProviderSubnetGateway -
135+
type: string
130136
passwordSelectors:
131137
default:
132138
service: OctaviaPassword

api/bases/octavia.openstack.org_octavias.yaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ spec:
103103
lbMgmtNetwork:
104104
default:
105105
manageLbMgmtNetworks: true
106-
subnetIpVersion: 4
107106
description: OctaviaLbMgmtNetworks Settings for Octavia management
108107
networks
109108
properties:
@@ -116,10 +115,6 @@ spec:
116115
manageLbMgmtNetworks:
117116
default: true
118117
type: boolean
119-
subnetIpVersion:
120-
default: 4
121-
description: IP Version of the managed subnets
122-
type: integer
123118
type: object
124119
nodeSelector:
125120
additionalProperties:
@@ -585,6 +580,12 @@ spec:
585580
description: NodeSelector to target subset of worker nodes running
586581
this service
587582
type: object
583+
octaviaProviderSubnetCIDR:
584+
description: OctaviaProviderSubnetCIDR -
585+
type: string
586+
octaviaProviderSubnetGateway:
587+
description: OctaviaProviderSubnetGateway -
588+
type: string
588589
passwordSelectors:
589590
default:
590591
service: OctaviaPassword
@@ -780,6 +781,12 @@ spec:
780781
description: NodeSelector to target subset of worker nodes running
781782
this service
782783
type: object
784+
octaviaProviderSubnetCIDR:
785+
description: OctaviaProviderSubnetCIDR -
786+
type: string
787+
octaviaProviderSubnetGateway:
788+
description: OctaviaProviderSubnetGateway -
789+
type: string
783790
passwordSelectors:
784791
default:
785792
service: OctaviaPassword
@@ -892,6 +899,11 @@ spec:
892899
- secret
893900
- serviceAccount
894901
type: object
902+
octaviaNetworkAttachment:
903+
default: octavia
904+
description: OctaviaNetworkAttachment is a NetworkAttachment resource
905+
name for the Octavia Management Network
906+
type: string
895907
octaviaWorker:
896908
description: OctaviaHousekeeping - Spec definition for the Octavia
897909
Housekeeping agent for the Octavia deployment
@@ -975,6 +987,12 @@ spec:
975987
description: NodeSelector to target subset of worker nodes running
976988
this service
977989
type: object
990+
octaviaProviderSubnetCIDR:
991+
description: OctaviaProviderSubnetCIDR -
992+
type: string
993+
octaviaProviderSubnetGateway:
994+
description: OctaviaProviderSubnetGateway -
995+
type: string
978996
passwordSelectors:
979997
default:
980998
service: OctaviaPassword
@@ -1197,6 +1215,7 @@ spec:
11971215
- apacheContainerImage
11981216
- databaseInstance
11991217
- octaviaAPI
1218+
- octaviaNetworkAttachment
12001219
- rabbitMqClusterName
12011220
- secret
12021221
type: object

api/v1beta1/amphoracontroller_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ type OctaviaAmphoraControllerSpecCore struct {
143143
// +operator-sdk:csv:customresourcedefinitions:type=spec
144144
// TLS - Parameters related to the TLS
145145
TLS tls.Ca `json:"tls,omitempty"`
146+
147+
// +kubebuilder:validation:Optional
148+
// OctaviaProviderSubnetGateway -
149+
OctaviaProviderSubnetGateway string `json:"octaviaProviderSubnetGateway"`
150+
151+
// +kubebuilder:validation:Optional
152+
// OctaviaProviderSubnetCIDR -
153+
OctaviaProviderSubnetCIDR string `json:"octaviaProviderSubnetCIDR"`
146154
}
147155

148156
// OctaviaAmphoraControllerStatus defines the observed state of the Octavia Amphora Controller

api/v1beta1/octavia_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ type OctaviaSpecBase struct {
160160
TenantName string `json:"tenantName"`
161161

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

166166
// +kubebuilder:validation:Optional
@@ -192,6 +192,11 @@ type OctaviaSpecBase struct {
192192
// +kubebuilder:validation:Required
193193
// Apache Container Image URL
194194
ApacheContainerImage string `json:"apacheContainerImage"`
195+
196+
// +kubebuilder:validation:Required
197+
// +kubebuilder:default=octavia
198+
// OctaviaNetworkAttachment is a NetworkAttachment resource name for the Octavia Management Network
199+
OctaviaNetworkAttachment string `json:"octaviaNetworkAttachment"`
195200
}
196201

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

216-
// +kubebuilder:validation:Optional
217-
// +kubebuilder:default=4
218-
// IP Version of the managed subnets
219-
SubnetIPVersion int `json:"subnetIpVersion,omitempty"`
220-
221221
// +kubebuilder:validation:Optional
222222
// Availability zones for the octavia management network resources
223223
AvailabilityZones []string `json:"availabilityZones,omitempty"`

config/crd/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ spec:
127127
description: NodeSelector to target subset of worker nodes running
128128
this service
129129
type: object
130+
octaviaProviderSubnetCIDR:
131+
description: OctaviaProviderSubnetCIDR -
132+
type: string
133+
octaviaProviderSubnetGateway:
134+
description: OctaviaProviderSubnetGateway -
135+
type: string
130136
passwordSelectors:
131137
default:
132138
service: OctaviaPassword

config/crd/bases/octavia.openstack.org_octavias.yaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ spec:
103103
lbMgmtNetwork:
104104
default:
105105
manageLbMgmtNetworks: true
106-
subnetIpVersion: 4
107106
description: OctaviaLbMgmtNetworks Settings for Octavia management
108107
networks
109108
properties:
@@ -116,10 +115,6 @@ spec:
116115
manageLbMgmtNetworks:
117116
default: true
118117
type: boolean
119-
subnetIpVersion:
120-
default: 4
121-
description: IP Version of the managed subnets
122-
type: integer
123118
type: object
124119
nodeSelector:
125120
additionalProperties:
@@ -585,6 +580,12 @@ spec:
585580
description: NodeSelector to target subset of worker nodes running
586581
this service
587582
type: object
583+
octaviaProviderSubnetCIDR:
584+
description: OctaviaProviderSubnetCIDR -
585+
type: string
586+
octaviaProviderSubnetGateway:
587+
description: OctaviaProviderSubnetGateway -
588+
type: string
588589
passwordSelectors:
589590
default:
590591
service: OctaviaPassword
@@ -780,6 +781,12 @@ spec:
780781
description: NodeSelector to target subset of worker nodes running
781782
this service
782783
type: object
784+
octaviaProviderSubnetCIDR:
785+
description: OctaviaProviderSubnetCIDR -
786+
type: string
787+
octaviaProviderSubnetGateway:
788+
description: OctaviaProviderSubnetGateway -
789+
type: string
783790
passwordSelectors:
784791
default:
785792
service: OctaviaPassword
@@ -892,6 +899,11 @@ spec:
892899
- secret
893900
- serviceAccount
894901
type: object
902+
octaviaNetworkAttachment:
903+
default: octavia
904+
description: OctaviaNetworkAttachment is a NetworkAttachment resource
905+
name for the Octavia Management Network
906+
type: string
895907
octaviaWorker:
896908
description: OctaviaHousekeeping - Spec definition for the Octavia
897909
Housekeeping agent for the Octavia deployment
@@ -975,6 +987,12 @@ spec:
975987
description: NodeSelector to target subset of worker nodes running
976988
this service
977989
type: object
990+
octaviaProviderSubnetCIDR:
991+
description: OctaviaProviderSubnetCIDR -
992+
type: string
993+
octaviaProviderSubnetGateway:
994+
description: OctaviaProviderSubnetGateway -
995+
type: string
978996
passwordSelectors:
979997
default:
980998
service: OctaviaPassword
@@ -1197,6 +1215,7 @@ spec:
11971215
- apacheContainerImage
11981216
- databaseInstance
11991217
- octaviaAPI
1218+
- octaviaNetworkAttachment
12001219
- rabbitMqClusterName
12011220
- secret
12021221
type: object

controllers/octavia_controller.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,24 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav
642642
// Amphora reconciliation
643643
// ------------------------------------------------------------------------------------------------------------
644644

645+
nad, err := nad.GetNADWithName(ctx, helper, instance.Spec.OctaviaNetworkAttachment, instance.Namespace)
646+
if err != nil {
647+
return ctrl.Result{}, err
648+
}
649+
650+
networkParameters, err := octavia.GetNetworkParametersFromNAD(nad)
651+
if err != nil {
652+
return ctrl.Result{}, err
653+
}
654+
645655
// Create load balancer management network and get its Id (networkInfo is actually a struct and contains
646656
// multiple details.
647657
networkInfo, err := octavia.EnsureAmphoraManagementNetwork(
648658
ctx,
649659
instance.Namespace,
650660
instance.Spec.TenantName,
651661
&instance.Spec.LbMgmtNetworks,
662+
networkParameters,
652663
&Log,
653664
helper,
654665
)
@@ -1322,6 +1333,8 @@ func (r *OctaviaReconciler) amphoraControllerDaemonSetCreateOrUpdate(
13221333
daemonset.Spec.AmphoraCustomFlavors = instance.Spec.AmphoraCustomFlavors
13231334
daemonset.Spec.TLS = instance.Spec.OctaviaAPI.TLS.Ca
13241335
daemonset.Spec.AmphoraImageOwnerID = ampImageOwnerID
1336+
daemonset.Spec.OctaviaProviderSubnetGateway = networkInfo.ManagementSubnetGateway
1337+
daemonset.Spec.OctaviaProviderSubnetCIDR = networkInfo.ManagementSubnetCIDR
13251338
if len(daemonset.Spec.NodeSelector) == 0 {
13261339
daemonset.Spec.NodeSelector = instance.Spec.NodeSelector
13271340
}

pkg/amphoracontrollers/daemonset.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func DaemonSet(
8484
envVars["KOLLA_CONFIG_STRATEGY"] = env.SetValue("COPY_ALWAYS")
8585
envVars["CONFIG_HASH"] = env.SetValue(configHash)
8686

87+
envVars["MGMT_CIDR"] = env.SetValue(instance.Spec.OctaviaProviderSubnetCIDR)
88+
envVars["MGMT_GATEWAY"] = env.SetValue(instance.Spec.OctaviaProviderSubnetGateway)
89+
8790
// Add the CA bundle
8891
if instance.Spec.TLS.CaBundleSecretName != "" {
8992
volumes = append(volumes, instance.Spec.TLS.CreateVolume())

0 commit comments

Comments
 (0)