Coder Social home page Coder Social logo

ldw-sh-cn / semaphore-demo-cicd-kubernetes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from semaphoreci-demos/semaphore-demo-cicd-kubernetes

0.0 1.0 0.0 623 KB

A Companion Demo for the CI/CD for Docker and Kubernetes Book

Home Page: https://semaphoreci.com

License: MIT License

Dockerfile 5.38% JavaScript 82.57% Shell 12.05%

semaphore-demo-cicd-kubernetes's Introduction

A Companion Demo for the CI/CD with Docker and Kubernetes Book

Run it in your workstation

$ docker-compose up --build
$ curl -w "\n" -X PUT -d "firstName=al&lastName=pacino" 127.0.0.1:3000/person
$ curl -w "\n" 127.0.0.1:3000/all

CI/CD Pipelines

The CI/CD workflow is as follows:

  1. Build docker image w/cache.
  2. Run tests inside docker images.
  3. Push image to docker registry.
  4. Perform canary deployment.
  5. Run functional test and migration in canary deployment.
  6. One-click production/stable deployment.

Workflow

Configure Semaphore

  1. Fork this repository
  2. Clone it to your machine
  3. Sign up for Semaphore and install sem cli.
  4. Add the project to Semaphore:
$ sem init

Deploy to the cloud

Cloud services required:

  • Kubernetes Cluster (recommended 3 nodes) called semaphore-demo-cicd-kubernetes
  • PostgreSQL Database in the same region and VPC as the cluster.

Open the relevant pipeline files at .semaphore and fill in the environment variables for the blocks. Uncomment the desired promotion on .semaphore/semaphore.yml.

Create Secrets

Create DB connection secret:

    $ sem create secret db-params \e
        -e DB_USER=YOUR_DB_USERNAME \
        -e DB_PASSWORD=YOUR_DB_PASSWORD \
        -e DB_HOST=YOUR_DB_IP \
        -e DB_PORT=YOUR_DB_PORT (5432) \
        -e DB_SCHEMA=YOUR_DB_SCHEMA (postgres) \
        -e DB_SSL=true|false (empty)

Depending on the cloud provider, you’ll need to create different secrets.

AWS

  • Create an IAM User with Administrator permissions. Create a secret with the access id and the Kubernetes kubeconfig file:
$ sem create secret aws-key \
    -e AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_ID \
    -e AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_KEY \
    -f YOUR_KUBECONFIG.yml:/home/semaphore/aws-key.yml

Google Cloud

  • Create a project called semaphore-demo-cicd-kubernetes
  • Create service account and generate a key file. Upload the file to Semaphore:
$ sem create secret gcp-key -f YOUR_KEY_FILE.json:/home/semaphore/gcp-key.json

DigitalOcean

  • Create a project called semaphore-demo-cicd-kubernetes and set it as default.
  • Get your authentication API Token and create a secret for it:
$ sem create secret do-key -e DO_ACCESS_TOKEN=YOUR_DIGITALOCEAN_TOKEN
  • Set the parameter in db-params secret to DB_SSL=true

  • Create a secret to store your DockerHub credentials:

$ sem create secret dockerhub \
    -e DOCKER_USERNAME=YOUR_DOCKERHUB_USER \
    -e DOCKRE_PASSWORD=YOUR_DOCKERHUB_PASSWORD

License

Copyright (c) 2019 Rendered Text

Distributed under the MIT License. See the file LICENSE.md.

semaphore-demo-cicd-kubernetes's People

Contributors

tomfern avatar

Watchers

 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.