From 7bb267c7f9c1b047406f4ad4bbe4069a935393b1 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Wed, 19 Aug 2020 08:38:25 -0400 Subject: [PATCH] Move n-ovs-agent to Kubernetes Change-Id: I8e6d62341b327137c69585a26a3d37cf5554ea08 --- devstack/lib/neutron-legacy | 20 ++++ images/neutron/Dockerfile | 4 + images/neutron/bindep.txt | 2 + images/neutron/neutron-openvswitch-agent | 29 ++++++ images/neutron/setup-repos.sh | 55 +++++++++++ openstack_operator/neutron.py | 4 +- .../identity/applicationcredential.py | 12 +++ .../openstack/identity/services.py | 4 +- .../daemonset-openvswitch-agent.yml.j2 | 97 +++++++++++++++++++ ...emonset.yml.j2 => daemonset-server.yml.j2} | 0 zuul.d/functional-jobs.yaml | 3 +- zuul.d/neutron-jobs.yaml | 3 + 12 files changed, 229 insertions(+), 4 deletions(-) create mode 100755 images/neutron/neutron-openvswitch-agent create mode 100644 images/neutron/setup-repos.sh create mode 100644 openstack_operator/templates/neutron/daemonset-openvswitch-agent.yml.j2 rename openstack_operator/templates/neutron/{daemonset.yml.j2 => daemonset-server.yml.j2} (100%) diff --git a/devstack/lib/neutron-legacy b/devstack/lib/neutron-legacy index 99811416..6ef9a423 100644 --- a/devstack/lib/neutron-legacy +++ b/devstack/lib/neutron-legacy @@ -87,6 +87,26 @@ function start_neutron_service_and_check { } export -f start_neutron_service_and_check +function start_mutnauq_l2_agent { + kubernetes_rollout_restart daemonset/neutron-openvswitch-agent + kubernetes_rollout_status daemonset/neutron-openvswitch-agent + + if is_provider_network && [[ $Q_AGENT == "openvswitch" ]]; then + sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE + sudo ip link set $OVS_PHYSICAL_BRIDGE up + sudo ip link set br-int up + sudo ip link set $PUBLIC_INTERFACE up + if is_ironic_hardware; then + for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do + sudo ip addr del $IP dev $PUBLIC_INTERFACE + sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE + done + sudo ip route replace $FIXED_RANGE via $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE + fi + fi +} +export -f start_neutron_agents + function _configure_neutron_common { _create_neutron_conf_dir diff --git a/images/neutron/Dockerfile b/images/neutron/Dockerfile index d6cce6c5..f03467b9 100644 --- a/images/neutron/Dockerfile +++ b/images/neutron/Dockerfile @@ -25,3 +25,7 @@ CMD ["/usr/local/bin/uwsgi", "--ini", "/etc/uwsgi/uwsgi.ini"] FROM neutron-base AS neutron-rpc-server COPY neutron-rpc-server /usr/local/bin/neutron-rpc-server CMD ["/usr/local/bin/neutron-rpc-server"] + +FROM neutron-base AS neutron-openvswitch-agent +COPY neutron-openvswitch-agent /usr/local/bin/neutron-openvswitch-agent +CMD ["/usr/local/bin/neutron-openvswitch-agent", "--config-file", "/etc/neutron/neutron.conf", "--config-file", "/etc/neutron/plugins/ml2/ml2_conf.ini"] \ No newline at end of file diff --git a/images/neutron/bindep.txt b/images/neutron/bindep.txt index 64b038ba..80478861 100644 --- a/images/neutron/bindep.txt +++ b/images/neutron/bindep.txt @@ -1,2 +1,4 @@ gcc [compile] libc-dev [compile] +sudo +openvswitch-common diff --git a/images/neutron/neutron-openvswitch-agent b/images/neutron/neutron-openvswitch-agent new file mode 100755 index 00000000..b4d91bed --- /dev/null +++ b/images/neutron/neutron-openvswitch-agent @@ -0,0 +1,29 @@ +#!/usr/local/bin/python +# Copyright (c) 2020 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pkg_resources +import re +import sys + +import sentry_sdk + +from neutron.cmd.eventlet.plugins.ovs_neutron_agent import main + +VERSION = pkg_resources.get_distribution("neutron").version +sentry_sdk.init(release="neutron@%s" % VERSION) + +sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) +sys.exit(main()) diff --git a/images/neutron/setup-repos.sh b/images/neutron/setup-repos.sh new file mode 100644 index 00000000..97a0dd1d --- /dev/null +++ b/images/neutron/setup-repos.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Copyright (c) 2020 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xe + +apt-get install -y gnupg2 + +cat < 1: raise RuntimeError("Found multiple services with name and type") diff --git a/openstack_operator/templates/neutron/daemonset-openvswitch-agent.yml.j2 b/openstack_operator/templates/neutron/daemonset-openvswitch-agent.yml.j2 new file mode 100644 index 00000000..f1927af9 --- /dev/null +++ b/openstack_operator/templates/neutron/daemonset-openvswitch-agent.yml.j2 @@ -0,0 +1,97 @@ +--- +# Copyright 2020 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: neutron-openvswitch-agent + namespace: openstack + labels: + {{ labels("neutron", component="openvswitch-agent") | indent(4) }} +spec: + updateStrategy: + rollingUpdate: + maxUnavailable: 1 + type: RollingUpdate + selector: + matchLabels: + {{ labels("neutron", component="openvswitch-agent") | indent(6) }} + template: + metadata: + labels: + {{ labels("neutron", component="openvswitch-agent") | indent(8) }} + spec: + automountServiceAccountToken: false + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + initContainers: + # TODO(mnaser): This should parse the configuration file and then create + # the bridges as needed. + - name: create-bridge + image: vexxhost/neutron-openvswitch-agent:latest + imagePullPolicy: Always + command: + - ovs-vsctl + - --may-exist + - add-br + - br-ex + volumeMounts: + - name: config + mountPath: /etc/neutron + - name: ml2-config + mountPath: /etc/neutron/plugins/ml2 + - name: host-run-ovs + mountPath: /run/openvswitch + containers: + - name: agent + image: vexxhost/neutron-openvswitch-agent:latest + imagePullPolicy: Always + env: + {% if 'sentryDSN' in spec %} + - name: SENTRY_DSN + value: {{ spec.sentryDSN }} + {% endif %} + - name: OS_OVS__LOCAL_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + securityContext: + # NOTE(mnaser): We need to revisit this + privileged: true + volumeMounts: + - name: config + mountPath: /etc/neutron + - name: ml2-config + mountPath: /etc/neutron/plugins/ml2 + - name: host-run-ovs + mountPath: /run/openvswitch + volumes: + - name: config + secret: + secretName: neutron-config + - name: ml2-config + secret: + secretName: neutron-ml2-config + - name: host-run-ovs + hostPath: + path: /run/openvswitch + tolerations: + - key: node-role.kubernetes.io/master + effect: NoSchedule +{% if 'hostAliases' in spec %} + hostAliases: + {{ spec.hostAliases | to_yaml | indent(8) }} +{% endif %} + diff --git a/openstack_operator/templates/neutron/daemonset.yml.j2 b/openstack_operator/templates/neutron/daemonset-server.yml.j2 similarity index 100% rename from openstack_operator/templates/neutron/daemonset.yml.j2 rename to openstack_operator/templates/neutron/daemonset-server.yml.j2 diff --git a/zuul.d/functional-jobs.yaml b/zuul.d/functional-jobs.yaml index 1884a913..32a51d25 100644 --- a/zuul.d/functional-jobs.yaml +++ b/zuul.d/functional-jobs.yaml @@ -50,7 +50,8 @@ - magnum-tempest-plugin - tempest-horizon devstack_localrc: - NEUTRON_DEPLOY_MOD_WSGI: True + NEUTRON_DEPLOY_MOD_WSGI: true + Q_USE_ROOTWRAP: false TEMPEST_PLUGINS: /opt/stack/barbican-tempest-plugin /opt/stack/heat-tempest-plugin /opt/stack/magnum-tempest-plugin /opt/stack/tempest-horizon docker_use_buildset_registry: true diff --git a/zuul.d/neutron-jobs.yaml b/zuul.d/neutron-jobs.yaml index 24100106..f4ec5269 100644 --- a/zuul.d/neutron-jobs.yaml +++ b/zuul.d/neutron-jobs.yaml @@ -17,6 +17,9 @@ - context: images/neutron repository: vexxhost/neutron-rpc-server target: neutron-rpc-server + - context: images/neutron + repository: vexxhost/neutron-openvswitch-agent + target: neutron-openvswitch-agent dependencies: - openstack-operator:images:build:openstack-operator files: &id003