From d57fac1ff729fe0ac662bf5aeadfd971abe25223 Mon Sep 17 00:00:00 2001 From: ricolin Date: Thu, 8 May 2025 01:03:17 +0800 Subject: [PATCH] Allow neutron work with OVN+DHCP Change-Id: Ib8bb71e0b23e905ca72aeae5ef06daa292e7e042 --- .../templates/bin/_neutron-dhcp-agent.sh.tpl | 3 +++ neutron/templates/configmap-etc.yaml | 5 ++++- neutron/templates/daemonset-dhcp-agent.yaml | 22 +++++++++++++++++++ neutron/values.yaml | 2 ++ .../notes/neutron-b225c11a5e1d522d.yaml | 5 +++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/neutron-b225c11a5e1d522d.yaml diff --git a/neutron/templates/bin/_neutron-dhcp-agent.sh.tpl b/neutron/templates/bin/_neutron-dhcp-agent.sh.tpl index 0f73e5a391..b6296f48f1 100644 --- a/neutron/templates/bin/_neutron-dhcp-agent.sh.tpl +++ b/neutron/templates/bin/_neutron-dhcp-agent.sh.tpl @@ -17,6 +17,9 @@ limitations under the License. set -x exec neutron-dhcp-agent \ --config-file /etc/neutron/neutron.conf \ +{{- if ( has "ovn" .Values.network.backend ) }} + --config-file /tmp/pod-shared/ovn.ini \ +{{- end }} {{- if and ( empty .Values.conf.neutron.DEFAULT.host ) ( .Values.pod.use_fqdn.neutron_agent ) }} --config-file /tmp/pod-shared/neutron-agent.ini \ {{- end }} diff --git a/neutron/templates/configmap-etc.yaml b/neutron/templates/configmap-etc.yaml index db92641d9f..ec12baa9ad 100644 --- a/neutron/templates/configmap-etc.yaml +++ b/neutron/templates/configmap-etc.yaml @@ -155,7 +155,7 @@ limitations under the License. {{- if empty $envAll.Values.conf.dhcp_agent.DEFAULT.interface_driver -}} {{- $_ := set $envAll.Values "__interface_driver" ( list ) }} -{{- if ( has "openvswitch" $envAll.Values.network.backend ) -}} +{{- if or ( has "openvswitch" $envAll.Values.network.backend ) ( has "ovn" $envAll.Values.network.backend ) -}} {{ $__interface_driver := append $envAll.Values.__interface_driver "openvswitch" }} {{- $_ := set $envAll.Values "__interface_driver" $__interface_driver }} {{- end -}} @@ -165,6 +165,9 @@ limitations under the License. {{- end -}} {{- $_ := set $envAll.Values.conf.dhcp_agent.DEFAULT "interface_driver" $envAll.Values.__interface_driver -}} {{- end -}} +{{- if and (has "ovn" $envAll.Values.network.backend) (empty $envAll.Values.conf.dhcp_agent.ovs.ovsdb_connection) -}} +{{- $_ := set $envAll.Values.conf.dhcp_agent.ovs "ovsdb_connection" "unix:/run/openvswitch/db.sock" -}} +{{- end -}} {{- if empty $envAll.Values.conf.l3_agent.DEFAULT.interface_driver -}} {{- $_ := set $envAll.Values "__interface_driver" ( list ) }} diff --git a/neutron/templates/daemonset-dhcp-agent.yaml b/neutron/templates/daemonset-dhcp-agent.yaml index 17e15f8e12..af72487572 100644 --- a/neutron/templates/daemonset-dhcp-agent.yaml +++ b/neutron/templates/daemonset-dhcp-agent.yaml @@ -94,6 +94,19 @@ spec: {{- end }} initContainers: {{ tuple $envAll "pod_dependency" $mounts_neutron_dhcp_agent_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + {{- if ( has "ovn" .Values.network.backend ) }} + - name: ovn-neutron-init +{{ tuple $envAll "neutron_dhcp" | include "helm-toolkit.snippets.image" | indent 10 }} + command: + - /tmp/neutron-ovn-init.sh + volumeMounts: + - name: pod-shared + mountPath: /tmp/pod-shared + - name: neutron-bin + mountPath: /tmp/neutron-ovn-init.sh + subPath: neutron-ovn-init.sh + readOnly: true + {{- end }} - name: neutron-dhcp-agent-init {{ tuple $envAll "neutron_dhcp" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.agent.dhcp | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} @@ -245,6 +258,10 @@ spec: mountPath: /run/netns mountPropagation: Bidirectional {{- end }} + {{- if ( has "ovn" .Values.network.backend ) }} + - name: run-openvswitch + mountPath: /run/openvswitch + {{- end }} {{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_messaging.auth.admin.secret.tls.internal "path" "/etc/rabbitmq/certs" | include "helm-toolkit.snippets.tls_volume_mount" | indent 12 }} {{ if $mounts_neutron_dhcp_agent.volumeMounts }}{{ toYaml $mounts_neutron_dhcp_agent.volumeMounts | indent 12 }}{{ end }} volumes: @@ -274,6 +291,11 @@ spec: hostPath: path: /run/netns {{- end }} + {{- if ( has "ovn" .Values.network.backend ) }} + - name: run-openvswitch + hostPath: + path: /run/openvswitch + {{- end }} {{- dict "enabled" $envAll.Values.manifests.certificates "name" $envAll.Values.endpoints.oslo_messaging.auth.admin.secret.tls.internal | include "helm-toolkit.snippets.tls_volume" | indent 8 }} {{ if $mounts_neutron_dhcp_agent.volumes }}{{ toYaml $mounts_neutron_dhcp_agent.volumes | indent 8 }}{{ end }} {{- end }} diff --git a/neutron/values.yaml b/neutron/values.yaml index 204e8c7aea..3ede160770 100644 --- a/neutron/values.yaml +++ b/neutron/values.yaml @@ -2113,6 +2113,8 @@ conf: interface_driver: null dnsmasq_config_file: /etc/neutron/dnsmasq.conf force_metadata: True + # NOTE(mnaser): This has to be here in order for the DHCP agent to work with OVN. + ovs: {} dnsmasq: | #no-hosts #port=5353 diff --git a/releasenotes/notes/neutron-b225c11a5e1d522d.yaml b/releasenotes/notes/neutron-b225c11a5e1d522d.yaml new file mode 100644 index 0000000000..d046815c06 --- /dev/null +++ b/releasenotes/notes/neutron-b225c11a5e1d522d.yaml @@ -0,0 +1,5 @@ +--- +neutron: + - | + Fix OVN support in neutron DHCP. +...