Giter Site home page Giter Site logo

f4you / k8s-deployment-strategies Goto Github PK

View Code? Open in Web Editor NEW

This project forked from containersolutions/k8s-deployment-strategies

0.0 0.0 0.0 3.69 MB

Kubernetes deployment 发布可视化大屏

Home Page: https://container-solutions.com/kubernetes-deployment-strategies/

Go 86.71% Makefile 6.36% Dockerfile 6.93%

k8s-deployment-strategies's Introduction

Kubernetes deployment strategies

In Kubernetes there are a few different ways to release an application, you have to carefully choose the right strategy to make your infrastructure resilient.

  • recreate: terminate the old version and release the new one
  • ramped: release a new version on a rolling update fashion, one after the other
  • blue/green: release a new version alongside the old version then switch traffic
  • canary: release a new version to a subset of users, then proceed to a full rollout
  • a/b testing: release a new version to a subset of users in a precise way (HTTP headers, cookie, weight, etc.). This doesn’t come out of the box with Kubernetes, it imply extra work to setup a smarter loadbalancing system (Istio, Linkerd, Traeffik, custom nginx/haproxy, etc).
  • shadow: release a new version alongside the old version. Incoming traffic is mirrored to the new version and doesn't impact the response.

deployment strategy decision diagram

Before experimenting, checkout the following resources:

Getting started

These examples were created and tested on Minikube running with Kubernetes v1.25.2 and Rancher Desktop running with Kubernetes 1.23.6.

On MacOS the hypervisor VM does not have external connectivity so docker image pulls will fail. To resolve this, install another driver such as VirtualBox and add --vm-driver virtualbox to the command to be able to pull images.

$ minikube start --kubernetes-version v1.25.2 --memory 8192 --cpus 2

Visualizing using Prometheus and Grafana

The following steps describe how to setup Prometheus and Grafana to visualize the progress and performance of a deployment.

Install Helm3

To install Helm3, follow the instructions provided on their website.

Install Prometheus

$ helm install prometheus prometheus-community/prometheus \
    --create-namespace --namespace=monitoring

Install Grafana

$ helm install grafana \
    --namespace=monitoring \
    --set=adminUser=admin \
    --set=adminPassword=admin \
    --set=service.type=NodePort \
    grafana/grafana

Setup Grafana

Now that Prometheus and Grafana are up and running, you can access Grafana:

$ minikube service grafana

To login, username: admin, password: admin.

Then you need to connect Grafana to Prometheus, to do so, add a DataSource:

Name: prometheus
Type: Prometheus
Url: http://prometheus-server
Access: Server

Create a dashboard with a Time series or import the JSON export. Use the following query:

sum(rate(http_requests_total{app="my-app"}[2m])) by (version)

Since we installed Prometheus with default settings, it is using the default scrape interval of 1m so the range cannot be lower than that.

To have a better overview of the version, add {{version}} in the legend field.

Example graph

Recreate:

Kubernetes deployment recreate

Ramped:

Kubernetes deployment ramped

Blue/Green:

Kubernetes deployment blue-green

Canary:

Kubernetes deployment canary

A/B testing:

kubernetes ab-testing deployment

Shadow:

kubernetes shadow deployment

k8s-deployment-strategies's People

Contributors

etiennetremel avatar jonathangold avatar arosequist avatar ivuk avatar karl-johan-grahn avatar luebken avatar ppaltmann avatar stafot 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.