You are viewing documentation for KubeSphere version:v3.0.0
KubeSphere v3.0.0 documentation is no longer actively maintained. The version you are currently viewing is a static snapshot. For up-to-date documentation, see the latest version.
Kubernetes Blue-green Deployment in Kubesphere
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.
Prerequisites
- You need to enable KubeSphere Service Mesh.
- You need to create a workspace, a project and an account (
project-regular
). The account must be invited to the project with the role ofoperator
. For more information, see Create Workspaces, Projects, Accounts and Roles. - You need to enable Application Governance and have an available app so that you can implement the blue-green deployment for it. The sample app used in this tutorial is Bookinfo. For more information, see Deploy Bookinfo and Manage Traffic.
Create a Blue-green Deployment Job
-
Log in to KubeSphere as
project-regular
. Under Categories, click Create Job on the right of Blue-green Deployment. -
Set a name for it and click Next.
-
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.
-
On the Grayscale Release Version page, add another version of it (e.g
v2
) as shown in the image below and click Next:Note
The image version isv2
in the screenshot. -
To allow the app version
v2
to take over all the traffic, select Take over all traffic and click Create. -
The blue-green deployment job created displays under the tab Job Status. Click it to view details.
-
Wait for a while and you can see all the traffic go to the version
v2
: -
The new Deployment is created as well.
-
You can directly get the virtual service to identify the weight by executing the following command:
kubectl -n demo-project get virtualservice -o yaml
Note
- 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
.
- When you execute the command above, replace
-
Expected output:
... spec: hosts: - reviews http: - route: - destination: host: reviews port: number: 9080 subset: v2 weight: 100 ...
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.