Hello world / Walkthrough
Please read :ref:`local-setup` to make sure you installed Python and Docker correctly.
- Docker needs to be version 1.9 or higher
- Python 3.4 or higher including pip is required
- Make sure your console environment is UTF-8 (
export LC_ALL=en_US.utf-8; export LANG=en_US.utf-8)
This guide should show all steps for one sample application from birth to death. Please see the other sections in the :ref:`user-guide` for more information about specific topics.
Install STUPS command line tools and configure them.
$ sudo pip3 install --upgrade stups $ stups configure
First of all clone this example project:
$ git clone https://github.com/zalando-stups/zalando-cheat-sheet-generator.git $ cd zalando-cheat-sheet-generator
Create this new application using the :ref:`yourturn` web frontend:
Now you will need to create the :ref:`scm-source-json` file that links your Docker image to a specific git revision number.
Let's start the application and see if all works:
$ python3 -m http.server 8000 http://localhost:8000/index.html?schema=schema/stups.json
Nice! Let's build the Docker images:
Build with the Dockerfile in the repo.
$ docker build -t pierone.stups.example.org/<your-team>/zalando-cheat-sheet-generator:0.1 .
And now see if it is listed locally:
$ docker images
Let's also try if the docker images works!
$ docker run -p 8000:8000 -it pierone.stups.example.org/<your-team>/zalando-cheat-sheet-generator:0.1 # and test with this url: http://localhost:8000/index.html?schema=schema/stups.json
If all works, we are ready to login in :ref:`pierone` and push it.
$ pierone login $ docker push pierone.stups.example.org/<your-team>/zalando-cheat-sheet-generator:0.1
Let's check if we can find it in the Pier One repository (login needed if your token expired):
$ pierone login $ pierone tags <your-team> zalando-cheat-sheet-generator
Configure your application's mint bucket (click on the "Access Control" button on your app's page in YOUR TURN).
This will trigger the mint worker to write your app credentials to your mint bucket.
List AWS account:
$ mai list
Login via console to your AWS account:
$ mai login <account-name>
Wait for the first credentials to appear:
$ aws s3 ls s3://mint-example-bucket # there should be a new folder for your application
Create a :ref:`senza` definition file for that (using the region you are on):
$ senza init --region eu-west-1 deploy-definition.yaml
- Choose the "webapp" template.
- Enter the application ID "zalando-cheat-sheet-generator"
- Enter the docker image "pierone.stups.example.org/<your-team>/zalando-cheat-sheet-generator"
- Enter the port "8000" (see the Dockerfile [why 8000?? no reason for that :D])
- Health check path is the default "/" (would obviously be better to have a specific one)
- Go for "t2.micro"
- Use the default mint bucket
Take the internal LB! We have no OAUTH2 configured!
- and let senza create the security groups and IAM role for us.
Note: if you don't want to specify the region with every senza call, run
After this, you can also add a log provider or other configuration, if you like to encrypt your password check this :ref:`guide <key-encryption>`.
Create your Cloud Formation stack.
$ senza create deploy-definition.yaml 1 0.1
- Senza will generate CF JSON
- CF stack is created
- ASG launches Taupage instance
- Taupage starts Scalyr agent
- Taupage runs berry to download app credentials
- Taupage pushes Taupage config userdata to fullstop.
- Taupage pulls Docker image from Pier One using the app credentials
- Taupage starts the Docker container
- Taupage signals CFN
Wait for completion by watching the Senza status output.
$ senza status deploy-definition.yaml -W
or senza events:
$ senza events deploy-definition.yaml 1 -W
In case of error go to your log provider, if you did not configure it. Go in aws, EC2 service, find your instance, right click, Instance Settings, Get System Log
$ curl -v http://<address>:8000/index.html?schema=schema/stups.json
This will not work! Because of the missing OAUTH2 we have created an internal LB. To test it we will need to :ref:`follow the same guide as for a DB connection <dig-a-tunnel>` and than try again.
Get instance IP and use it in the ssh call below:
$ senza instances zalando-cheat-sheet-generator
$ piu odd-eu-west-1.<your-team>.example.org "test zalando-cheat-sheet-generator application" $ ssh -L 63333:<ip-address>:8000 odd-eu-west-1.<your-team>.example.org
Now you can test via curl or browser:
$ curl -v http://localhost:63333/index.html?schema=schema/stups.json
Route 100% traffic to your new stack version 1.
$ senza traffic zalando-cheat-sheet-generator 1 100
Shut down the stack.
$ senza delete zalando-cheat-sheet-generator 1