Catalog Recipes

Overview


Catalog Recipes are JSON configuration entries in catalogs collection in core provision database; each catalog represents a recipe to deploy an nginx - service - daemon - mongo - elasticsearch - nodejs service or any custom type.

Once a catalog recipe is created, you can then use it in the Clouds & Deployments section to deploy your services.

Sections


  1. Generic Schema Explanation
    1. Docker Swarm Voluming
    2. Kubernetes Voluming
  2. Service Catalog Recipe
  3. Daemon Catalog Recipe
  4. Nginx Catalog Recipe
  5. Mongo Catalog Recipe
  6. Elasticsearch Catalog Recipe
  7. NodeJs Catalog Recipe
  8. Environment Variables
    1. Static Variables
    2. Computed Variables
    3. User Input Variables



Generic Schema Explanation


Generic Schema Explained
{
	"name": "Service Recipe",	//catalog recipe name
	"type": "soajs",			//catalog recipe type
	"subtype": "service",		//catalog recipe subtype supporting only service or daemon and applicable for soajs only
	"description": "This is a sample service catalog recipe", //catalog recipe description
	"locked": true,				//if catalog recipe is locked, it cannot be modified but you can create copies out of it
	"recipe": {					//catalog recipe configuration
		"deployOptions": {		//recipe deployment options
			"image": {			//recipe image
				"prefix": "soajsorg",	//image prefix
				"name": "soajs",		//image name
				"tag": "latest",		//image tag
				"pullPolicy": "Always"	//image pull policy (only valid for kubernetes),
				"override": false //if set to true, then when using this catalog recipe in the deploy pillar, you can change the values of prefix, name and tag before you submit
			},
			"specifyGitConfiguration": true,		//if set to true, then when deploying a soajs service or daemon, the deployer will ask you to provide the git information of the repo to pull the code from
			"readinessProbe": {		//readiness probe configuration, any valid kubernetes config is allowed
				"httpGet": {		//http readinesss probe configuration example
					"path": "/heartbeat",	//Endpoint to hit when probing
					"port": "maintenance"	//Target port for probe, can be a string (for labeled ports) or number
				},
				"initialDelaySeconds": 5,	//Number of seconds after the container has started before liveness probes are initiated
				"timeoutSeconds": 2,		//Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1
				"periodSeconds": 5,			//How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1
				"successThreshold": 1,		//Minimum consecutive successes for the probe to be considered successful after having failed.
				"failureThreshold": 3		//Minimum consecutive failures for the probe to be considered failed after having succeeded
			},
			"restartPolicy": {		//swarm specific restart policy for containers
				"condition": "",	//Restart condition: none, on-failure, any
				"maxAttempts": 0	//maximum number of restart attempts
			},
			"container": {			//Container related deploy options
				"network": "",		//Docker network that the container should plug to (only applicable for swarm)
				"workingDir": ""	//Container working directory
			},
			"ports": [		//Port mapping
				{
					"name": "http",		//Port name
					"target": 80,		//Target port at container level
					"isPublished": true,	//Flag that specifies a published port
					"published": 81		//Optional exposed port (for kubernetes, 30000 is automatically added to the port number)
				}
			]
			"voluming": {}	//Voluming configuration, content depends on platform (swarm or kubernetes), refer to the samples below for more details
		},
		"buildOptions": {
			"settings": {
				"accelerateDeployment": true	//if set to true, then the deployer will copy soajs from the soajsorg/soajs image instead of installing it using npm
			},
			//catalog recipe environment variables that are passed on to the service container(s) to be deployed
			//environment variables are explained in detail in the last section of this page
			"env": {							
				"NODE_ENV": {
					"type": "static",
					"value": "production"
				},
				"SOAJS_ENV": {
					"type": "computed",
					"value": "$SOAJS_ENV"
				},
				"MY_ENV": {
					"type": "userInput",
					"label": "My Environment Variable",
					"default": "something",
					"fieldMsg": "Enter the value of this field to use in your deployment"
				}
			},
			"cmd": {							//catalog recipe command to execute
				"deploy": {
					"command": [				//command to execute
						"bash",
						"-c"
					],
					"args": [					//command arguments
						"node index.js -T service"
					]
				}
			}
		}
	}
}

Docker Swarm Voluming

"voluming": {	//Voluming configuration
	"volumes": [	//Volumes array, objects have a free schema, any valid swarm volume can be set
		{
			 "Type": "volume",	//Type of volume: can be volume or bind
             "Source": "/data/custom/db/",	//Volume source: can be a path or a volume name
             "Target": "/data/db/"		//Volume target where it will be mounted inside a container
		}
	]
}

Reference : https://docs.docker.com/engine/tutorials/dockervolumes/


Kubernetes Voluming

"voluming": {	//Voluming configuration
	"volumes": [	//Volumes array, objects have a free schema, any valid kubernetes volume can be set
		 "name" : "custom-mongo-volume", 	//Volume name
         "hostPath" : {		//Example of host volume configuration
         	"path" : "/data/custom/db/"		//Path of volume on the host filesystem
          }
	],
	"volumeMounts": [	//Volume mounts configuration example
		{
			"mountPath" : "/data/db/", //Path where the volume will be plugged at the pod level
			"name" : "custom-mongo-volume"	//Name of the volume to be plugged
		}
	]
}

Reference : https://kubernetes.io/docs/concepts/storage/volumes/



Service Catalog Recipe


The following recipe allows the deployment of SOAJS services and controllers

Service Sample Recipe
{
	"name": "Service Recipe",
	"type": "soajs",
	"subtype": "service",
	"description": "This is a sample service catalog recipe",
	"locked": true,
	"recipe": {
		"deployOptions": {
			"image": {
				"prefix": "soajsorg",
				"name": "soajs",
				"tag": "latest",
				"pullPolicy": "Always"
			},
			"specifyGitConfiguration": true,
			"readinessProbe": {
				"httpGet": {
					"path": "/heartbeat",
					"port": "maintenance"
				},
				"initialDelaySeconds": 5,
				"timeoutSeconds": 2,
				"periodSeconds": 5,
				"successThreshold": 1,
				"failureThreshold": 3
			},
			"restartPolicy": {
				"condition": "",
				"maxAttempts": 0
			},
			"container": {
				"network": "",
				"workingDir": ""
			},
			"voluming": {}
		},
		"buildOptions": {
			"settings": {
				"accelerateDeployment": true
			},
			"env": {
				"NODE_ENV": {
					"type": "static",
					"value": "production"
				},
				"SOAJS_ENV": {
					"type": "computed",
					"value": "$SOAJS_ENV"
				},
				"SOAJS_PROFILE": {
					"type": "static",
					"value": "/opt/soajs/FILES/profiles/profile.js"
				},
				"SOAJS_SRV_AUTOREGISTERHOST": {
					"type": "static",
					"value": "true"
				},
				"SOAJS_SRV_MEMORY": {
					"type": "computed",
					"value": "$SOAJS_SRV_MEMORY"
				},
				"SOAJS_GC_NAME": {
					"type": "computed",
					"value": "$SOAJS_GC_NAME"
				},
				"SOAJS_GC_VERSION": {
					"type": "computed",
					"value": "$SOAJS_GC_VERSION"
				},
				"SOAJS_GIT_OWNER": {
					"type": "computed",
					"value": "$SOAJS_GIT_OWNER"
				},
				"SOAJS_GIT_BRANCH": {
					"type": "computed",
					"value": "$SOAJS_GIT_BRANCH"
				},
				"SOAJS_GIT_COMMIT": {
					"type": "computed",
					"value": "$SOAJS_GIT_COMMIT"
				},
				"SOAJS_GIT_REPO": {
					"type": "computed",
					"value": "$SOAJS_GIT_REPO"
				},
				"SOAJS_GIT_TOKEN": {
					"type": "computed",
					"value": "$SOAJS_GIT_TOKEN"
				},
				"SOAJS_DEPLOY_HA": {
					"type": "computed",
					"value": "$SOAJS_DEPLOY_HA"
				},
				"SOAJS_HA_NAME": {
					"type": "computed",
					"value": "$SOAJS_HA_NAME"
				},
				"SOAJS_MONGO_NB": {
					"type": "computed",
					"value": "$SOAJS_MONGO_NB"
				},
				"SOAJS_MONGO_PREFIX": {
					"type": "computed",
					"value": "$SOAJS_MONGO_PREFIX"
				},
				"SOAJS_MONGO_RSNAME": {
					"type": "computed",
					"value": "$SOAJS_MONGO_RSNAME"
				},
				"SOAJS_MONGO_AUTH_DB": {
					"type": "computed",
					"value": "$SOAJS_MONGO_AUTH_DB"
				},
				"SOAJS_MONGO_SSL": {
					"type": "computed",
					"value": "$SOAJS_MONGO_SSL"
				},
				"SOAJS_MONGO_IP": {
					"type": "computed",
					"value": "$SOAJS_MONGO_IP_N"
				},
				"SOAJS_MONGO_PORT": {
					"type": "computed",
					"value": "$SOAJS_MONGO_PORT_N"
				}
			},
			"cmd": {
				"deploy": {
					"command": [
						"bash",
						"-c"
					],
					"args": [
						"node index.js -T service"
					]
				}
			}
		}
	}
}



Daemon Catalog Recipe


The following recipe allows the deployment of SOAJS daemon

Daemon Sample Recipe
{
	"_id": ObjectId('59143f97b418be4c8e85d052'),
	"name": "Daemon Recipe",
	"type": "soajs",
	"subtype": "daemon",
	"description": "This is a sample daemon recipe",
	"locked": true,
	"recipe": {
		"deployOptions": {
			"image": {
				"prefix": "soajsorg",
				"name": "soajs",
				"tag": "latest",
				"pullPolicy": "Always"
			},
			"specifyGitConfiguration": true,
			"readinessProbe": {
				"httpGet": {
					"path": "/heartbeat",
					"port": "maintenance"
				},
				"initialDelaySeconds": 5,
				"timeoutSeconds": 2,
				"periodSeconds": 5,
				"successThreshold": 1,
				"failureThreshold": 3
			},
			"restartPolicy": {
				"condition": "",
				"maxAttempts": 0
			},
			"container": {
				"network": "",
				"workingDir": ""
			},
			"voluming": {}
		},
		"buildOptions": {
			"settings": {
				"accelerateDeployment": true
			},
			"env": {
				"NODE_ENV": {
					"type": "static",
					"value": "production"
				},
				"SOAJS_ENV": {
					"type": "computed",
					"value": "$SOAJS_ENV"
				},
				"SOAJS_PROFILE": {
					"type": "static",
					"value": "/opt/soajs/FILES/profiles/profile.js"
				},
				"SOAJS_SRV_AUTOREGISTERHOST": {
					"type": "static",
					"value": "true"
				},
				"SOAJS_SRV_MEMORY": {
					"type": "computed",
					"value": "$SOAJS_SRV_MEMORY"
				},
				"SOAJS_DAEMON_GRP_CONF": {
					"type": "computed",
					"value": "$SOAJS_DAEMON_GRP_CONF"
				},
				"SOAJS_GIT_OWNER": {
					"type": "computed",
					"value": "$SOAJS_GIT_OWNER"
				},
				"SOAJS_GIT_BRANCH": {
					"type": "computed",
					"value": "$SOAJS_GIT_BRANCH"
				},
				"SOAJS_GIT_COMMIT": {
					"type": "computed",
					"value": "$SOAJS_GIT_COMMIT"
				},
				"SOAJS_GIT_REPO": {
					"type": "computed",
					"value": "$SOAJS_GIT_REPO"
				},
				"SOAJS_GIT_TOKEN": {
					"type": "computed",
					"value": "$SOAJS_GIT_TOKEN"
				},
				"SOAJS_DEPLOY_HA": {
					"type": "computed",
					"value": "$SOAJS_DEPLOY_HA"
				},
				"SOAJS_HA_NAME": {
					"type": "computed",
					"value": "$SOAJS_HA_NAME"
				},
				"SOAJS_MONGO_NB": {
					"type": "computed",
					"value": "$SOAJS_MONGO_NB"
				},
				"SOAJS_MONGO_PREFIX": {
					"type": "computed",
					"value": "$SOAJS_MONGO_PREFIX"
				},
				"SOAJS_MONGO_RSNAME": {
					"type": "computed",
					"value": "$SOAJS_MONGO_RSNAME"
				},
				"SOAJS_MONGO_AUTH_DB": {
					"type": "computed",
					"value": "$SOAJS_MONGO_AUTH_DB"
				},
				"SOAJS_MONGO_SSL": {
					"type": "computed",
					"value": "$SOAJS_MONGO_SSL"
				},
				"SOAJS_MONGO_IP": {
					"type": "computed",
					"value": "$SOAJS_MONGO_IP_N"
				},
				"SOAJS_MONGO_PORT": {
					"type": "computed",
					"value": "$SOAJS_MONGO_PORT_N"
				}
			},
			"cmd": {
				"deploy": {
					"command": [
						"bash",
						"-c"
					],
					"args": [
						"node index.js -T service"
					]
				}
			}
		}
	}
}




Nginx Catalog Recipe


The following recipe allows the deployment of an Nginx Container.

Nginx Catalog Recipe
{
	"_id": ObjectId('59143f97b418be4c8e85d053'),
	"name": "Nginx Recipe",
	"type": "nginx",
	"description": "This is a sample nginx recipe",
	"locked": true,
	"recipe": {
		"deployOptions": {
			"image": {
				"prefix": "soajsorg",
				"name": "nginx",
				"tag": "latest",
				"pullPolicy": "Always"
			},
			"readinessProbe": {
				"httpGet": {
					"path": "/",
					"port": "http"
				},
				"initialDelaySeconds": 5,
				"timeoutSeconds": 2,
				"periodSeconds": 5,
				"successThreshold": 1,
				"failureThreshold": 3
			},
			"restartPolicy": {
				"condition": "",
				"maxAttempts": 0
			},
			"container": {
				"network": "",
				"workingDir": ""
			},
			"voluming": {},
			"ports": [
				{
					"name": "http",
					"target": 80,
					"isPublished": true,
					"published": 81
				},
				{
					"name": "https",
					"target": 443,
					"isPublished": true,
					"published": 444
				}
			]
		},
		"buildOptions": {
			"env": {
				"SOAJS_ENV": {
					"type": "computed",
					"value": "$SOAJS_ENV"
				},
				"SOAJS_NX_DOMAIN": {
					"type": "computed",
					"value": "$SOAJS_NX_DOMAIN"
				},
				"SOAJS_NX_API_DOMAIN": {
					"type": "computed",
					"value": "$SOAJS_NX_API_DOMAIN"
				},
				"SOAJS_NX_SITE_DOMAIN": {
					"type": "computed",
					"value": "$SOAJS_NX_SITE_DOMAIN"
				},
				"SOAJS_NX_CONTROLLER_NB": {
					"type": "computed",
					"value": "$SOAJS_NX_CONTROLLER_NB"
				},
				"SOAJS_NX_CONTROLLER_IP": {
					"type": "computed",
					"value": "$SOAJS_NX_CONTROLLER_IP_N"
				},
				"SOAJS_NX_CONTROLLER_PORT": {
					"type": "computed",
					"value": "$SOAJS_NX_CONTROLLER_PORT"
				},
				"SOAJS_DEPLOY_HA": {
					"type": "computed",
					"value": "$SOAJS_DEPLOY_HA"
				},
				"SOAJS_HA_NAME": {
					"type": "computed",
					"value": "$SOAJS_HA_NAME"
				}
			},
			"cmd": {
				"deploy": {
					"command": [
						"bash",
						"-c"
					],
					"args": [
						"node index.js -T nginx"
					]
				}
			}
		}
	}
}



Mongo Catalog Recipe


The following recipe allows the deployment of a Mongo Container.

Mongo Catalog Recipe
{
	"_id": ObjectId('59143f97b418be4c8e85d054'),
	"name": "Mongo Recipe",
	"type": "mongo",
	"description": "This is a sample mongo recipe",
	"locked": true,
	"recipe": {
		"deployOptions": {
			"image": {
				"prefix": "",
				"name": "mongo",
				"tag": "latest",
				"pullPolicy": "Always"
			},
			"readinessProbe": {
				"httpGet": {
					"path": "/",
					"port": 27017
				},
				"initialDelaySeconds": 5,
				"timeoutSeconds": 2,
				"periodSeconds": 5,
				"successThreshold": 1,
				"failureThreshold": 3
			},
			"restartPolicy": {
				"condition": "",
				"maxAttempts": 0
			},
			"container": {
				"network": "",
				"workingDir": ""
			},
			"voluming": {},
			"ports": [
				{
					"name": "mongo",
					"target": 27017,
					"isPublished": true
				}
			]
		},
		"buildOptions": {
			"env": {},
			"cmd": {
				"deploy": {
					"command": [
						"mongod"
					],
					"args": [
						"--smallfiles"
					]
				}
			}
		}
	}
}



Elasticsearch Catalog Recipe


The following recipe allows the deployment of an ElasticSearch Container.

ElasticSearch Catalog Recipe
{
	"_id": ObjectId('59143f97b418be4c8e85d055'),
	"name": "Elasticsearch Recipe",
	"type": "es",
	"description": "This is a sample elasticsearch recipe",
	"locked": true,
	"recipe": {
		"deployOptions": {
			"image": {
				"prefix": "",
				"name": "elasticsearch",
				"tag": "latest",
				"pullPolicy": "Always"
			},
			"readinessProbe": {
				"httpGet": {
					"path": "/",
					"port": 9200
				},
				"initialDelaySeconds": 5,
				"timeoutSeconds": 2,
				"periodSeconds": 5,
				"successThreshold": 1,
				"failureThreshold": 3
			},
			"restartPolicy": {
				"condition": "",
				"maxAttempts": 0
			},
			"container": {
				"network": "",
				"workingDir": ""
			},
			"voluming": {},
			"ports": [
				{
					"name": "es",
					"target": 9200,
					"isPublished": true
				}
			]
		},
		"buildOptions": {
			"env": {},
			"cmd": {
				"deploy": {
					"command": [],
					"args": []
				}
			}
		}
	}
}



NodeJs Catalog Recipe


The following recipe allows the deployment of a NodeJS Container.

NodeJS Catalog Recipe
{
	"_id": ObjectId('59143f97b418be4c8e85d051'),
	"name": "Nodejs Recipe",
	"type": "service",
	"description": "This is a sample nodejs catalog recipe",
	"locked": true,
	"recipe": {
		"deployOptions": {
			"image": {
				"prefix": "soajsorg",
				"name": "soajs",
				"tag": "latest",
				"pullPolicy": "Always"
			},
			"readinessProbe": {
				"httpGet": {
					"path": "/",
					"port": ""
				},
				"initialDelaySeconds": 5,
				"timeoutSeconds": 2,
				"periodSeconds": 5,
				"successThreshold": 1,
				"failureThreshold": 3
			},
			"restartPolicy": {
				"condition": "",
				"maxAttempts": 0
			},
			"container": {
				"network": "",
				"workingDir": ""
			},
			"voluming": {
				"volumes": [],
				"volumeMounts": []
			}
		},
		"buildOptions": {
			"settings": {
				"accelerateDeployment": true
			},
			"env": {
				"NODE_ENV": {
					"type": "static",
					"value": "production"
				}
			},
			"cmd": {
				"deploy": {
					"command": [],
					"args": []
				}
			}
		}
	}
}



Environment Variables


The catalog recipe provide the ability to send environment variables to the service container(s) you are deploying.

These environment variables are classified to 3 categories: 


Static

This environment variable provided a static value of type string. 

Static Environment Variable
"NODE_ENV": {				//variable name in your code
	"type": "static",		//type is static
	"value": "production"	//value is the word production
}


Computed

This environment variable is computed by SOAJS then assigned before passing the recipe to the deployer to deploy the service container(s).

The full list of supported computed environment variables is found on this page and detailed in depth, Click here to see the list.

Computed Environment Variable
"CONTROLLER_IP": {							//variable name in your code
	"type": "computed",						//type is computed
	"value": "$SOAJS_NX_CONTROLLER_IP_N"	//the variable that SOAJS should match from its list and replace here
}

When you deploy a service, you pick the catalog recipe. SOAJS will then load the list of its environment variables and match them to all the computed variables of your recipe.

The above will result in creating an environment variable called CONTROLLER_IP whose value is 127.0.0.1 for example.

After your deploy your service, if you click on the inspect operation from maintenance operations, you will find that the value of your computed variable is now:

Computed Environment Variable Rendered
"CONTROLLER_IP": {			//variable name in your code
	"type": "computed",		//type is computed
	"value": "127.0.0.1"	//if the value of $SOAJS_NX_CONTROLLER_IP_N is 127.0.0.1 in SOAJS for example, then your env variable will now have that value
}


User Input

This environment variable depicts that the user should provide its value while deploying a service.

This means that when you are deploying a new service, if you pick the catalog recipe, SOAJS Dashboard will create new inputs for each environment variable whose type is userInput.

Provide the value of these variables and click deploy.

User Input Environment Variable
"MY_ENV": {										//variable name in your code
	"type": "userInput",						//type is userInput
	"label": "My Custom User Input Variable",	//label to show above the input when attempting to deploy using this recipe
	"default": "something",						//default value of the input that shows up when attempting to deploy using this recipe
	"fieldMsg": "Enter the value of your custom environment variable." //descriptive message that below the input that shows up when attempting to deploy using this recipe
}