Enable internal dns by default with a default dns name
Add dns-domain config option in neutron-k8s to allow building instances within an internal domain. Always enable extension dns_domain_ports. Remove config option from openstack-hypervisor, as it is not the right place. Change-Id: I876269ba1b575ad108dc8c9defcc32dcf6044ba3
This commit is contained in:
parent
9c31e36587
commit
fbe0587157
@ -3,6 +3,15 @@ options:
|
|||||||
default: False
|
default: False
|
||||||
description: Enable debug logging.
|
description: Enable debug logging.
|
||||||
type: boolean
|
type: boolean
|
||||||
|
dns-domain:
|
||||||
|
default: cloud.sunbeam.local.
|
||||||
|
description: |
|
||||||
|
Specifies the dns domain name that should be used for building instance
|
||||||
|
hostnames. The value of 'openstacklocal' will cause
|
||||||
|
the dhcp agents to broadcast the default domain of openstacklocal and
|
||||||
|
will not enable internal cloud dns resolution. This value should end
|
||||||
|
with a '.', e.g. 'cloud.example.org.'.
|
||||||
|
type: string
|
||||||
os-admin-hostname:
|
os-admin-hostname:
|
||||||
default:
|
default:
|
||||||
description: |
|
description: |
|
||||||
|
@ -20,7 +20,9 @@ This charm provide Neutron services as part of an OpenStack deployment
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
|
import ops
|
||||||
import ops_sunbeam.charm as sunbeam_charm
|
import ops_sunbeam.charm as sunbeam_charm
|
||||||
import ops_sunbeam.config_contexts as sunbeam_ctxts
|
import ops_sunbeam.config_contexts as sunbeam_ctxts
|
||||||
import ops_sunbeam.container_handlers as sunbeam_chandlers
|
import ops_sunbeam.container_handlers as sunbeam_chandlers
|
||||||
@ -121,6 +123,63 @@ class NeutronOperatorCharm(sunbeam_charm.OSBaseOperatorAPICharm):
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def check_configuration(self, event: ops.EventBase):
|
||||||
|
"""Check a configuration key is correct."""
|
||||||
|
try:
|
||||||
|
self._validate_domain()
|
||||||
|
except ValueError as e:
|
||||||
|
raise sunbeam_guard.BlockedExceptionError(str(e)) from e
|
||||||
|
|
||||||
|
def _validate_domain(self):
|
||||||
|
"""Check given domain is valid."""
|
||||||
|
domain = self.config.get("dns-domain")
|
||||||
|
if not domain:
|
||||||
|
raise ValueError("dns-domain cannot be empty")
|
||||||
|
|
||||||
|
if len(domain) > 253:
|
||||||
|
raise ValueError(
|
||||||
|
"A full name cannot be longer than 253 characters (trailing dot included)"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not domain.endswith("."):
|
||||||
|
raise ValueError("A domain name must have a trailing dot (.)")
|
||||||
|
|
||||||
|
labels = domain.split(".")
|
||||||
|
|
||||||
|
if len(labels) == 1:
|
||||||
|
raise ValueError(
|
||||||
|
"A domain name must have at least one label and a trailing dot,"
|
||||||
|
" or two labels separated by a dot"
|
||||||
|
)
|
||||||
|
|
||||||
|
if domain.endswith("."):
|
||||||
|
# strip trailing dot
|
||||||
|
del labels[-1]
|
||||||
|
|
||||||
|
label_regex = re.compile(r"^[a-z0-9-]*$", re.IGNORECASE)
|
||||||
|
|
||||||
|
for label in labels:
|
||||||
|
if not 1 < len(label) < 63:
|
||||||
|
raise ValueError(
|
||||||
|
"A label in a domain cannot be empty or longer than 63 characters"
|
||||||
|
)
|
||||||
|
|
||||||
|
if label.startswith("-") or label.endswith("-"):
|
||||||
|
raise ValueError(
|
||||||
|
"A label in a domain cannot start or end with a hyphen (-)"
|
||||||
|
)
|
||||||
|
|
||||||
|
if label_regex.match(label) is None:
|
||||||
|
raise ValueError(
|
||||||
|
"A label in a domain can only contain alphanumeric characters"
|
||||||
|
" and hyphens (-)"
|
||||||
|
)
|
||||||
|
|
||||||
|
def configure_unit(self, event: ops.EventBase) -> None:
|
||||||
|
"""Run configuration on this unit."""
|
||||||
|
self.check_configuration(event)
|
||||||
|
return super().configure_unit(event)
|
||||||
|
|
||||||
def get_pebble_handlers(self) -> list[sunbeam_chandlers.PebbleHandler]:
|
def get_pebble_handlers(self) -> list[sunbeam_chandlers.PebbleHandler]:
|
||||||
"""Pebble handlers for the service."""
|
"""Pebble handlers for the service."""
|
||||||
return [
|
return [
|
||||||
@ -178,7 +237,7 @@ class OVNContext(sunbeam_ctxts.ConfigContext):
|
|||||||
def context(self) -> dict:
|
def context(self) -> dict:
|
||||||
"""Configuration context."""
|
"""Configuration context."""
|
||||||
return {
|
return {
|
||||||
"extension_drivers": "port_security,qos",
|
"extension_drivers": "port_security,qos,dns_domain_ports",
|
||||||
"type_drivers": "geneve,gre,vlan,flat,local",
|
"type_drivers": "geneve,gre,vlan,flat,local",
|
||||||
"tenant_network_types": "geneve,gre,vlan,flat,local",
|
"tenant_network_types": "geneve,gre,vlan,flat,local",
|
||||||
"mechanism_drivers": "ovn",
|
"mechanism_drivers": "ovn",
|
||||||
|
@ -22,7 +22,7 @@ dhcp_agents_per_network = 1
|
|||||||
notify_nova_on_port_status_changes = True
|
notify_nova_on_port_status_changes = True
|
||||||
notify_nova_on_port_data_changes = True
|
notify_nova_on_port_data_changes = True
|
||||||
|
|
||||||
|
dns_domain = {{ options.dns_domain }}
|
||||||
|
|
||||||
global_physnet_mtu = 1500
|
global_physnet_mtu = 1500
|
||||||
|
|
||||||
|
@ -10,9 +10,6 @@ options:
|
|||||||
description: |
|
description: |
|
||||||
Whether to resume the guest VMs when the host boots.
|
Whether to resume the guest VMs when the host boots.
|
||||||
type: boolean
|
type: boolean
|
||||||
dns-domain:
|
|
||||||
default: "openstack.local"
|
|
||||||
type: string
|
|
||||||
dns-servers:
|
dns-servers:
|
||||||
default: "8.8.8.8"
|
default: "8.8.8.8"
|
||||||
type: string
|
type: string
|
||||||
|
@ -429,7 +429,6 @@ class HypervisorOperatorCharm(sunbeam_charm.OSBaseOperatorCharm):
|
|||||||
"identity.user-domain-name": contexts.identity_credentials.user_domain_name,
|
"identity.user-domain-name": contexts.identity_credentials.user_domain_name,
|
||||||
"identity.username": contexts.identity_credentials.username,
|
"identity.username": contexts.identity_credentials.username,
|
||||||
"logging.debug": config("debug"),
|
"logging.debug": config("debug"),
|
||||||
"network.dns-domain": config("dns-domain"),
|
|
||||||
"network.dns-servers": config("dns-servers"),
|
"network.dns-servers": config("dns-servers"),
|
||||||
"network.enable-gateway": config("enable-gateway"),
|
"network.enable-gateway": config("enable-gateway"),
|
||||||
"network.external-bridge": config("external-bridge"),
|
"network.external-bridge": config("external-bridge"),
|
||||||
|
@ -162,7 +162,6 @@ class TestCharm(test_utils.CharmTestCase):
|
|||||||
"identity.username": "username",
|
"identity.username": "username",
|
||||||
"logging.debug": False,
|
"logging.debug": False,
|
||||||
"monitoring.enable": False,
|
"monitoring.enable": False,
|
||||||
"network.dns-domain": "openstack.local",
|
|
||||||
"network.dns-servers": "8.8.8.8",
|
"network.dns-servers": "8.8.8.8",
|
||||||
"network.enable-gateway": False,
|
"network.enable-gateway": False,
|
||||||
"network.external-bridge": "br-ex",
|
"network.external-bridge": "br-ex",
|
||||||
@ -266,7 +265,6 @@ class TestCharm(test_utils.CharmTestCase):
|
|||||||
"identity.username": "username",
|
"identity.username": "username",
|
||||||
"logging.debug": False,
|
"logging.debug": False,
|
||||||
"monitoring.enable": True,
|
"monitoring.enable": True,
|
||||||
"network.dns-domain": "openstack.local",
|
|
||||||
"network.dns-servers": "8.8.8.8",
|
"network.dns-servers": "8.8.8.8",
|
||||||
"network.enable-gateway": False,
|
"network.enable-gateway": False,
|
||||||
"network.external-bridge": "br-ex",
|
"network.external-bridge": "br-ex",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user