Support exposing ports in capsule - API
In capsule controller, process the 'ports' field and convert it to 'exposed_ports' property of the container. Right now, we process the 'containerPort' and 'protocol' field. Under the hook, Zun will create a security group for opening that port and protocol. The 'hostPort' field is ignored since Zun doesn't expose compute host information. This might be revisited later and implemented by the neutron floating IP port forwarding feature. Change-Id: Ic71d19c5e61573373babb5082331b98847a3cebf
This commit is contained in:
parent
20ad7bbe0c
commit
bb7ba49c62
|
@ -26,7 +26,7 @@
|
|||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
container_service:
|
||||
min_microversion: 1.34
|
||||
min_microversion: 1.35
|
||||
devstack_services:
|
||||
tempest: true
|
||||
devstack_plugins:
|
||||
|
|
|
@ -287,12 +287,16 @@ class CapsuleController(base.Controller):
|
|||
container_dict['command'] = container_dict['args']
|
||||
container_dict.pop('args')
|
||||
|
||||
# NOTE(kevinz): Don't support port remapping, will find a
|
||||
# easy way to implement it.
|
||||
# if container need to open some port, just open it in container,
|
||||
# user can change the security group and getting access to port.
|
||||
if container_dict.get('ports'):
|
||||
container_dict.pop('ports')
|
||||
exposed_ports = {}
|
||||
ports = container_dict.pop('ports')
|
||||
for port in ports:
|
||||
container_port = "%s/%s" % (
|
||||
port['containerPort'],
|
||||
port.get('protocol', 'tcp').lower())
|
||||
host_port = {}
|
||||
exposed_ports[container_port] = host_port
|
||||
container_dict['exposed_ports'] = exposed_ports
|
||||
|
||||
if container_dict.get('resources'):
|
||||
resources_list = container_dict.get('resources')
|
||||
|
|
|
@ -421,7 +421,7 @@ capsule_container_ports = {
|
|||
'protocol': capsule_port_protocol,
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'required': ['containerPort', 'hostPort']
|
||||
'required': ['containerPort']
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,10 +67,11 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
|||
* 1.32 - Make capsule deletion asynchronized
|
||||
* 1.33 - Add 'finish_time' to container actions
|
||||
* 1.34 - Add 'init_containers' to capsule
|
||||
* 1.35 - Support exposing container ports in capsule
|
||||
"""
|
||||
|
||||
BASE_VER = '1.1'
|
||||
CURRENT_MAX_VER = '1.34'
|
||||
CURRENT_MAX_VER = '1.35'
|
||||
|
||||
|
||||
class Version(object):
|
||||
|
|
|
@ -261,3 +261,17 @@ user documentation.
|
|||
|
||||
Add 'init_containers' to capsule.
|
||||
This field contains a list of init_container information.
|
||||
|
||||
1.35
|
||||
----
|
||||
|
||||
Support processing 'ports' field in capsule's container.
|
||||
Users can leverage this field to open ports of a container.
|
||||
For example::
|
||||
|
||||
spec:
|
||||
containers:
|
||||
- image: "nginx"
|
||||
ports:
|
||||
- containerPort: 80
|
||||
protocol: TCP
|
||||
|
|
|
@ -26,7 +26,7 @@ from zun.tests.unit.db import base
|
|||
|
||||
|
||||
PATH_PREFIX = '/v1'
|
||||
CURRENT_VERSION = "container 1.34"
|
||||
CURRENT_VERSION = "container 1.35"
|
||||
|
||||
|
||||
class FunctionalTest(base.DbTestCase):
|
||||
|
|
|
@ -28,7 +28,7 @@ class TestRootController(api_base.FunctionalTest):
|
|||
'default_version':
|
||||
{'id': 'v1',
|
||||
'links': [{'href': 'http://localhost/v1/', 'rel': 'self'}],
|
||||
'max_version': '1.34',
|
||||
'max_version': '1.35',
|
||||
'min_version': '1.1',
|
||||
'status': 'CURRENT'},
|
||||
'description': 'Zun is an OpenStack project which '
|
||||
|
@ -37,7 +37,7 @@ class TestRootController(api_base.FunctionalTest):
|
|||
'versions': [{'id': 'v1',
|
||||
'links': [{'href': 'http://localhost/v1/',
|
||||
'rel': 'self'}],
|
||||
'max_version': '1.34',
|
||||
'max_version': '1.35',
|
||||
'min_version': '1.1',
|
||||
'status': 'CURRENT'}]}
|
||||
|
||||
|
|
Loading…
Reference in New Issue