Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/bases/neutron.openstack.org_neutronapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ spec:
description: DefaultConfigOverwrite - interface to overwrite default
config files like policy.yaml
type: object
enableFwaas:
default: false
description: EnableFwaas - enable NeutronFwaas service plugin
type: boolean
extraMounts:
description: ExtraMounts containing conf files
items:
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/neutronapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ type NeutronAPISpecCore struct {
// TopologyRef to apply the Topology defined by the associated CR referenced
// by name
TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=false
// EnableFwaas - enable NeutronFwaas service plugin
EnableFwaas bool `json:"enableFwaas"`
}

type NeutronApiTLS struct {
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/neutron.openstack.org_neutronapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ spec:
description: DefaultConfigOverwrite - interface to overwrite default
config files like policy.yaml
type: object
enableFwaas:
default: false
description: EnableFwaas - enable NeutronFwaas service plugin
type: boolean
extraMounts:
description: ExtraMounts containing conf files
items:
Expand Down
2 changes: 2 additions & 0 deletions controllers/neutronapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,8 @@ func (r *NeutronAPIReconciler) generateServiceSecrets(
templateParameters["OVNDB_TLS"] = instance.Spec.TLS.Ovn.Enabled()
}

templateParameters["EnableFwaas"] = instance.Spec.EnableFwaas

// create httpd vhost template parameters
httpdVhostConfig := map[string]interface{}{}
for _, endpt := range []service.Endpoint{service.EndpointInternal, service.EndpointPublic} {
Expand Down
13 changes: 13 additions & 0 deletions templates/neutronapi/config/01-neutron.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ bind_port = 9697
transport_url={{ .TransportURL }}
core_plugin = {{ .CorePlugin }}
{{ if .IsOVN }}
{{ if .EnableFwaas }}
service_plugins = qos,ovn-router,trunk,segments,port_forwarding,log,firewall_v2
{{ else }}
service_plugins = qos,ovn-router,trunk,segments,port_forwarding,log
{{ end }}
{{ else }}
{{ if .EnableFwaas }}
service_plugins = qos,trunk,segments,port_forwarding,log,firewall_v2
{{ else }}
service_plugins = qos,trunk,segments,port_forwarding,log
{{ end }}
{{ end }}
dns_domain = openstackgate.local
dhcp_agent_notification = false
Expand Down Expand Up @@ -119,3 +127,8 @@ memcache_dead_retry = 30
policy_file = /etc/neutron/policy.yaml
enforce_scope = True
enforce_new_defaults = True

{{ if and .EnableFwaas .IsOVN }}
[service_providers]
service_provider = FIREWALL_V2:fwaas_db:neutron_fwaas.services.firewall.service_drivers.ovn.firewall_l3_driver.OVNFwaasDriver:default
{{ end }}
79 changes: 79 additions & 0 deletions test/functional/neutronapi_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,31 @@ func getNeutronAPIControllerSuite(ml2MechanismDrivers []string) func() {
}, timeout, interval).Should(Succeed())
})
}
It("should create a Secret for 01-neutron.conf without FWaaS configuration", func() {
if isOVNEnabled {
DeferCleanup(DeleteOVNDBClusters, CreateOVNDBClusters(namespace))
}

keystoneAPI := keystone.CreateKeystoneAPI(namespace)
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPI)

secret := types.NamespacedName{
Namespace: neutronAPIName.Namespace,
Name: fmt.Sprintf("%s-%s", neutronAPIName.Name, "config"),
}

Eventually(func() corev1.Secret {
return th.GetSecret(secret)
}, timeout, interval).ShouldNot(BeNil())

data := th.GetSecret(secret).Data["01-neutron.conf"]
conf := string(data)

// service_plugins should include firewall_v2
Expect(conf).ShouldNot(MatchRegexp("service_plugins = .*firewall_v2.*"))
Expect(conf).ShouldNot(ContainSubstring(
"service_provider = FIREWALL_V2:fwaas_db:neutron_fwaas.services.firewall.service_drivers.ovn.firewall_l3_driver.OVNFwaasDriver:default"))
})
})

When("DB is created", func() {
Expand Down Expand Up @@ -1904,6 +1929,60 @@ func getNeutronAPIControllerSuite(ml2MechanismDrivers []string) func() {
},
).Spec.Template.Spec.Containers[0].Env, "CONFIG_HASH", "")
})

When("Neutron API is created with FWaaS enabled", func() {
BeforeEach(func() {
spec["enableFwaas"] = true
DeferCleanup(th.DeleteInstance, CreateNeutronAPI(neutronAPIName.Namespace, neutronAPIName.Name, spec))
DeferCleanup(k8sClient.Delete, ctx, CreateNeutronAPISecret(namespace, SecretName))
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec))
infra.SimulateMemcachedReady(memcachedName)
DeferCleanup(
mariadb.DeleteDBService,
mariadb.CreateDBService(
namespace,
GetNeutronAPI(neutronAPIName).Spec.DatabaseInstance,
corev1.ServiceSpec{
Ports: []corev1.ServicePort{{Port: 3306}},
},
),
)
SimulateTransportURLReady(apiTransportURLName)
mariadb.SimulateMariaDBAccountCompleted(types.NamespacedName{Namespace: namespace, Name: GetNeutronAPI(neutronAPIName).Spec.DatabaseAccount})
mariadb.SimulateMariaDBDatabaseCompleted(types.NamespacedName{Namespace: namespace, Name: neutronapi.DatabaseCRName})
keystoneAPI := keystone.CreateKeystoneAPI(namespace)
DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPI)
})

It("should create a Secret for 01-neutron.conf with expected FWaaS configuration", func() {
if isOVNEnabled {
DeferCleanup(DeleteOVNDBClusters, CreateOVNDBClusters(namespace))
}
secret := types.NamespacedName{
Namespace: neutronAPIName.Namespace,
Name: fmt.Sprintf("%s-%s", neutronAPIName.Name, "config"),
}

Eventually(func() corev1.Secret {
return th.GetSecret(secret)
}, timeout, interval).ShouldNot(BeNil())

data := th.GetSecret(secret).Data["01-neutron.conf"]
conf := string(data)

// service_plugins should include firewall_v2
Expect(conf).Should(MatchRegexp("service_plugins = .*firewall_v2.*"))

if isOVNEnabled {
Expect(conf).Should(ContainSubstring(
"service_provider = FIREWALL_V2:fwaas_db:neutron_fwaas.services.firewall.service_drivers.ovn.firewall_l3_driver.OVNFwaasDriver:default"))
} else {
Expect(conf).ShouldNot(ContainSubstring(
"service_provider = FIREWALL_V2:fwaas_db:neutron_fwaas.services.firewall.service_drivers.ovn.firewall_l3_driver.OVNFwaasDriver:default"))
}
})

})
}
}

Expand Down