Code Monkey home page Code Monkey logo

blue-green-deployment's Introduction

blue-green deployment with nginx ingress and istio

reviews 微服务有 3 个版本: https://raw.githubusercontent.com/istio/istio/release-1.17/samples/bookinfo/platform/kube/bookinfo.yaml;

  • v1 版本不会调用ratings 服务
  • v2 版本会调用 ratings 服务,并使用 1 到 5 个黑色星形图标来显示评分信息。
  • v3 版本会调用 ratings 服务,并使用 1 到 5 个红色星形图标来显示评分信息。

Install

  • Install istio(without gateway)
# https://istio.io/latest/docs/setup/install/helm/

kubectl create namespace istio-system;
helm repo add istio https://istio-release.storage.googleapis.com/charts;
helm repo update;
helm install istio-base istio/base -n istio-system;
helm install istiod istio/istiod -n istio-system;
helm status istiod -n istio-system;
  • Inject istio sidercar
kubectl create namespace bookinfo;
kubectl create namespace nginx-ingress;

kubectl label namespace bookinfo istio-injection=enabled;
kubectl label nginx-ingress bookinfo istio-injection=enabled;

kubectl get namespace -L istio-injection;
  • Install nginx ingress(from kubernetes's org)
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm upgrade -i --namespace nginx-ingress nginx-ingress ingress-nginx/ingress-nginx -f ./ingress-nginx.values.yaml
  • Make tls local
# https://github.com/FiloSottile/mkcert
# Install the local CA in the system trust store.
mkcert -install
mkcert "*.local.dev" 127.0.0.1 ::1
  • Install bookinfo microservices
kubectl -n bookinfo apply -f ./bookinfo;
kubectl -n bookinfo apply -f ./vservice;
# create tls secret
kubectl -n bookinfo create secret tls tls-secret-local --key ~/.local/share/mkcert/_wildcard.local.dev+2-key.pem \
        --cert ~/.local/share/mkcert/_wildcard.local.dev+2.pem

Test

Open https://bookinfo.local.dev and https://bookinfo.staging.local.dev

How nginx ingress work with istio

ingress controller

controller:
  podAnnotations:
    sidecar.istio.io/inject: 'true'
    traffic.sidecar.istio.io/includeInboundPorts: ""
    traffic.sidecar.istio.io/excludeInboundPorts: "80,443"

ingress resource

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/service-upstream: "true"
    nginx.ingress.kubernetes.io/upstream-vhost: productpage.bookinfo.svc.cluster.local
    nginx.ingress.kubernetes.io/configuration-snippet: |
          more_set_input_headers 'env: staging';
  name: bookinfo-staging
spec:
  ingressClassName: nginx

The nginx.ingress.kubernetes.io/service-upstream annotation disables that behavior and instead uses a single upstream in NGINX, the service's Cluster IP and port.

The nginx.ingress.kubernetes.io/upstream-vhost annotation allows you to control the value for host in the following statement: proxy_set_header Host $host, which forms part of the location block.

Debug

# https://istio.io/latest/docs/tasks/observability/logs/access-log/

$ kubectl -n nginx-ingress logs -f nginx-ingress-controller-7b6d7d4d75-8jw8p -c istio-proxy

blue-green-deployment's People

Contributors

steevenhu avatar

Watchers

koolay 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.