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-s
   12b5990..f24fd58  master     -> origin/master
Updating 12b5990..f24fd58
Fast-forward
 deployments/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 updated

root@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-service
        pod-template-hash=8d49d9845
  Containers:
   bq-api-service-container:
    Image:      europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/bq-api-service:1.1.2
    Port:       <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 的意思啦!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/516577.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【蓝桥杯】GCD与LCM

一.概述 最大公约数&#xff08;GCD&#xff09;和最小公倍数&#xff08;Least Common Multiple&#xff0c;LCM&#xff09; 在C中&#xff0c;可以使用 std::__gcd(a, b)来计算最大公约数 1.欧几里德算法/辗转相除法 int gcd(int a,int b){return b?gcd(b, a%b):a; } 2…

CATIA软件 焊点坐标(BiW Welding SpotPoint)导出txt文本的操作方法

通常我们客户给的工件是带焊点球的形式&#xff0c;且可导出焊点坐标。如下图所示的焊点位置标识及坐标&#xff0c;即是CATIA中Automotive BiW Fastening模块下的BiW Welding SpotPoint焊点定义。 遇到这样的形式&#xff0c;要导出焊点坐标txt文本&#xff0c;可按如下图片找…

ssm023实验室耗材管理系统设计与实现+jsp

实验室耗材管理系统的设计与实现 摘 要 互联网发展至今&#xff0c;无论是其理论还是技术都已经成熟&#xff0c;而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播&#xff0c;搭配信息管理工具可以很好地为人们提供服务。针对实验室耗材信息管理混乱&#xff…

深入浅出 -- 系统架构之单体架构和微服务架构的区别

在软件开发中&#xff0c;架构设计是非常重要的一环。架构设计不仅决定了软件系统的性能、可维护性和扩展性&#xff0c;还直接关系到开发成本和项目进度。目前&#xff0c;主流的架构设计模式有两种&#xff0c;一种是单体架构&#xff0c;另一种是微服务架构。本文将详细介绍…

【C语言】从零开始:用C语言实现顺序表

欢迎来CILMY23的博客 本篇主题为 从零开始&#xff1a;用C语言实现顺序表 个人主页&#xff1a;CILMY23-CSDN博客 C语言专栏&#xff1a; http://t.csdnimg.cn/hQ5a9 Python系列专栏&#xff1a;http://t.csdnimg.cn/HqYo8 上一篇C语言博客&#xff1a; http://t.csdnimg.…

pwn学习笔记(7)--堆相关源码

相关源码&#xff1a; 1. chunk 相关源码&#xff1a; ​ 对于用户来说&#xff0c;只需要确保malloc()函数返回的内存不会发生溢出&#xff0c;并且在不用的时候使用free() 函数将其释放&#xff0c;以后也不再做任何操作即可。而对于glibc来说’它要在用户第一次调用malloc…

C语言数据结构初阶-顺序表

什么是数据结构 数据结构是由数据和结构两个词结合而来&#xff0c; 那么数据由是什么 就比如我们日常生活中的1&#xff0c;2&#xff0c;3&#xff0c;4&#xff0c;5&#xff0c;a,b,c,d,e文字信息图片等&#xff0c;这些就是数据 那么结构又是什么&#xff1f; 想像一下如…

Collection与数据结构 Stack与Queue(一): 栈与Stack

1. 栈 1.1 概念 栈&#xff1a;一种特殊的线性表&#xff0c;其只允许在固定的一端进行插入和删除元素操作。进行数据插入和删除操作的一端称为栈顶&#xff0c;另一端称为栈底。栈中的数据元素遵守后进先出LIFO&#xff08;Last In First Out&#xff09;的原则。 压栈&…

【029】基于ssm+小程序实现的理发店预约系统

作者主页&#xff1a;Java码库 主营内容&#xff1a;SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、小程序、安卓app等设计与开发。 收藏点赞不迷路 关注作者有好处 文末获取源码 技术选型 【后端】&#xff1a;Java 【框架】&#xff1a;ssm 【…

Hadoop: word count,并将reduce结果写入ES

一、依赖&#xff0c;其中ES版本为7.6.2 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http…

[StartingPoint][Tier0]Mongod

Task 1 How many TCP ports are open on the machine? (机器上打开了多少个 TCP 端口&#xff1f;) Example: $ sudo nmap -sS -T4 10.129.222.112 -p 27017,22 2 Task 2 Which service is running on port 27017 of the remote host? (哪个服务正在远程主机的端口 270…

Hippo4j线程池实现技术

文章目录 &#x1f50a;博主介绍&#x1f964;本文内容部署运行模式集成线程池监控配置参数默认配置 &#x1f4e2;文章总结&#x1f4e5;博主目标 &#x1f50a;博主介绍 &#x1f31f;我是廖志伟&#xff0c;一名Java开发工程师、Java领域优质创作者、CSDN博客专家、51CTO专家…

基于Java课程选课系统设计与实现(源码+部署文档)

博主介绍&#xff1a; ✌至今服务客户已经1000、专注于Java技术领域、项目定制、技术答疑、开发工具、毕业项目实战 ✌ &#x1f345; 文末获取源码联系 &#x1f345; &#x1f447;&#x1f3fb; 精彩专栏 推荐订阅 &#x1f447;&#x1f3fb; 不然下次找不到 Java项目精品实…

KIl5:Stm32L071下载出现flash download faild “cortex-m0+“的解决方法

首先看看有没有芯片&#xff0c;没有芯片下载一下 下载并在device选择对应的芯片 选择调试器 选择flash

gpt4.0中文版

我愿把这个网站成为全球最强AI网站&#xff01;弄100多个AI伺候你&#xff1f;&#xff1f; 家人们&#xff0c;你们猜我发现了什么牛逼的AI网站&#xff1f;&#xff1f; 直接上图&#xff1a; 编辑 这个网站&#xff0c;聚合了国内外100多个顶尖的AI&#xff0c;包括了Op…

入门用Hive构建数据仓库

在当今数据爆炸的时代&#xff0c;构建高效的数据仓库是企业实现数据驱动决策的关键。Apache Hive 是一个基于 Hadoop 的数据仓库工具&#xff0c;可以轻松地进行数据存储、查询和分析。本文将介绍什么是 Hive、为什么选择 Hive 构建数据仓库、如何搭建 Hive 环境以及如何在 Hi…

我认识的Git-史上最强的版本控制系统

大家好&#xff01; 欢迎大家来一起交流Git使用心得&#xff0c;相信很多同事对Git都很熟悉了&#xff0c;如果下面说的有错误的“知识点”&#xff0c;欢迎批评指正。 初识Git 我认识Git已经很多年了&#xff08;我在有道云笔记里面“Git”文件夹的创建时间是&#xff1a; …

sky06笔记下

1.边沿检测 检测输入信号din的上升沿&#xff0c;并输出pulse module edge_check ( clk, rstn, din, pulse ); input wire clk,rstn; input wire din; output reg pulse;wire din_dly;always (posedge clk or negedge rstn)beginif(!rstn)din_dly < 1b0;elsedin_dly < d…

JS-11A/11时间继电器 板前接线 JOSEF约瑟

系列型号&#xff1a; JS-11A/11集成电路时间继电器&#xff1b;JS-11A/12集成电路时间继电器&#xff1b; JS-11A/13集成电路时间继电器&#xff1b;JS-11A/136集成电路时间继电器&#xff1b; JS-11A/137集成电路时间继电器&#xff1b;JS-11A/22集成电路时间继电器&#…

【C语言】_文件内容操作:随机读写

目录 1. fseek 1.1 随机读文件 1.2 随机写文件 2. ftell 3. rewind 当以读方式打开一个存在且存有内容的文件时&#xff0c;文件指针会默认指向第一个元素。以在test4.txt文件中存储abcdef为例&#xff1a; int main() {//打开文件FILE* pf fopen("E:\\C_文件操作…