Blue-green Deployment

The blue-green release provides a zero downtime deployment, which means the new version can be deployed with the old one preserved. At any time, only one of the versions is active serving all the traffic, while the other one remains idle. If there is a problem with running, you can quickly roll back to the old version.

blue-green-0

Prerequisites

Create Blue-green Deployment Job

  1. Log in KubeSphere as project-regular. Under Categories, click Create Job on the right of Blue-green Deployment.

    blue-green-1

  2. Set a name for it and click Next.

    blue-green-2

  3. Select your app from the drop-down list and the service for which you want to implement the blue-green deployment. If you also use the sample app Bookinfo, select reviews and click Next.

    blue-green-3

  4. On the Grayscale Release Version page, add another version of it (e.g v2) as shown in the image below and click Next:

    blue-green-4

    备注

    The image version is v2 in the screenshot.

  5. To allow the app version v2 to take over all the traffic, select Take over all traffic and click Create.

    blue-green-5

  6. The blue-green deployment job created displays under the tab Job Status. Click it to view details.

    blue-green-job-list

  7. Wait for a while and you can see all the traffic go to the version v2:

    blue-green-6

  8. The new Deployment is created as well.

    version2-deployment

  9. You can directly get the virtual service to identify the weight by executing the following command:

    1. kubectl -n demo-project get virtualservice -o yaml

    备注

    • When you execute the command above, replace demo-project with your own project (i.e. namespace) name.
    • If you want to execute the command from the web kubectl on the KubeSphere console, you need to use the account admin.
  10. Expected output:

    1. ...
    2. spec:
    3. hosts:
    4. - reviews
    5. http:
    6. - route:
    7. - destination:
    8. host: reviews
    9. port:
    10. number: 9080
    11. subset: v2
    12. weight: 100
    13. ...

Take a Job Offline

After you implement the blue-green deployment, and the result meets your expectation, you can take the task offline with the version v1 removed by clicking Job offline.

blue-green-7