Giter VIP home page Giter VIP logo

ship-voting-app-redis's Introduction

Shippable Voting App

This sample creates a multi-container application in a GKE Kubernetes cluster. The application interface has been built using Python / Flask. The data component is using Redis.

Shippable workflow

The workflow in this sample application is multi-stage deployments into Test and Prod environments.

Shippable Assembly Lines workflow for a multi-stage deployment to Kubernetes on GKE

The challenge with this is that the configuration of the app changes in each environment. You therefore need a config file that is specific to application/service/microservice and the environment! This creates a new DevOps matrix from hell which is explained in detail in our blog.

With Shippable, you just need one Kubernetes template spec and you have the ability to replace environment specific values at runtime during deployment. This avoids the matrix from hell and creates an Assembly Line for your application as it moves from code to test to prod.

Pre-requisites

You need the following in order to run this sample:

If you're not familiar with Shippable, it is also recommended that you read the Platform overview docs to understand the overall structure of Shippable's DevOps Assembly Lines platform.

Instructions

Step 1: Fork the application

Fork this repository to your GitHub account.

Step 2: Create integrations

Since your deployment config will interact with GCR to push the front-end image and GKE to deploy the application, you will need to create integrations for these in the Shippable UI.

Follow steps in Adding an account integration section to create these integrations:

You will also need to create a GitHub integration to access contents of your repository. Make sure the friendly name of this integration is dr_github.

Step 3: Edit the config

Edit the following files:

In shippable.resources.yml:

  • In the ship_voting_app_redis_gitRepo resource definition, replace devops-recipes/ship-voting-app-redis with the name of your forked repo
  • In the front_img resource definition, replace gcr.io/devops-samples/vote with gcr.io/YOUR-GCLOUD-PROJECT-ID/vote. To find the project ID, follow instructions here
  • In kube_cluster, replace the value of sourceName and region with the name of your GKE cluster name and region.

In shippable.jobs.yml:

  • In the build_image job definition, replace gcr.io/devops-samples/vote with gcr.io/YOUR-GCLOUD-PROJECT-ID/vote. To find the project ID, follow instructions here

Step 4: Import config into shippable

Follow these instructions to add your config to Shippable: Adding a syncRepo

To see a graphical view of your workflow, click on the eye icon on your Subscription Dashboard to view your Single Pane of Glass.

Step 5: Run the build_image job

Right click on the build_image job in your SPOG view and click on Build. This will trigger your workflow and deploy application to with the test labels. Deploy to production is manual and you can right click on the deploy_prod job to run it and deploy to prod.

Understanding the sample

Here are some links that will help you understand how the sample is structured:

  • This sample extensively uses the shipctl utility to perform common operations like:

    • To extract information from IN resources
    • Put information in OUT resources
    • Replacing environment values in the Kubernetes spec template for each environment.
  • Reference for jobs and resources used in this sample:

    • build_image is a runSh job that builds and pushes the front-end image to GCR
    • deploy_test is a runSh job that takes the deployment template ship_vote_all_in_one_redis.yml.template, replaces the environment values needed for test deployment, and deploys both front_img and redis images. It also outputs relstate which is an updated deployment spec with immutable image tags to test.
    • deploy_prod is a runSh job that takes the deployment spec from relstate, replaces the labels needed for prod deployment, and deploys both front_img and redis images to production.
    • test_params and prod_params are params resources that contain values for labels for test and prod respectively
    • kube_cluster is a cluster resource that points to your Kubernetes cluster on GKE
    • relstate is a state resource that hold the immutable release spec
    • gcloud_cliConfig is a cliConfig resource that points to your GKE integration so we can initialize gcloud cli on your behalf
    • front_img is an image resource represents the Docker image of your front-end service stored in GCR
    • ship_voting_app_redis_gitRepo is a gitRepo resource a pointer to your github repository. This is an input to any job that needs content from this repository.

ship-voting-app-redis's People

Contributors

ambarish2012 avatar manishas avatar shippablejedi avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.