Coder Social home page Coder Social logo

kubecamp-app's Introduction

kubecamp-app

This repository contains a sample Python Flask application, along with the various glue to mimic an end-to-end workflow for a containerized application to run in a production Kubernetes cluster, with support from a central platform organization.

The tooling utilized incldues:

It utilizes two additional repos:

  • kubecamp-env for providing a separate environment focused repository around candidate Kubernetes manifests as well as applied Kubernetes manifests.
  • kubecamp-blueprints for providing upstream Kubernetes manifests outside of an individual team's app repository.

The overall workflow is as follows:

  • Developer will work in kubecamp-app repo on any branch that is not main, utilizing skaffold dev to iterate with a development Kubernetes cluster, either locally or in the cloud.
    • skaffold dev will utilize Kustomize as a deployer, with base in kubecamp-blueprints/team-a/resources and applying kubecamp-app/app/config to generate a ConfigMap where they can change an environment variable.
  • Once the developer is happy with the state of kubecamp-app they will push to remote on their feature branch.
  • This will trigger kubecamp-app/builds/create-pr-main.yaml, a Cloud Build that will run unit tests defined in kubecamp-app/test_main.py, triggered off of any push to a branch that is not main. You will need to create the Cloud Build trigger yourself should you want to replicate this.
  • Assuming tests pass, the developer can then merge their feature branch into main, ready to prepare their application to run in production.
  • This merge (you will need to create the Cloud Build trigger yourself should you want to replicate this.) will trigger a Cloud Build defined in kubecamp-app/builds/merge-into-main.yaml, which will do two things:
    • It will run skaffold render -p prod, which will build, tag, and push the container images for kubecamp-app. Then it will render Kubernetes manifests in resources.yaml after utilizing the Kustomize stanza defined in the Skaffold Profile prod to pull from overlays that contain a new ConfigMap for production and will expose kubecamp-app via a LoadBalancer rather than ClusterIP.
    • Then, it will run the gcloud container as a build step defined in kubecamp-blueprints/shared/git, which will take the rendered manifest, and push it to a candidate branch for kubeecamp-env, tagging the candidate branch with the SHORT_SHA from the commit in kubecamp-app that triggered this build. That way we can identify candidate manifests with the specific code changes made in the app repo. You will need to configure Secret Manager to use an SSH key you generated for your GitHub, customize configure_git.sh and then build a gcloud container using build_git.yaml with your custom script.
  • Once a candidate branch is opened in kubecamp-env, this will trigger a Cloud Build defined in kubecamp-env/tests/integration_test.yaml, which mocks automation for integration tests you may want to run in a pre-prod environment (it doesn't actually do this, rather demonstrates where you could do it). You will need to create the Cloud Build trigger yourself should you want to replicate this.
  • Finally, with integration tests passing, you can then merge your candidate branch into main for kubecamp-env, which will trigger the final Cloud Build defined in deploy.yaml This will use skaffold apply with your rendered manifests to your production Kubernetes cluster. You will need to update this with your proper Kubernetes cluster.

TODO

  • Add automated creation of build triggers.
  • Add cluster creation instructions.
  • Add IAM requirements.
  • Add specific instructions for customizing configure_git.sh.
  • Add workflow diagram.
  • Use Cloud Build support for integration with Secret Manager, rather than hacking it together.

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.