Your own vApp
A vApp lives inside a deployment of its app. It has no compose file and runs
no container: installing an instance runs jobs in the parent’s containers,
and removing it runs others. Each instance is a row of its own in shc ls.
guestbook gets a board vApp: each board is a count of its own in the
parent’s counter, started at a number the board chooses. Four files make it,
all in guestbook’s directory on home01.
version: "1.0"name: boardapp: guestbooktype: vappdescription: A board inside a guestbook, with a count of its ownhidden: falserestartHost: truevars: start: the count a new board starts at cleanup: delete the count when the board is removedstart: 0cleanup: truevsocket: boarddata: key: "board:{{ instance_name }}" start: "{{ vars.start }}" cleanup: "{{ vars.cleanup }}"schema: plug: key@string!: the counter key the board counts in start@int: the count it starts at cleanup@boolean: delete the count when the board is removed socket: hostname@string!: the counter's addressdata: hostname: "{{ environment }}.counter.{{ stack }}"jobs: integration: - name: open context: service service: counter command: redis-cli setnx {{ integration.plug.data.key }} {{ integration.plug.data.start }} cleanup: - name: close context: service service: counter command: redis-cli del {{ integration.plug.data.key }}board.vapp.yamlnames the vApp, the app it belongs to and its variables.hidden: falsekeeps it on catalogue listings.restartHost: truerestarts the parent deployment once an instance’s jobs have run, for an app that reads what they wrote only at start.board.vvars.yamlgives the variables their defaults.board.vplug.yamlis what an instance asks the parent for: a key named after the instance.board.vsocket.yamlis what the parent does about it:integrationat install andcleanupat removal, in the parent’scounter, andcleanuponly for an instance whosecleanupis true.
An add-on for the vApp names a board setup: this one starts its count at a hundred and keeps it when the board goes.
vapp: boardtitle: Centurydescription: a board that starts at a hundred and keeps its countdefault: latestversions: latest: start: 100 cleanup: falseThe vApp is part of the app, so it reaches the cluster in a new archive. Pack guestbook 1.3.1 and point the index at it.
$ sed -i 's/^version: "1.3.0"/version: "1.3.1"/' ~/learn/guestbook/app.yaml$ tar -czf ~/learn/shelf/files/guestbook-1.3.1.app -C ~/learn/guestbook app.yaml vars.yaml shc.yaml web.env icon.svg site seed.job.yaml count.job.yaml report.job.yaml ping-shelf.job.yaml counter.socket.yaml board.vapp.yaml board.vvars.yaml board.vplug.yaml board.vsocket.yaml addonsapi_version: v2apps: - name: guestbook description: A page, an API under its path and a counter category: demo tags: [demo, redis, nginx] homepage: https://example.com/guestbook versions: - version: "1.3.1" archive: guestbook-1.3.1.app - version: "1.3.0" archive: guestbook-1.3.0.app - version: "1.2.1" archive: guestbook-1.2.1.app - version: "1.2.0" archive: guestbook-1.2.0.app$ shc update shelf...$ shc repo sync mine...$ shc search --kind vapp...A plug of guestbook can ask for a board when its edge connects. Its vapp
block names the vApp, the add-on and the instance, and mode: create makes
the instance after the consumer deploys and keeps it when the edge goes.
This one points at keyfront’s store, which this ladder never installs, so
the edge never connects; shc validate reads it.
socket: storerequired: falseservices: - webvapp: name: board addon: century instance: store mode: create$ shc validate ~/learn/guestbook...An add-on of a vApp is read with --vapp, which names the vApp it belongs
to. --instance names the instance a vApp would be installed as, beside
--into for its parent.
$ shc addon versions guestbook/century --vapp board --app-dir ~/learn/guestbook...$ shc addon show guestbook/century --vapp board --app-dir ~/learn/guestbook...$ shc show guestbook/board --into party --instance kids...$ shc catalog show guestbook/board --into party --instance kids...$ shc catalog compile guestbook/board --addon century --into party --instance kids...Install a board named kids into party. --into names the parent and
--instance the board. The add-on is installed by its app and its name, and
the instance takes the add-on’s name.
$ shc install guestbook/board --into party --instance kids...$ shc install guestbook/century --into party...$ shc ls...$ shc exec -s party -S counter -- redis-cli mget board:kids board:century0100Remove both. kids took the default cleanup, true, so its count goes;
century took the add-on’s false, so its count stays.
$ shc uninstall party/kids --yes...$ shc uninstall party/century --yes...$ shc exec -s party -S counter -- redis-cli exists board:kids board:century1$ shc uninstall party --yes...Next: Copies and deployfiles.