-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for linuxbridge and openvswitch network plug-ins
- Loading branch information
Showing
47 changed files
with
1,701 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Install neutron chart | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'charts/neutron/**' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Fetch history | ||
run: git fetch --prune --unshallow | ||
|
||
- name: Set up chart-testing | ||
uses: helm/chart-testing-action@v2.2.1 | ||
|
||
- name: Create kind cluster | ||
uses: helm/kind-action@v1.2.0 | ||
|
||
- name: create virt interface | ||
run: tests/scripts/github-action-helper.sh create_virt_interface_test | ||
|
||
- name: Create k8s namespace | ||
run: | ||
kubectl create namespace test-neutron | ||
|
||
- name: Install password chart | ||
run: | ||
helm install openstack-password charts/password --namespace test-neutron | ||
|
||
- name: Install openstack-dep chart | ||
run: | | ||
helm dependency build charts/openstack-dep | ||
helm install openstack-dependency charts/openstack-dep --namespace test-neutron --wait --timeout 600s | ||
- name: Install keystone chart | ||
run: | | ||
helm dependency build charts/keystone | ||
helm install openstack-keystone charts/keystone --namespace test-neutron --wait --timeout 600s | ||
- name: Run chart-testing (install) | ||
run: ct install --namespace test-neutron --target-branch main --charts charts/neutron --debug --helm-extra-args "--timeout 600s" | ||
|
||
- name: setup tmate session for debugging when event is PR | ||
if: failure() && github.event_name == 'pull_request' | ||
uses: mxschmitt/action-tmate@v3 | ||
timeout-minutes: 60 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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: v2 | ||
description: Openstack neutron service | ||
name: neutron | ||
version: 1.0.0 | ||
home: https://github.com/kungze/kolla-helm | ||
maintainers: | ||
- name: Kungze | ||
dependencies: | ||
- name: common | ||
repository: https://kungze.github.io/kolla-helm | ||
version: 1.x.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
# neutron | ||
|
||
The chart used to deploy openstack neutron project. | ||
|
||
## TL;DR | ||
|
||
```shell | ||
$ helm repo add kolla-helm https://kungze.github.io/kolla-helm | ||
$ helm install openstack-password kolla-helm/password | ||
$ helm install openstack-dependency kolla-helm/openstack-dep | ||
$ helm install openstack-keystone kolla-helm/keystone | ||
$ helm install openstack-neutron kolla-helm/neutron --set networkPlugins.external_interface=eth1,networkPlugins.ovs.tunnel_interface=eth2 | ||
``` | ||
|
||
## Parameters | ||
|
||
### Cluster Paramters | ||
|
||
| Name | Form title | Description | Value | | ||
| ----------------------- | --------------------- | -------------------------------------------- | --------------- | | ||
| `cluster_domain_suffix` | Cluster Domain Suffix | The doamin suffix of the current k8s cluster | `cluster.local` | | ||
|
||
|
||
### Dependency Parameters | ||
|
||
| Name | Form title | Description | Value | | ||
| --------------------- | --------------------- | --------------------------------------- | ---------------------- | | ||
| `openstackDepRelease` | Openstack-dep Release | The release name of openstack-dep chart | `openstack-dependency` | | ||
| `passwordRelease` | Password Release | The release name of password chart | `openstack-password` | | ||
| `keystoneRelease` | keystone Release | The release name of keystone chart | `openstack-keystone` | | ||
|
||
|
||
### Image Parameters | ||
|
||
| Name | Form title | Description | Value | | ||
| ---------------- | ----------------- | ----------------------------------------------- | ----------------------- | | ||
| `imageRegistry` | Image Registry | The registry address of openstack kolla image | `registry.aliyuncs.com` | | ||
| `imageNamespace` | Image Namespace | The registry namespace of openstack kolla image | `kolla-helm` | | ||
| `openstackTag` | Openstack version | The openstack version | `yoga` | | ||
| `pullPolicy` | Pull Policy | The image pull policy | `IfNotPresent` | | ||
|
||
|
||
### Deployment Parameters | ||
|
||
| Name | Form title | Description | Value | | ||
| ---------------------- | ----------------------- | ------------------------------------------------------------------------ | -------- | | ||
| `replicaCount` | | Number of neutron-server replicas to deploy | `1` | | ||
| `serviceAccountName` | | ServiceAccount name | `neutron` | | ||
| `enableLivenessProbe` | Enable Liveness Probe | Whether or not enable liveness probe | `true` | | ||
| `enableReadinessProbe` | Enable Readliness Probe | Whether or not enable readiness probe | `true` | | ||
|
||
|
||
### neutron Config parameters | ||
|
||
| Name | Form title | Description | Value | | ||
| ------------------------------------- | --------------------------- | --------------------------------------------------- | ----------| | ||
| `db_database` | Neutron Database | The neutron database name | `neutron` | | ||
| `db_username` | Neutron Database User | The neutron database user name | `neutron` | | ||
| `enabled_notification` | Enable Notification | Whether or not enable notification | `false` | | ||
| `tenant_network_types` | Tenant Network Types | The tenant network types | `vlan` | | ||
| `network_vlan_ranges` | Network Vlan Ranges |Multiple ranges can be defined like so: 1100:1110 | `1001:1100`| | ||
| `neutron_server.service_plugins` | Network Service Plugins | | `router` | | ||
| `neutron_openvswitch_agent.enabled` | Enable Openvswitch | Whether or not enable openvswitch network plug-in | `true` | | ||
| `neutron_openvswitch_agent.tunnel_interface` | Tunnel Interface Name | The tunnel interface name | `eth0` | | ||
| `neutron_linuxbridge_agent.enabled` | Enable Linuxbridge | Whether or not enable linuxbridge network plug-in | `false` | | ||
| `external_interface` | External Interface Name | The extertnal interface name | `eth1` | | ||
|
||
### Ingress Parameters | ||
|
||
| Name | Form title | Description | Value | | ||
| ---------------------- | ------------- | --------------------------------------------------------------------------------------- | ----------------- | | ||
| `ingress.enabled` | Ingress | Whether or not create ingress for neutron service | `true` | | ||
| `ingress.ingressClass` | Ingress Class | Ingress Class Name | `openstack-nginx` | | ||
| `ingress.path` | Path Prefix | Ingress will match the path prefix, and forward the matched request to neutron service | `network` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{/* | ||
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. | ||
*/}} | ||
|
||
|
||
CHART NAME: {{ .Chart.Name }} | ||
CHART VERSION: {{ .Chart.Version }} | ||
|
||
** Please be patient while the chart is being deployed ** | ||
|
||
Verify: | ||
source openstackrc | ||
openstack network agent list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
|
||
{{/* | ||
Return the proper neutron server image name | ||
*/}} | ||
{{- define "neutron.server.image" -}} | ||
{{ $repository := "ubuntu-source-neutron-server" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron dhcp image name | ||
*/}} | ||
{{- define "neutron.dhcp.image" -}} | ||
{{ $repository := "ubuntu-source-neutron-dhcp-agent" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron linuxbridge image name | ||
*/}} | ||
{{- define "neutron.linuxbridge.image" -}} | ||
{{ $repository := "ubuntu-source-neutron-linuxbridge-agent" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron openvswitch agent init image name | ||
*/}} | ||
{{- define "neutron.openvswitch-agent-init.image" -}} | ||
{{ $repository := "ubuntu-source-kolla-toolbox" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron openvswitch agent image name | ||
*/}} | ||
{{- define "neutron.openvswitch-agent.image" -}} | ||
{{ $repository := "ubuntu-source-neutron-openvswitch-agent" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron openvswitch db image name | ||
*/}} | ||
{{- define "neutron.openvswitch-db.image" -}} | ||
{{ $repository := "ubuntu-source-openvswitch-db-server" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron openvswitch vswitchd image name | ||
*/}} | ||
{{- define "neutron.openvswitch-vswitchd.image" -}} | ||
{{ $repository := "ubuntu-source-openvswitch-vswitchd" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron l3 agent image name | ||
*/}} | ||
{{- define "neutron.l3-agent.image" -}} | ||
{{ $repository := "ubuntu-source-neutron-l3-agent" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the proper neutron metadata agent image name | ||
*/}} | ||
{{- define "neutron.metadata-agent.image" -}} | ||
{{ $repository := "ubuntu-source-neutron-metadata-agent" }} | ||
{{- include "common.images.image" (dict "registry" .Values.imageRegistry "namespace" .Values.imageNamespace "repository" $repository "tag" .Values.openstackTag) }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the neutron.cluster.endpoints | ||
*/}} | ||
{{- define "neutron.cluster.endpoint" -}} | ||
{{ printf "http://%s.%s.svc.%s:9696" "neutron-api" .Release.Namespace .Values.cluster_domain_suffix }} | ||
{{- end }} |
90 changes: 90 additions & 0 deletions
90
charts/neutron/templates/bin/_neutron-configmap-render.py.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import logging | ||
import requests | ||
import os | ||
import sys | ||
import tempfile | ||
import netifaces as ni | ||
|
||
KUBE_HOST = None | ||
KUBE_CERT = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt' | ||
KUBE_TOKEN = None | ||
NAMESPACE = os.environ['KUBERNETES_NAMESPACE'] | ||
TUNNEL_INTERFACE_NAME = os.getenv('TUNNEL_INTERFACE_NAME', None) | ||
CONF_FILE_NAME = os.getenv('CONF_FILE_NAME', None) | ||
CONFIG_MAP_NAME = os.getenv('CONFIG_MAP_NAME', None) | ||
LOG_DATEFMT = "%Y-%m-%d %H:%M:%S" | ||
LOG_FORMAT = "%(asctime)s.%(msecs)03d - %(levelname)s - %(message)s" | ||
logging.basicConfig(format=LOG_FORMAT, datefmt=LOG_DATEFMT) | ||
LOG = logging.getLogger(__name__) | ||
LOG.setLevel(logging.INFO) | ||
|
||
|
||
def get_tunnel_interface_address(if_name): | ||
return ni.ifaddresses(if_name)[ni.AF_INET][0]['addr'] | ||
|
||
|
||
def read_kube_config(): | ||
global KUBE_HOST, KUBE_TOKEN | ||
KUBE_HOST = "https://%s:%s" % ('kubernetes.default', | ||
os.environ['KUBERNETES_SERVICE_PORT']) | ||
with open('/var/run/secrets/kubernetes.io/serviceaccount/token', 'r') as f: | ||
KUBE_TOKEN = f.read() | ||
|
||
|
||
def get_configmap_definition(name): | ||
url = '%s/api/v1/namespaces/%s/configmaps/%s' % (KUBE_HOST, | ||
NAMESPACE, | ||
name) | ||
resp = requests.get(url, | ||
headers={'Authorization': 'Bearer %s' % KUBE_TOKEN}, | ||
verify=KUBE_CERT) | ||
if resp.status_code != 200: | ||
LOG.error('Cannot get configmap %s.', name) | ||
LOG.error(resp.text) | ||
return None | ||
LOG.info('Request configmaps url %s.', url) | ||
return resp.json() | ||
|
||
|
||
def update_configmap(name, configmap): | ||
url = '%s/api/v1/namespaces/%s/configmaps/%s' % (KUBE_HOST, NAMESPACE, name) | ||
resp = requests.put(url, | ||
json=configmap, | ||
headers={'Authorization': 'Bearer %s' % KUBE_TOKEN}, | ||
verify=KUBE_CERT) | ||
if resp.status_code != 200: | ||
LOG.error('Cannot update configmap %s.', name) | ||
LOG.error(resp.text) | ||
return False | ||
return True | ||
|
||
def update_connection_fields(content): | ||
tmp = tempfile.NamedTemporaryFile(prefix='tmp', suffix='.ini', dir='/tmp') | ||
LOG.info('Start update configmap file data %s.', CONF_FILE_NAME) | ||
with open(tmp.name, 'w') as f: | ||
f.seek(0, 0) | ||
for line in content.split("\n"): | ||
if "tunnel_interface_address_placeholder" in line: | ||
tunnel_interface_address = get_tunnel_interface_address(TUNNEL_INTERFACE_NAME) | ||
line = line.replace("tunnel_interface_address_placeholder", tunnel_interface_address ) | ||
f.write(line + "\n") | ||
f.truncate() | ||
with open(tmp.name, 'r') as f: | ||
info = f.read() | ||
return info | ||
|
||
|
||
def main(): | ||
read_kube_config() | ||
updated_keys = "" | ||
configmap = get_configmap_definition(CONFIG_MAP_NAME) | ||
conf = configmap['data'][CONF_FILE_NAME] | ||
print(conf) | ||
updated_keys = update_connection_fields(conf) | ||
|
||
configmap['data'][CONF_FILE_NAME] = updated_keys | ||
if not update_configmap(CONFIG_MAP_NAME, configmap): | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"command": "/tmp/db-sync.sh", | ||
"config_files": [ | ||
{ | ||
"source": "/var/lib/kolla/config_files/neutron.conf", | ||
"dest": "/etc/neutron/neutron.conf", | ||
"owner": "neutron", | ||
"perm": "0600" | ||
} | ||
], | ||
"permissions": [ | ||
{ | ||
"path": "/var/log/kolla", | ||
"owner": "neutron:kolla" | ||
}, | ||
{ | ||
"path": "/var/log/kolla/neutron/neutron.log", | ||
"owner": "neutron:neutron" | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
charts/neutron/templates/conf/neutron-dhcp-agent/_dhcp_agent.ini.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[DEFAULT] | ||
{{- if .Values.neutron_linuxbridge_agent.enabled }} | ||
interface_driver = linuxbridge | ||
{{- else if .Values.neutron_openvswitch_agent.enabled }} | ||
interface_driver = openvswitch | ||
{{- end }} | ||
dnsmasq_config_file = /etc/neutron/dnsmasq.conf | ||
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq | ||
enable_isolated_metadata = true | ||
force_metadata = true | ||
dnsmasq_dns_servers = 1.1.1.1,8.8.8.8,8.8.4.4 |
1 change: 1 addition & 0 deletions
1
charts/neutron/templates/conf/neutron-dhcp-agent/_dnsmasq.conf.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
log-facility=/var/log/kolla/neutron/dnsmasq.log |
Oops, something went wrong.