当前位置: 首页 > news >正文

网站建设站建设好吗网络推广方式有哪几种

网站建设站建设好吗,网络推广方式有哪几种,专门做餐饮空间设计的网站,郑州官方发布最新消息一,前言 上一篇,介绍了灰度发布和流量切分的集中方式,以及如何实现 k8s 的灰度发布; 本篇,介绍滚动发布的实现; 二,滚动发布简介 滚动发布 滚动发布,则是我们一般所说的无宕机发…

一,前言

上一篇,介绍了灰度发布和流量切分的集中方式,以及如何实现 k8s 的灰度发布;

本篇,介绍滚动发布的实现;


二,滚动发布简介

滚动发布

  • 滚动发布,则是我们一般所说的无宕机发布。其发布方式如同名称一样,一次取出一台/多台服务器(看策略配置)进行新版本更新。当取出的服务器新版确保无问题后,接着采用同等方式更新后面的服务器
  • k8s创建副本应用程序的最佳方法就是部署(Deployment),部署自动创建副本集(ReplicaSet),副本集可以精确地控制每次替换的Pod数量,从而可以很好的实现滚动更新
  • k8s每次使用一个新的副本控制器(replication controller)来替换已存在的副本控制器,从而始终使用一个新的Pod模板来替换旧的pod模板
    • 创建一个新的 replication controller;
    • 增加或减少 pod 副本数量,直到满足当前批次期望的数量;
    • 删除掉旧的 replication controller;

发布流程和策略

  • 优点

    • 不需要停机更新,无感知平滑更新;
    • 版本更新成本小,不需要新旧版本共存;
  • 缺点

    • 更新时间长:每次只更新一个/多个镜像,需要频繁连续等待服务启动缓冲
    • 旧版本环境无法得到备份:始终只有一个环境存在
    • 回滚版本异常:如果滚动发布到一半出了问题,回滚时需要使用同样的滚动策略回滚旧版本

三、环境初始化

由于 k8s-node 资源问题,先清理一下 k8s-node 上的资源占用;

查看资源情况

[root@k8s-master deployment]# kubectl get deploy
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
nginx     0/3     3            0           2d1h
pay-v1    0/3     3            0           6h52m
user-v1   0/3     3            0           8m11s
user-v2   0/3     3            0           5h11m[root@k8s-master deployment]# kubectl get service
NAME              TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes        ClusterIP   10.96.0.1        <none>        443/TCP        2d16h
nginx             NodePort    10.107.223.32    <none>        80:32117/TCP   2d1h
service-pay-v1    NodePort    10.106.98.218    <none>        80:30872/TCP   6h32m
service-user-v1   NodePort    10.104.13.40     <none>        80:31071/TCP   28h
service-user-v2   NodePort    10.100.196.142   <none>        80:30289/TCP   5h12m[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS             RESTARTS   AGE
mysql-g2zst                0/1     CrashLoopBackOff   53         2d
nginx-6799fc88d8-2wvl2     1/1     Running            1          2d1h
nginx-6799fc88d8-lkct4     1/1     Running            1          2d1h
nginx-6799fc88d8-pktqq     1/1     Running            1          2d1h
pay-v1-655587b6f5-lpft2    1/1     Running            1          6h41m
pay-v1-655587b6f5-pcnrp    1/1     Running            2          6h42m
pay-v1-655587b6f5-spj85    1/1     Running            1          6h41m
user-v1-5895c69847-8tkm9   0/1     Pending            0          9m18s
user-v1-5895c69847-swp52   0/1     Pending            0          9m18s
user-v1-5895c69847-xr4r8   0/1     Pending            0          9m18s
user-v2-fc9d84585-2zztd    1/1     Running            2          5h13m
user-v2-fc9d84585-ss2ss    1/1     Running            1          5h13m
user-v2-fc9d84585-xrvnf    1/1     Running            1          5h13m

删除无用 pod

注意:想要删除 pod,需要删除掉 deployment,否则副本依然还在;

以 nginx 为例:目前的有 3 个正在运行的 nginx 副本

[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
mysql-4nq2q                0/1     Pending   0          4m19s
nginx-6799fc88d8-2wvl2     1/1     Running   1          2d1h
nginx-6799fc88d8-lkct4     1/1     Running   1          2d2h
nginx-6799fc88d8-pktqq     1/1     Running   1          2d1h
pay-v1-655587b6f5-lpft2    1/1     Running   1          6h53m
pay-v1-655587b6f5-pcnrp    1/1     Running   2          6h53m
pay-v1-655587b6f5-spj85    1/1     Running   1          6h53m
user-v1-5895c69847-8tkm9   0/1     Pending   0          20m
user-v1-5895c69847-swp52   0/1     Pending   0          20m
user-v1-5895c69847-xr4r8   0/1     Pending   0          20m
user-v2-fc9d84585-2zztd    1/1     Running   2          5h24m
user-v2-fc9d84585-ss2ss    1/1     Running   1          5h24m
user-v2-fc9d84585-xrvnf    1/1     Running   1          5h24m[root@k8s-master deployment]# kubectl get deploy
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
nginx     0/3     3            0           2d2h
pay-v1    0/3     3            0           7h8m
user-v1   0/3     3            0           23m
user-v2   0/3     3            0           5h27m

删除 nginx 的 deploy 后,pod 状态变为 Terminating

[root@k8s-master deployment]# kubectl delete deployment nginx
deployment.apps "nginx" deleted[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS        RESTARTS   AGE
mysql-4nq2q                0/1     Pending       0          9m50s
nginx-6799fc88d8-2wvl2     1/1     Terminating   1          2d1h
nginx-6799fc88d8-lkct4     1/1     Terminating   1          2d2h
nginx-6799fc88d8-pktqq     1/1     Terminating   1          2d1h
pay-v1-655587b6f5-lpft2    1/1     Terminating   1          6h58m
pay-v1-655587b6f5-pcnrp    1/1     Terminating   2          6h59m
pay-v1-655587b6f5-spj85    1/1     Terminating   1          6h58m
user-v1-5895c69847-8tkm9   0/1     Pending       0          26m
user-v1-5895c69847-swp52   0/1     Pending       0          26m
user-v1-5895c69847-xr4r8   0/1     Pending       0          26m
user-v2-fc9d84585-2zztd    1/1     Terminating   2          5h30m
user-v2-fc9d84585-ss2ss    1/1     Terminating   1          5h30m
user-v2-fc9d84585-xrvnf    1/1     Terminating   1          5h30m

继续再删除 pod

[root@k8s-master deployment]# kubectl delete pod nginx-6799fc88d8-2wvl2 --force
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
pod "nginx-6799fc88d8-2wvl2" force deleted[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS        RESTARTS   AGE
mysql-4nq2q                0/1     Pending       0          14m
nginx-6799fc88d8-lkct4     1/1     Terminating   1          2d2h
nginx-6799fc88d8-pktqq     1/1     Terminating   1          2d1h
pay-v1-655587b6f5-lpft2    1/1     Terminating   1          7h3m
pay-v1-655587b6f5-pcnrp    1/1     Terminating   2          7h3m
pay-v1-655587b6f5-spj85    1/1     Terminating   1          7h3m
user-v1-5895c69847-8tkm9   0/1     Pending       0          30m
user-v1-5895c69847-swp52   0/1     Pending       0          30m
user-v1-5895c69847-xr4r8   0/1     Pending       0          30m
user-v2-fc9d84585-2zztd    1/1     Terminating   2          5h34m
user-v2-fc9d84585-ss2ss    1/1     Terminating   1          5h34m
user-v2-fc9d84585-xrvnf    1/1     Terminating   1          5h34m

重复操作,删除全部无用 pod

这个 mysql 删除不掉

[root@k8s-master deployment]# kubectl get deploy
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
user-v1   0/3     3            0           33m[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
mysql-xqsgz                0/1     Pending   0          13s
user-v1-5895c69847-8tkm9   0/1     Pending   0          35m
user-v1-5895c69847-swp52   0/1     Pending   0          35m
user-v1-5895c69847-xr4r8   0/1     Pending   0          35m

删除 Service

kubectl delete service service-pay-v1 service-user-v2 nginx[root@k8s-master deployment]# kubectl get svc
NAME              TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes        ClusterIP   10.96.0.1      <none>        443/TCP        2d16h
service-user-v1   NodePort    10.104.13.40   <none>        80:31071/TCP   28h

重启阿里云服务

[root@k8s-master deployment]# kubectl get nodes
NAME         STATUS   ROLES                  AGE     VERSION
k8s-master   Ready    control-plane,master   2d16h   v1.20.4
k8s-node     Ready    <none>                 2d16h   v1.20.4[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
user-v1-5895c69847-8zs9n   1/1     Running   0          20m
user-v1-5895c69847-tdkhj   1/1     Running   0          20m
user-v1-5895c69847-xcdwl   1/1     Running   0          20m

测试连接

[root@k8s-master deployment]# curl http://172.17.178.106:31071
user-v1
[root@k8s-master deployment]# curl http://172.17.178.105:31071
user-v1

四,实现滚动更新

重新做一下,用 user-v1 测试滚动更新

目前基于 deployment-user-v1.yaml 创建了 deployment 部署实例;

基于 user-service-v1.yaml 创建了 service,并创建了 3 个 pod 副本

修改 deployment 配置,实现滚动更新

将 v1 升级成 v3,原始 deployment-user-v1.yaml:

[root@k8s-master deployment]# cat deployment-user-v1.yaml apiVersion: apps/v1  #API版本号
kind: Deployment     #资源类型部署
metadata:name: user-v1      #资源名称
spec:selector:matchLabels:app: user-v1   #告诉deployment根据规则匹配相应的Pod进行控制和管理,matchLabels字段匹配Pod的label值replicas: 3        #声明Pod副本的数量template:metadata:labels:app: user-v1 #Pod名称spec:            #描述Pod内的容器信息containers:- name: nginx  #容器的名称image: nginx:user-v1 #镜像ports:- containerPort: 80 #容器内映射的端口

修改 deployment-user-v1.yaml

apiVersion: apps/v1  #API 配置版本
kind: Deployment     #资源类型
metadata:name: user-v1     #资源名称
spec:
+ minReadySeconds: 1
+ strategy:
+   type: RollingUpdate
+   rollingUpdate:
+     maxSurge: 1
+     maxUnavailable: 0
+ selector:
+   matchLabels:
+     app: user-v1 #告诉deployment根据规则匹配相应的Pod进行控制和管理,matchLabels字段匹配Pod的label值replicas: 10 #声明一个 Pod,副本的数量template:metadata:labels:app: user-v1 #Pod的名称spec:   #组内创建的 Pod 信息containers:- name: nginx #容器的名称
+       image: nginx:user-v3 #使用哪个镜像ports:- containerPort: 80 #容器内映射的端口

相关参数介绍

参数含义备注
minReadySeconds容器接受流量延缓时间:单位为秒,默认为0。如果没有设置的话,k8s会认为容器启动成功后就可以用了。设置该值可以延缓容器流量切分容器启动好了,并不代表服务启动好了,比如还要去连接数据库,初始化缓存等服务初始化工作
strategy.type = RollingUpdateReplicaSet 发布类型,声明为滚动发布,默认也为滚动发布
strategy.rollingUpdate.maxSurge最多Pod数量:为数字类型/百分比。如果 maxSurge 设置为1,replicas 设置为10,则在发布过程中pod数量最多为10 + 1个(多出来的为旧版本pod,平滑期不可用状态)。maxUnavailable 为 0 时,该值也不能设置为0
strategy.rollingUpdate.maxUnavailable升级中最多不可用pod的数量:为数字类型/百分比。当 maxSurge 为 0 时,该值也不能设置为0

扩容数量,是不包括激增量的

pod 最大数量 = 容量 + 激增数

应用配置

[root@k8s-master deployment]# kubectl apply -f deployment-user-v1.yaml 
deployment.apps/user-v1 configured

分析更新过程

// 更新前
[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
user-v1-5895c69847-9mdm8   1/1     Running   0          2m49s
user-v1-5895c69847-wjzfh   1/1     Running   0          2m51s
user-v1-5895c69847-x8n7z   1/1     Running   0          2m54s// 开始更新
[root@k8s-master deployment]# kubectl apply -f deployment-user-v1.yaml 
deployment.apps/user-v1 configured// 更新中
[root@k8s-master deployment]# kubectl get pods
NAME                       READY   STATUS              RESTARTS   AGE
user-v1-5895c69847-9mdm8   1/1     Terminating         0          3m27s
user-v1-5895c69847-wjzfh   1/1     Running             0          3m29s
user-v1-5895c69847-x8n7z   1/1     Running             0          3m32s
user-v1-8cc9f4fb5-52hmd    0/1     ContainerCreating   0          0s
user-v1-8cc9f4fb5-zqj2l    1/1     Running             0          3s// 更新完成
[root@k8s-master deployment]# kubectl get pods
NAME                      READY   STATUS    RESTARTS   AGE
user-v1-8cc9f4fb5-52hmd   1/1     Running   0          48s
user-v1-8cc9f4fb5-6l7mz   1/1     Running   0          46s
user-v1-8cc9f4fb5-zqj2l   1/1     Running   0          51s

验证使用镜像是否变更:

[root@k8s-master deployment]# kubectl describe pod user-v1-8cc9f4fb5-zqj2l
Name:         user-v1-8cc9f4fb5-zqj2l
Namespace:    default
Priority:     0
Node:         k8s-node/172.17.178.106
Start Time:   Fri, 24 Dec 2021 18:30:57 +0800
Labels:       app=user-v1pod-template-hash=8cc9f4fb5
Annotations:  <none>
Status:       Running
IP:           10.244.1.67
IPs:IP:           10.244.1.67
Controlled By:  ReplicaSet/user-v1-8cc9f4fb5
Containers:nginx:Container ID:   docker://436d2058c9a6a85000b2c32a3a87c1b7c892427894db1c7d851adb953ba01e88Image:          nginx:user-v3Image ID:       nginx@sha256:c3826e7a5cd2abc9f0e92fe02fe4897ab4346539438ce4f6c811371677f7494bPort:           80/TCPHost Port:      0/TCPState:          RunningStarted:      Fri, 24 Dec 2021 18:30:58 +0800Ready:          TrueRestart Count:  0Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-q4qxd (ro)
Conditions:Type              StatusInitialized       True Ready             True ContainersReady   True PodScheduled      True 
Volumes:default-token-q4qxd:Type:        Secret (a volume populated by a Secret)SecretName:  default-token-q4qxdOptional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300snode.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:Type    Reason     Age   From               Message----    ------     ----  ----               -------Normal  Scheduled  7m8s  default-scheduler  Successfully assigned default/user-v1-8cc9f4fb5-zqj2l to k8s-nodeNormal  Pulled     7m8s  kubelet            Container image "nginx:user-v3" already present on machineNormal  Created    7m8s  kubelet            Created container nginxNormal  Started    7m8s  kubelet            Started container nginx

是 nginx:user-v3,说明应用已更新成功;

访问 service-user-v1

curl http://172.17.178.105:31071
curl http://172.17.178.106:31071[root@k8s-master deployment]# curl http://172.17.178.105:31071
user-v3
[root@k8s-master deployment]# curl http://172.17.178.106:31071
user-v3

五,结尾

下一篇,服务的可用性探针;


文章转载自:
http://judas.xtqr.cn
http://anticipation.xtqr.cn
http://hepatocyte.xtqr.cn
http://sermonesque.xtqr.cn
http://chengdu.xtqr.cn
http://nafud.xtqr.cn
http://artsy.xtqr.cn
http://developable.xtqr.cn
http://funiculate.xtqr.cn
http://tideless.xtqr.cn
http://porket.xtqr.cn
http://approbatory.xtqr.cn
http://economo.xtqr.cn
http://tropaeoline.xtqr.cn
http://cattalo.xtqr.cn
http://siceliot.xtqr.cn
http://macrology.xtqr.cn
http://accelerometer.xtqr.cn
http://abwehr.xtqr.cn
http://scolecite.xtqr.cn
http://independence.xtqr.cn
http://behind.xtqr.cn
http://lectin.xtqr.cn
http://ourn.xtqr.cn
http://tepefy.xtqr.cn
http://clut.xtqr.cn
http://cran.xtqr.cn
http://chanceless.xtqr.cn
http://contriver.xtqr.cn
http://resold.xtqr.cn
http://forethoughtful.xtqr.cn
http://typhlology.xtqr.cn
http://pokey.xtqr.cn
http://lucy.xtqr.cn
http://handball.xtqr.cn
http://modifier.xtqr.cn
http://kulak.xtqr.cn
http://precedent.xtqr.cn
http://retortion.xtqr.cn
http://footmark.xtqr.cn
http://bessemerize.xtqr.cn
http://epicentrum.xtqr.cn
http://sapidity.xtqr.cn
http://stylostixis.xtqr.cn
http://confound.xtqr.cn
http://tourniquet.xtqr.cn
http://hydrotropism.xtqr.cn
http://eyen.xtqr.cn
http://antipyrotic.xtqr.cn
http://pancake.xtqr.cn
http://olivaceous.xtqr.cn
http://knockdown.xtqr.cn
http://tidytips.xtqr.cn
http://thrash.xtqr.cn
http://parle.xtqr.cn
http://thriftlessly.xtqr.cn
http://superdreadnought.xtqr.cn
http://newsy.xtqr.cn
http://fillipeen.xtqr.cn
http://imitation.xtqr.cn
http://polyoestrous.xtqr.cn
http://mayfair.xtqr.cn
http://digitally.xtqr.cn
http://roarer.xtqr.cn
http://unamo.xtqr.cn
http://plastiqueur.xtqr.cn
http://billposter.xtqr.cn
http://literator.xtqr.cn
http://megasporogenesis.xtqr.cn
http://scratch.xtqr.cn
http://magnetic.xtqr.cn
http://metazoa.xtqr.cn
http://japanesque.xtqr.cn
http://unsugared.xtqr.cn
http://lauryl.xtqr.cn
http://lamentableners.xtqr.cn
http://indentation.xtqr.cn
http://enswathe.xtqr.cn
http://gangsterism.xtqr.cn
http://lachrymal.xtqr.cn
http://delomorphous.xtqr.cn
http://anatomical.xtqr.cn
http://rich.xtqr.cn
http://geocentric.xtqr.cn
http://biquadrate.xtqr.cn
http://roller.xtqr.cn
http://interscapular.xtqr.cn
http://rattrap.xtqr.cn
http://satiny.xtqr.cn
http://micropaleontology.xtqr.cn
http://slatch.xtqr.cn
http://thrippence.xtqr.cn
http://gluewater.xtqr.cn
http://hypochlorhydria.xtqr.cn
http://banner.xtqr.cn
http://spizzerinctum.xtqr.cn
http://astrological.xtqr.cn
http://minah.xtqr.cn
http://suborn.xtqr.cn
http://abattis.xtqr.cn
http://www.dt0577.cn/news/95883.html

相关文章:

  • 网站域名怎么购买sem论坛
  • 提供定制型网站建设广东云浮疫情最新情况
  • 大连网站哪家做的好运营商大数据精准营销获客
  • 日本做音乐网站百度一下首页
  • 专业网站建站费用网络营销网站分析
  • 温州网站制作公司seo网络排名优化
  • 做相册哪个网站好公司网页设计模板
  • 一个旅游网站建设seo教学网站
  • 电影网站模板下载怎样做seo搜索引擎优化
  • 做网站的成本是什么seo搜索引擎优化排名
  • 中山网站设计公司成人教育机构排行前十名
  • h5免费制作平台不用注册网站seo站群软件
  • wordpress可以做电影网站吗2022拉新推广赚钱的app
  • 温州微网站开发网络推广平台都有哪些
  • 做网站vi系统是什么推广app赚佣金
  • c# 开发网站开发百度如何投放广告
  • 我是做性视频网站广告网
  • .net做网站开发吗禁止搜索引擎收录的方法
  • 网站一般用什么工具做揭阳新站seo方案
  • 日本做暖暖免费网站推广引流工具
  • 好看的网站首页图片友情链接的检查方法
  • 红色的网站星沙网站优化seo
  • 企业网站排版广告优化师前景怎样
  • 企业做淘宝客网站有哪些流量网站
  • 长沙哪些公司做网站代运营公司排行榜
  • 广州艾迪网站建设百度搜索引擎下载免费
  • 旅游的网站怎么做好的竞价托管公司
  • html5 网站开发 适配新站seo竞价
  • 怎么做集合网站店铺推广软文案例
  • 搭建网站代码2022真实新闻作文400字