K8S- Deployment 的滚动更新 Rolling Update

2024-04-05 03:28

本文主要是介绍K8S- Deployment 的滚动更新 Rolling Update,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在这里插入图片描述

滚动更新

这里的更新指的不是更新deployment 本身的属性(label/ replicas)等, 而是更新POD 的container 的版本

更新方法通常有两种

  1. 是直接update deployment配置, 注意只有update了template中的内容(与container相关) 才会触发更新
  2. 用kubectl set image 命令




构造新版本的service

为了更好地测试,
我们构造1个新的版本的spring boot的service

更新很简单
直接更新pom里面的version就好, 由1.1.1 to 1.1.2

    <groupId>com.home</groupId><artifactId>bq_api</artifactId><version>1.1.2</version><name>bq-api-service</name>

里面已经利用springboot actuator 构造了1个接口/actuator/info 可以获得当前版本

[gateman@manjaro-x13 ~]$ curl 127.0.0.1:8080/actuator/info
{"app":"Sales API","version":"1.1.2","description":"This is a simple Spring Boot application to demonstrate the use of BigQuery in GCP."}

当把docker image 推送到GAR后
可以用下面命令确认

[gateman@manjaro-x13 ~]$ gcloud artifacts docker images list europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo --include-tags
Listing items under project jason-hsbc, location europe-west2, repository my-docker-repo.IMAGE                                                                 DIGEST                                                                   TAGS            CREATE_TIME          UPDATE_TIME          SIZE
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:30fb2cebd2bf82863608037ce41048114c061acbf1182261a748dadefff2372f                  2024-03-18T02:45:02  2024-03-18T02:45:02  366980350
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:55737b9c2efc7115d878c8b8b036dd0fe8ae5e66b2154fe05ba015b28a31c7aa  1.0.0           2024-03-18T01:40:34  2024-03-18T01:40:34  366980348
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:569397b5d13264988800ad5af15359b4ab085eaca209484e6d859fc2a9e6b6ab  1.1.1           2024-03-31T12:03:57  2024-03-31T12:03:57  366981699
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:648920b7aba0b5cdeeca9e1237d9eeb62ee29188801a95adf7619bcee94e9eb1                  2024-03-15T02:29:55  2024-03-15T02:29:55  367470655
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:6c4129c5a6938004b14cc555518b52a18e8177ce6940b52db7c514783ef9325b  1.1.2           2024-04-04T21:08:09  2024-04-04T21:08:09  366981681
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:7db14476085376db27a2814f8348fdbe002516c576d396c02030094c859f279c                  2024-03-15T20:51:58  2024-03-15T20:51:58  367470658
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:88c7f68df0dd0508b551d53ad22cf4395fea233b5e77be016f13ce9c8c4401fa                  2024-03-30T00:12:15  2024-03-30T00:12:15  366981231
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:a42cd0cd3a3483599b17d94022d1ccd234003491db217b4055f64997478149e1                  2024-03-15T00:03:21  2024-03-15T00:03:21  367470619
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service  sha256:f1e5a8064b134aedd1a5840c16af85633e98a9649c830b6a3f6788a8b00bf16f                  2024-03-25T00:35:48  2024-03-25T00:35:48  366980337

可以看见到1.1.2 的image 已经在GAR了




update deployment配置 测试

先看当前的状态

root@k8s-master:~# kubectl get deploy -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   10/10   10           10          3h27m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service   app=bq-api-service
root@k8s-master:~# kubectl get rs -o wide --show-labels
NAME                                     DESIRED   CURRENT   READY   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR                                         LABELS
bq-api-service-deploy-sample-9f8d9c988   10        10        10      3h27m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service,pod-template-hash=9f8d9c988   app=bq-api-service,pod-template-hash=9f8d9c988
root@k8s-master:~# kubectl get pods -o wide --show-labels
NAME                                           READY   STATUS    RESTARTS   AGE     IP            NODE        NOMINATED NODE   READINESS GATES   LABELS
bq-api-service-deploy-sample-9f8d9c988-25tqr   1/1     Running   0          3h27m   10.244.1.20   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-67psf   1/1     Running   0          3h27m   10.244.3.30   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-cvm4z   1/1     Running   0          3h27m   10.244.3.32   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-f77tx   1/1     Running   0          3h27m   10.244.1.23   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-f98s6   1/1     Running   0          3h27m   10.244.2.82   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-g6627   1/1     Running   0          3h27m   10.244.1.22   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-jlc9w   1/1     Running   0          3h27m   10.244.3.31   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-mnqmf   1/1     Running   0          3h27m   10.244.2.80   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-pw468   1/1     Running   0          3h27m   10.244.2.81   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-v565f   1/1     Running   0          3h27m   10.244.1.21   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
root@k8s-master:~# 

可以见到只有1个deploy 对象, 1个rs 对象, 和 10 个pods, 版本是1.1.1




测试1, 只更新 deployment 的label

命令
kubectl edit deployment bq-api-service-deploy-sample
在这里插入图片描述

结果, 单纯地添加了1个label在deployment 对象, rs 和 pod 都没有触发更新

root@k8s-master:~# kubectl edit deployment bq-api-service-deploy-sample
deployment.apps/bq-api-service-deploy-sample edited
root@k8s-master:~# kubectl get deploy -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   10/10   10           10          3h38m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service   app=bq-api-service,author=Gateman
root@k8s-master:~# kubectl get rs -o wide --show-labels
NAME                                     DESIRED   CURRENT   READY   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR                                         LABELS
bq-api-service-deploy-sample-9f8d9c988   10        10        10      3h38m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service,pod-template-hash=9f8d9c988   app=bq-api-service,pod-template-hash=9f8d9c988
root@k8s-master:~# kubectl get pods -o wide --show-labels
NAME                                           READY   STATUS    RESTARTS   AGE     IP            NODE        NOMINATED NODE   READINESS GATES   LABELS
bq-api-service-deploy-sample-9f8d9c988-25tqr   1/1     Running   0          3h39m   10.244.1.20   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-67psf   1/1     Running   0          3h39m   10.244.3.30   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-cvm4z   1/1     Running   0          3h39m   10.244.3.32   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-f77tx   1/1     Running   0          3h39m   10.244.1.23   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-f98s6   1/1     Running   0          3h39m   10.244.2.82   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-g6627   1/1     Running   0          3h39m   10.244.1.22   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-jlc9w   1/1     Running   0          3h39m   10.244.3.31   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-mnqmf   1/1     Running   0          3h39m   10.244.2.80   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-pw468   1/1     Running   0          3h39m   10.244.2.81   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-v565f   1/1     Running   0          3h39m   10.244.1.21   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
root@k8s-master:~#

注意, 也可以更新本地的yaml , 然后用kubectl apply -f xxx.yaml 来更新

root@k8s-master:~/k8s-s/deployments# git pull
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 322 bytes | 6.00 KiB/s, done.
From e.coding.net:nvd11/k8s/k8s-s12b5990..f24fd58  master     -> origin/master
Updating 12b5990..f24fd58
Fast-forwarddeployments/bq-api-service-sample.yaml | 1 +1 file changed, 1 insertion(+)
root@k8s-master:~/k8s-s/deployments# kubectl apply -f bq-api-service-sample.yaml 
deployment.apps/bq-api-service-deploy-sample configured




测试2, 只更新 deployment 的replicas 期望副本数量

replicas: 10 -> 12

结果是 deployment 和 rs 的属性都更新了, 而且pod 也增加了两个, 但是实际上rs 的hash 没变, 还是那个RS, 而且pod 的版本仍然是1.1.1 并没有触发滚动更新

oot@k8s-master:~/k8s-s/deployments# kubectl edit deployment bq-api-service-deploy-sample
deployment.apps/bq-api-service-deploy-sample edited
root@k8s-master:~/k8s-s/deployments# kubectl get deploy -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   12/12   12           12          3h47m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~/k8s-s/deployments# kubectl get rs -o wide --show-labels
NAME                                     DESIRED   CURRENT   READY   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR                                         LABELS
bq-api-service-deploy-sample-9f8d9c988   12        12        12      3h47m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service,pod-template-hash=9f8d9c988   app=bq-api-service,pod-template-hash=9f8d9c988
root@k8s-master:~/k8s-s/deployments# kubectl get po -o wide --show-labels
NAME                                           READY   STATUS    RESTARTS   AGE     IP            NODE        NOMINATED NODE   READINESS GATES   LABELS
bq-api-service-deploy-sample-9f8d9c988-25tqr   1/1     Running   0          3h48m   10.244.1.20   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-2zlnw   1/1     Running   0          81s     10.244.2.83   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-67psf   1/1     Running   0          3h48m   10.244.3.30   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-cvm4z   1/1     Running   0          3h48m   10.244.3.32   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-f77tx   1/1     Running   0          3h48m   10.244.1.23   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-f98s6   1/1     Running   0          3h48m   10.244.2.82   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-g6627   1/1     Running   0          3h48m   10.244.1.22   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-jlc9w   1/1     Running   0          3h48m   10.244.3.31   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-mnqmf   1/1     Running   0          3h48m   10.244.2.80   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-pw468   1/1     Running   0          3h48m   10.244.2.81   k8s-node0   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-qntj8   1/1     Running   0          81s     10.244.3.33   k8s-node3   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988
bq-api-service-deploy-sample-9f8d9c988-v565f   1/1     Running   0          3h48m   10.244.1.21   k8s-node1   <none>           <none>            app=bq-api-service,pod-template-hash=9f8d9c988




测试3, 只更新 deployment 的 template.container.image的version

在这里插入图片描述

结果, 触发了滚动更新
这里我多次执行了 get deploy 命令, 可以见到version 由1.1.1 逐渐变成了1.1.2

至于ReplicaSet 则是直接多了1个, 足以看出k8s 是新建1个 RS 作为临时的POD 容器进行滚动更新, 当新的RS 完成所有pod 更新时, 旧的RS 就被丢弃放在一边了

root@k8s-master:~# kubectl get deployments -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   12/12   12           12          3h52m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~# kubectl get deployments -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   12/12   12           12          3h52m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~# kubectl get deployments -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   9/12    12           9           3h54m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~# kubectl get deployments -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   9/12    12           9           3h54m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~# kubectl get deployments -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   11/12   12           11          3h54m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~# kubectl get deployments -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   12/12   12           12          3h54m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~# kubectl get deployments -o wide --show-labels
NAME                           READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR             LABELS
bq-api-service-deploy-sample   12/12   12           12          3h54m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2   app=bq-api-service   app=bq-api-service,author=Jason
root@k8s-master:~# kubectl get rs -o wide --show-labels
NAME                                     DESIRED   CURRENT   READY   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR                                         LABELS
bq-api-service-deploy-sample-8d49d9845   12        12        12      40s     bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2   app=bq-api-service,pod-template-hash=8d49d9845   app=bq-api-service,pod-template-hash=8d49d9845
bq-api-service-deploy-sample-9f8d9c988   0         0         0       3h55m   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service,pod-template-hash=9f8d9c988   app=bq-api-service,pod-template-hash=9f8d9c988
root@k8s-master:~# 




kubectl set image 命令更新测试

kubectl set image deployment/<deployment_name> <container_name>=europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:<新版本号>

root@k8s-master:~/k8s-s/deployments# kubectl set image deployment/bq-api-service-deploy-sample bq-api-service-container=europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.3
deployment.apps/bq-api-service-deploy-sample image updatedroot@k8s-master:~# curl 10.244.2.91:8080/actuator/info
{"app":"Sales API","version":"1.1.3","description":"This is a simple Spring Boot application to demonstrate the use of BigQuery in GCP."}root@k8s-master:~# 




查看deployment 更新历史

  1. 利用 Kubectl rollout 命令
root@k8s-master:~/k8s-s/deployments# kubectl rollout history deployment/bq-api-service-deploy-sample 
deployment.apps/bq-api-service-deploy-sample 
REVISION  CHANGE-CAUSE
1         <none>
2         <none>
3         <none>root@k8s-master:~/k8s-s/deployments# kubectl rollout history deployment/bq-api-service-deploy-sample --revision=2
deployment.apps/bq-api-service-deploy-sample with revision #2
Pod Template:Labels:       app=bq-api-servicepod-template-hash=8d49d9845Containers:bq-api-service-container:Image:      europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2Port:       <none>Host Port:  <none>Environment:        <none>Mounts:     <none>Volumes:      <none>
  1. 查看rs 的数量和版本
root@k8s-master:~/k8s-s/deployments# kubectl get rs -o wide -l app=bq-api-service
NAME                                      DESIRED   CURRENT   READY   AGE     CONTAINERS                 IMAGES                                                                       SELECTOR
bq-api-service-deploy-sample-7bff8fbc4b   12        12        12      6m11s   bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.3   app=bq-api-service,pod-template-hash=7bff8fbc4b
bq-api-service-deploy-sample-8d49d9845    0         0         0       13m     bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2   app=bq-api-service,pod-template-hash=8d49d9845
bq-api-service-deploy-sample-9f8d9c988    0         0         0       4h8m    bq-api-service-container   europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.1   app=bq-api-service,pod-template-hash=9f8d9c988

这里的-l 就是label selector 的意思啦!

这篇关于K8S- Deployment 的滚动更新 Rolling Update的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/877526

相关文章

在MySQL执行UPDATE语句时遇到的错误1175的解决方案

《在MySQL执行UPDATE语句时遇到的错误1175的解决方案》MySQL安全更新模式(SafeUpdateMode)限制了UPDATE和DELETE操作,要求使用WHERE子句时必须基于主键或索引... mysql 中遇到的 Error Code: 1175 是由于启用了 安全更新模式(Safe Upd

k8s部署MongDB全过程

《k8s部署MongDB全过程》文章介绍了如何在Kubernetes集群中部署MongoDB,包括环境准备、创建Secret、创建服务和Deployment,并通过Robo3T工具测试连接... 目录一、环境准备1.1 环境说明1.2 创建 namespace1.3 创建mongdb账号/密码二、创建Sec

Redis缓存问题与缓存更新机制详解

《Redis缓存问题与缓存更新机制详解》本文主要介绍了缓存问题及其解决方案,包括缓存穿透、缓存击穿、缓存雪崩等问题的成因以及相应的预防和解决方法,同时,还详细探讨了缓存更新机制,包括不同情况下的缓存更... 目录一、缓存问题1.1 缓存穿透1.1.1 问题来源1.1.2 解决方案1.2 缓存击穿1.2.1

Linux Mint Xia 22.1重磅发布: 重要更新一览

《LinuxMintXia22.1重磅发布:重要更新一览》Beta版LinuxMint“Xia”22.1发布,新版本基于Ubuntu24.04,内核版本为Linux6.8,这... linux Mint 22.1「Xia」正式发布啦!这次更新带来了诸多优化和改进,进一步巩固了 Mint 在 Linux 桌面

SpringCloud配置动态更新原理解析

《SpringCloud配置动态更新原理解析》在微服务架构的浩瀚星海中,服务配置的动态更新如同魔法一般,能够让应用在不重启的情况下,实时响应配置的变更,SpringCloud作为微服务架构中的佼佼者,... 目录一、SpringBoot、Cloud配置的读取二、SpringCloud配置动态刷新三、更新@R

centos7基于keepalived+nginx部署k8s1.26.0高可用集群

《centos7基于keepalived+nginx部署k8s1.26.0高可用集群》Kubernetes是一个开源的容器编排平台,用于自动化地部署、扩展和管理容器化应用程序,在生产环境中,为了确保集... 目录一、初始化(所有节点都执行)二、安装containerd(所有节点都执行)三、安装docker-

Ubuntu 24.04 LTS怎么关闭 Ubuntu Pro 更新提示弹窗?

《Ubuntu24.04LTS怎么关闭UbuntuPro更新提示弹窗?》Ubuntu每次开机都会弹窗提示安全更新,设置里最多只能取消自动下载,自动更新,但无法做到直接让自动更新的弹窗不出现,... 如果你正在使用 Ubuntu 24.04 LTS,可能会注意到——在使用「软件更新器」或运行 APT 命令时,

poj3468(线段树成段更新模板题)

题意:包括两个操作:1、将[a.b]上的数字加上v;2、查询区间[a,b]上的和 下面的介绍是下解题思路: 首先介绍  lazy-tag思想:用一个变量记录每一个线段树节点的变化值,当这部分线段的一致性被破坏我们就将这个变化值传递给子区间,大大增加了线段树的效率。 比如现在需要对[a,b]区间值进行加c操作,那么就从根节点[1,n]开始调用update函数进行操作,如果刚好执行到一个子节点,

hdu1394(线段树点更新的应用)

题意:求一个序列经过一定的操作得到的序列的最小逆序数 这题会用到逆序数的一个性质,在0到n-1这些数字组成的乱序排列,将第一个数字A移到最后一位,得到的逆序数为res-a+(n-a-1) 知道上面的知识点后,可以用暴力来解 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#in

hdu1689(线段树成段更新)

两种操作:1、set区间[a,b]上数字为v;2、查询[ 1 , n ]上的sum 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#include<queue>#include<set>#include<map>#include<stdio.h>#include<stdl