Canary release


Exit after modification takes effect immediately

Which type is used for cluster external access: nodeport

nodeip+nodeport external access

Internal access clusterip

What is used to set the port number of clusterip

Canary release

  • k8s defaults to rolling update. The deployment controller can control the rolling update rhythm by itself, such as' pause 'and' resume 'update operations. For example, there were a batch of pod resources to be updated. First, update some pod resources randomly, and then stop updating immediately. At this time, only part of the application update is completed, and the main part is still the old version. Then, a small proportion of users' requests are routed to the new version of the application for testing. After the application test is OK, continue to complete the rolling update of the remaining pod resources. If there is a problem with the new version of the application test, immediately roll back the update operation. This is the Canary release
  • Simply put, it is to upgrade some of them for users to use. If there is no problem, then update others, and automatically delete the old version after a period of time

How did the new version of traffic lead to the past?

However, there is a problem that the original user is using it, but after the upgrade, I don't know who is using the new version and who is using the old version. Here, you can select a user to test the new version, first tell him to test the new version, and then the special user to test. The new pod is associated with the original service (, the specified user accesses the original service IP, and the service is associated with both old and new resources.) then create a new tag to the new pod, and then associate the new pod with the service, and then access the new pod according to the new service

How are old and new pservice s connected?

Through labels and label selectors

Similar to Canary gas detection, if gas is detected, it will react, and the staff will know that there is gas, so as to avoid accidents

Unlike blue and green, we need two sets of equipment

It's not like rolling publishing, publishing in proportion

Canary release requires a new resource for you to test first. Users upgrade to this version knowingly. Users test it. If there is no problem, they are gradually updating the remaining resources

How is a service associated with a pod?

Through labels and label selectors

kubectl get nodes
NAME       STATUS   ROLES    AGE   VERSION
master01   Ready    master   24h   v1.15.1
node01     Ready    <none>   24h   v1.15.1
node02     Ready    <none>   24h   v1.15.1
[root@master01 opt]# kubectl get pod
No resources found.

View resource: resource is empty

Create a resource nginx:1.14

kubectl create deployment nginx --image=nginx:1.14
#deployment.apps/nginx created indicates that the creation is successful

see

kubectl get pod
kubectl get svc
kubectl get deployment
 or
kubectl get deployment,pod,svc

Exposed port

kubectl expose deployment nginx --port=80 --target-port=80

View the version number (you can first view the cluster IP and port through kubectl get svc)

curl http://10.103.74.102 -I
 or
curl http://10.103.74.102:80 -I

Note: after creation, the service must be exposed to view this service, that is, kubectl expose

Increase the number of pod s

kubectl scale deployment nginx --replicas=3

The following operations are performed according to the above

Update the version of deployment and configure to suspend deployment

Turn on tracking

kubectl get pod -w
kubectl get pod -owide -w#Detailed tracking

Turn on another terminal

kubectl set image deployment nginx nginx=nginx:1.16 && kubectl rollout pause deployment nginx#Join, update and pause, or the old version will be deleted

Monitoring the update process, we can see that a new resource has been added, but an old resource has not been deleted according to the expected state, because the pause command is used to pause the viewing of the original terminal

Some of them have been updated and have not been deleted by Terminating

View status

kubectl rollout status deployment nginx 

View updated services

curl http://10.244.2.12 
curl http://10.244.2.12 -I

Access ClusterIP

Since there are four services, there are four cycles,
curl http://10.103.74.102 -I
curl http://10.103.74.102 -I
curl http://10.103.74.102 -I
curl http://10.103.74.102 -I

kubectl describe svc nginx 
 kubectl get endpoints 
kubectl get endpoints nginx 

Associate the newly created

Ensure that there is no problem with the updated pod and keep updating

kubectl rollout resume deployment nginx 

Dynamic tracking: it is found that it has been deleted at this time

Check the version again: it is found that it is version 1.16

curl http://10.103.74.102 -I

View 3 resources

kubectl get nodes 
kubectl get pod
kubectl get service

To delete three kinds of resources, generally view the resource name first (take nginx as an example)

[root@master01 opt]# kubectl get svc
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        25h
nginx        NodePort    10.110.47.18   <none>        80:30558/TCP   25h
[root@master01 opt]# kubectl delete service nginx 
service "nginx" deleted
[root@master01 opt]# kubectl delete deployment nginx 
deployment.extensions "nginx" deleted

[root@master01 opt]# kubectl delete deployment nginx 
deployment.extensions "nginx" deleted

ubectl delete deployment nginx
deployment.extensions "nginx" deleted

[External chain picture transfer...(img-lAl0KMhh-1635986634697)]

```shell
[root@master01 opt]# kubectl delete deployment nginx 
deployment.extensions "nginx" deleted

Keywords: Kubernetes

Added by tomjung09 on Thu, 04 Nov 2021 08:24:58 +0200