k8s-docker-suite-app-murano/Applications/GuestBook/package/Classes/GuestBook.yaml

64 lines
1.7 KiB
YAML

Namespaces:
=: io.murano.apps.docker
std: io.murano
Name: DockerGuestBook
Extends: DockerApplication
Properties:
name:
Contract: $.string().notNull()
publish:
Contract: $.bool().notNull()
Default: true
redisMaster:
Contract: $.class(DockerRedis).notNull()
redisSlave:
Contract: $.class(DockerRedisSlave).notNull()
Methods:
initialize:
Body:
- $._environment: $.find(std:Environment).require()
- $._scope: switch($.publish, $ => public, not $ => internal)
getContainer:
Body:
- $.redisMaster.deploy()
- $.redisSlave.deploy()
- $redisMasterLink: $.getConnectionTo($.redisMaster, 6379)
- $redisSlaveLink: $.getConnectionTo($.redisSlave, 6379)
- Return:
name: $.name
image: 'brendanburns/php-redis'
env:
REDIS_MASTER_SERVICE_HOST: $.redisMaster.host
REDIS_MASTER_SERVICE_PORT: $.redisMaster.port
REDISSLAVE_SERVICE_HOST: $.redisSlave.host
REDISSLAVE_SERVICE_PORT: $.redisSlave.port
ports:
- port: 80
scope: $._scope
onInstallationStart:
Body:
- $._environment.reporter.report($this, 'Installing Redis Slave')
onInstallationFinish:
Body:
- If: $.publish
Then:
- $endpoints: $.applicationEndpoints.where($.scope = $this._scope).
select(format('{0}:{1}', $.address, $.port))
- $._environment.reporter.report($this, 'GuestBook {0} is available at {1}'.format($.name, join(', ', $endpoints)))
Else:
- $._environment.reporter.report($this, 'GuestBook {0} has deployed but is not accessible from outside'.format($.name))