Skip to content

Instantly share code, notes, and snippets.

@apcera-code
apcera-code / apcera-multi-resource-manifest.json
Created September 13, 2016 20:54
Using Apcea’s MRM it is possible to deploy a fully functioning Wordpress application and securely connect it to a new or existing MySql Database with a single deployment command that can be repeated time and time again in different contexts.
```json
{
"jobs": {
"job::/sandbox/dean::dockerwp": {
"docker": {
"image": "wordpress:latest"
},
"services" : {
"mysql-dockerwp" : {
"fqn" : "service::/sandbox/dean::mysql-dockerwp"
@apcera-code
apcera-code / apc-manifest-deploy-cast-docker-microservice.json
Created September 13, 2016 17:04
And what about if instead I am not deploying from code, but my app is already in a Docker image. No problem, the Apcera Platform can also pull images from any docker repository, and to test it out you can use this manifest file
Deploying manifest...
[manifest] -- Deploy -- execution started
[castserver] -- Pulling Docker image -- checking policy
[castserver] -- Pulling Docker image -- checking if package FQN is taken
[castserver] -- Pulling Docker image -- fetching image metadata
[castserver] -- Pulling Docker image -- creating package
[castserver] -- Pulling Docker image -- all layers downloaded
[manifest] -- Deploy -- checking if policy allows binding "job::/sandbox/simone::castclient" to "service::/sandbox/simone::nats-server"
[manifest] -- Deploy -- checking if policy allows binding "job::/sandbox/simone::castserver" to "service::/sandbox/simone::nats-server"
[manifest] -- Deploy -- checking if policy allows updates on "job::/sandbox/simone::castserver"
@apcera-code
apcera-code / apc-manifest-deploy-cast-microservice.json
Created September 13, 2016 16:26
Once you have done the first deployment manually or you have already in the platform the packages for the 2 components of the application (the server and the client), you can simply deploy a manifest file that describe the topology of the application with a single command: apc manifest deploy cast-microservice.json
Deploying manifest...
[manifest] -- Deploy -- execution started
[manifest] -- Deploy -- looking up "package::/sandbox/simone::cast-client"
[manifest] -- Deploy -- looking up "package::/sandbox/simone::cast-server"
[manifest] -- Deploy -- checking if policy allows binding "job::/sandbox/simone::castclient" to "service::/sandbox/simone::nats-server"
[manifest] -- Deploy -- checking if policy allows binding "job::/sandbox/simone::castserver" to "service::/sandbox/simone::nats-server"
[manifest] -- Deploy -- skip creating "service::/sandbox/simone::nats-server" since it already exists
[manifest] -- Deploy -- creating "job::/sandbox/simone::castclient"
[manifest] -- Deploy -- created "job::/sandbox/simone::castclient"
[manifest] -- Deploy -- creating "job::/sandbox/simone::castserver"
@apcera-code
apcera-code / PV->SvcGroups.go
Created September 6, 2016 23:32
The controlling policy which grants the jobs binding permission then takes the form of the following four rules:
on job::/ {
if (service == PV->SvcGroups.service)
{
request_category PV->SvcGroups.category
}
if (request_category == PV->Bindings.svcCategory &&
query->target fqnMatch PV->Bindings.jobNamespace)
{
permit bind
@apcera-code
apcera-code / controlling-policy.go
Created September 6, 2016 23:24
The controlling policy, which grants admin users the ability to bind to restricted services, takes the form of the following two rules:
on job::/ {
if (PV->SvcGroups.category == restricted &&
service == PV->SvcGroups.service &&
role == admin)
{
permit bind
}
}
on service::/ {
@apcera-code
apcera-code / apc-event-helloworld
Last active August 23, 2016 18:44
one way of subscribing to an FQN using Apcera’s CLI, APC
apc event subscribe job::/sandbox/user::helloworld
@apcera-code
apcera-code / wamp-client.go
Last active February 12, 2018 23:18
Sample WAMP client written in Go using an open-source WAMP Go library
package main
import (
"fmt"
turnpike "gopkg.in/jcelliott/turnpike.v2"
)
// Events realm for WAMP protocol specified by Apcera Platform.
const (
eventsRealm = "com.apcera.api.es"
apc capsule create efs-capsule1 --image linux -ae --batch
apc service bind efs-service-1 --job efs-capsule1 --batch -- --mountpath /an/unlimited/supply
apc capsule connect efs-capsule1
apc service create efs-service-1 \
--provider awsefs \
--description 'Amazon EFS Service' \
--batch
apc provider register awsefs --type nfs \
--url "nfs://10.0.0.112/" \
--description 'Amazon EFS' \
--batch \
-- --version 4.1