Modifying a Stack

Michael Delzer Updated by Michael Delzer

Modifying a Stack Using Git

Requirements

To follow this tutorial you will need a git CLI client (or other git client of your choice).

Guide

AgileStacks templates would not be as powerful, if you were unable to modify them by adding new components or removing unneeded ones.

To modify your stack template, you will need to clone its git repository.

First open Templates -> List section in a navigation bar of AgileStacks control plane. Find the stack template by the stack you would like to modify. On this screen you will see the address to your git repository. To access it you can use a SSH key you have defined in your user profile, or a secret key issued to you in the SuperHub WebUI. In this tutorial we will use the second option. Press Show secret URL in Stack Template source code section and then press Copy URL. The URL you see will be copied in you exchange buffer.

Now, open a terminal with your favorite shell, and clone a git repository from your exchange buffer:

git clone https://__YOUR_KEY__@git.agilestacks.io/repo/__ORGANISATION__/__TEMPLATE__

Enter the newly created directory:

cd __TEMPLATE__

The essential part of the template is a hub.yaml file. This file contains information about all of the components that are deployed in stacks with your template. In params folder you will find a file for each of your stack and also a user.yaml where you can redefine parameters for new stacks.

Imagine we have a stack template containing PostgreSQL component. The stack created with is this template used to run a backend application which uses the database. During development a team decided that they will also require MongoDB, for their application, and instead of creating a new template they want to modify the one they are already using.

To do this lets modify our hub.yaml and params/user.yaml and use a toolbox shell script to deploy our new component.

First we need to declare a new component in hub.yaml. Lets add the following line to components section:

  - name: mongodb
source:
dir: components/mongodb
- name: mongodb-web
depends:
- mongodb
source:
dir: components/mongodb-web

We have added two components since we want to also have a web UI for mongodb. Also we need to declare these components in lifecycle.order:

    - mongodb
- mongodb-web

Next, we need to add the parameters required by both components to params/user.yaml:

parameters:
- name: component.mongodb
component: mongodb
parameters:
- name: storageType
value: ebs
- name: volumeSize
value: 8Gi
- name: volumeType
value: gp2
- name: user
value: mongodb
- name: password
value: mongodb
- name: database
value: mongodb

You can find the description of all parameters for mongodb component in components/mongodb/hub.yaml.

Lets commit our changes to the template:

git commit -am "Added mongodb component"
git push origin master

Now we can deploy a new stack for our application from the AgileStacks control plane. This stack will also contain an instance of mongodb component.

Like what you see? Request a demo today!


How did we do?

Create a Stack Template

Access Stack Instance Components

Contact