Stan Lagun a855e9a879 Adds support for several applications in single Pod
Kubernetes doesn't allow to add containers to a Pod that
is already deployed. With this change old pods will be deleted
and either new pod created which will include new container
or Replication Controller will be modified (before Pod delete
so that updated Pods be created instead)

Also now Pods are created only when replica number set to 0.
Otherwise Pods created by ReplicationController alone.

Change-Id: I8552793f39083de47ad07e7013dedb72e0550885
Closes-Bug: #1444208
2015-04-15 00:28:31 +00:00

99 lines
2.6 KiB
YAML

Namespaces:
=: io.murano.apps.docker
std: io.murano
Name: DockerApplication
Extends: std:Application
Properties:
host:
Contract: $.class(DockerContainerHost).notNull()
applicationEndpoints:
Contract:
- port: $.int().notNull().check($ > 0)
address: $.string().notNull()
scope: $.string().notNull().check($ in list(public, cloud, internal, host))
portScope: $.string().notNull().check($ in list(public, cloud, internal, host))
containerPort: $.int().notNull().check($ > 0)
protocol: $.string().notNull().check($ in list(TCP, UDP))
Usage: Out
Methods:
initialize:
Body:
- $._environment: $.find(std:Environment).require()
deploy:
Body:
- $.host.deploy()
- $container: $.getContainer()
- $repr: $._getContainerRepresentation($container)
- If: $.getAttr(container, null) != $repr
Then:
- $.onInstallationStart()
- Try:
- $.applicationEndpoints: $.host.hostContainer($container)
- $.setAttr(container, $repr)
Catch:
- As: e
Do:
- $formatString: 'Error: {0}'
- $._environment.reporter.report_error($, $formatString.format($e.message))
- Rethrow:
Else:
- $.onInstallationFinish()
getConnectionTo:
Arguments:
- application:
Contract: $.class(DockerApplication).notNull()
- port:
Contract: $.int().notNull().check($ > 0)
- protocol:
Contract: $.string().notNull().check($ in list(TCP, UDP))
Default: TCP
Body:
- $scopes: [cloud, public]
- If: $.host = $application.host
Then:
- $scopes: list(host, internal) + $scopes
Else:
- If: $.host.getInternalScopeId() = $application.host.getInternalScopeId()
Then:
- $scopes: list(internal) + $scope
- For: s
In: $scopes
Do:
- $endpoints: $application.applicationEndpoints.where(true).where(
$.scope = $s and $.containerPort = $port and $.protocol = $protocol)
- If: len($endpoints) > 0
Then:
- $index: int(len($endpoints) * random())
- $endpoint: $endpoints[$index]
- Return:
host: $endpoint.address
port: $endpoint.port
_getContainerRepresentation:
Arguments:
- container:
Contract: $.class(DockerContainer).notNull()
Body:
Return: $container.getRepresentation()
getContainer:
onInstallationStart:
Body:
onInstallationFinish:
Body: