研发工程师玩转Kubernetes——使用Deployment进行版本升级

news2025/1/19 7:55:00

软件升级是一件非常常见的事,本节我们将尝试使用Deployment进行软件升级。

更新simple_http版本

我们还是借助《研发工程师玩转Kubernetes——构建、推送自定义镜像》中的代码库,只是稍微修改一下Dockerfile——将版本变成2。

From python:3.11
RUN pip install --upgrade pip
COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
COPY main.py /main.py
CMD ["python","main.py","-port","8888","-version","2"]

在这里插入图片描述

构建镜像

docker build -t simple_http:v2 .
Sending build context to Docker daemon  16.25MB
Step 1/6 : From python:3.11
 ---> 815c8c75dfc0
Step 2/6 : RUN pip install --upgrade pip
 ---> Using cache
 ---> e26af84d8b3e
Step 3/6 : COPY requirements.txt /requirements.txt
 ---> Using cache
 ---> 9e14379efd70
Step 4/6 : RUN pip install -r /requirements.txt
 ---> Using cache
 ---> 964f97edf3b5
Step 5/6 : COPY main.py /main.py
 ---> Using cache
 ---> 183ac054cd4d
Step 6/6 : CMD ["python","main.py","-port","8888","-version","2"]
 ---> Running in 1fc7e3afb2c9
Removing intermediate container 1fc7e3afb2c9
 ---> 57ab1ae7f5de
Successfully built 57ab1ae7f5de
Successfully tagged simple_http:v2

推送镜像

docker tag simple_http:v2 localhost:32000/simple_http:v2
docker push localhost:32000/simple_http:v2

上线老版本

直接借用《研发工程师玩转Kubernetes——使用Deployment进行多副本维护》的案例。具体请转到这篇文章。只要部署了2个Pod即可。
使用下面指令查看Pod

kubectl describe pod
Name:             simple-http-deployment-5995f574dc-lzs8v
Namespace:        default
Priority:         0
Service Account:  default
Node:             fangliang-virtual-machine/172.30.45.36
Start Time:       Mon, 22 May 2023 21:27:01 +0800
Labels:           app=simple_http
                  pod-template-hash=5995f574dc
Annotations:      cni.projectcalico.org/containerID: 311e41d76878cb77546a754ad1123556a58c3b3b3ea087634d80dcf6f12240e8
                  cni.projectcalico.org/podIP: 10.1.62.150/32
                  cni.projectcalico.org/podIPs: 10.1.62.150/32
Status:           Running
IP:               10.1.62.150
IPs:
  IP:           10.1.62.150
Controlled By:  ReplicaSet/simple-http-deployment-5995f574dc
Containers:
  simple-http-container:
    Container ID:   containerd://5f722b33ba614ae1c4351567e0fb07946cb26b8529d55ab1ca9168f1af4563b8
    Image:          localhost:32000/simple_http:v1
    Image ID:       localhost:32000/simple_http@sha256:cbee584f83426593efb95a9e2213bb40143a1c86c3d217e65d30430033f846d4
    Port:           8888/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 22 May 2023 21:27:03 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-62cr6 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-62cr6:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  22s   default-scheduler  Successfully assigned default/simple-http-deployment-5995f574dc-lzs8v to fangliang-virtual-machine
  Normal  Pulled     22s   kubelet            Container image "localhost:32000/simple_http:v1" already present on machine
  Normal  Created    22s   kubelet            Created container simple-http-container
  Normal  Started    21s   kubelet            Started container simple-http-container


Name:             simple-http-deployment-5995f574dc-l7zwv
Namespace:        default
Priority:         0
Service Account:  default
Node:             fangliang-virtual-machine/172.30.45.36
Start Time:       Mon, 22 May 2023 21:27:01 +0800
Labels:           app=simple_http
                  pod-template-hash=5995f574dc
Annotations:      cni.projectcalico.org/containerID: 613a62e30933c3715b43de4e83ccf1baa93e53ac1434cf63dd93178a5214c992
                  cni.projectcalico.org/podIP: 10.1.62.149/32
                  cni.projectcalico.org/podIPs: 10.1.62.149/32
Status:           Running
IP:               10.1.62.149
IPs:
  IP:           10.1.62.149
Controlled By:  ReplicaSet/simple-http-deployment-5995f574dc
Containers:
  simple-http-container:
    Container ID:   containerd://e52726f94486008b8bd375e0dac3243ad534186ea63d7ca5ae522c68fb05d89a
    Image:          localhost:32000/simple_http:v1
    Image ID:       localhost:32000/simple_http@sha256:cbee584f83426593efb95a9e2213bb40143a1c86c3d217e65d30430033f846d4
    Port:           8888/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 22 May 2023 21:27:03 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-5hpdv (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-5hpdv:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  22s   default-scheduler  Successfully assigned default/simple-http-deployment-5995f574dc-l7zwv to fangliang-virtual-machine
  Normal  Pulled     22s   kubelet            Container image "localhost:32000/simple_http:v1" already present on machine
  Normal  Created    22s   kubelet            Created container simple-http-container
  Normal  Started    21s   kubelet            Started container simple-http-container

可以看到两个Pod(simple-http-deployment-5995f574dc-lzs8v和simple-http-deployment-5995f574dc-l7zwv)对应的Image都是localhost:32000/simple_http:v1。

查看Deployment

kubectl describe deployments.apps simple-http-deployment 
Name:                   simple-http-deployment
Namespace:              default
CreationTimestamp:      Mon, 22 May 2023 21:27:01 +0800
Labels:                 <none>
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=simple_http
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=simple_http
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v1
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   simple-http-deployment-5995f574dc (2/2 replicas created)
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  3m16s  deployment-controller  Scaled up replica set simple-http-deployment-5995f574dc to 2

此时我们看到该Deployment管理的ReplicaSet是simple-http-deployment-5995f574dc。

更新

kubectl set image deployments/simple-http-deployment simple-http-container=localhost:32000/simple_http:v2

deployment.apps/simple-http-deployment image updated

我们查看下Pod

Name:             simple-http-deployment-576c865db-k48mn
Namespace:        default
Priority:         0
Service Account:  default
Node:             fangliang-virtual-machine/172.30.45.36
Start Time:       Mon, 22 May 2023 21:32:16 +0800
Labels:           app=simple_http
                  pod-template-hash=576c865db
Annotations:      cni.projectcalico.org/containerID: e35c8331fb45eeef955671d86bcd5156082246875362f2a87b87ac8be05fdfe6
                  cni.projectcalico.org/podIP: 10.1.62.147/32
                  cni.projectcalico.org/podIPs: 10.1.62.147/32
Status:           Running
IP:               10.1.62.147
IPs:
  IP:           10.1.62.147
Controlled By:  ReplicaSet/simple-http-deployment-576c865db
Containers:
  simple-http-container:
    Container ID:   containerd://ffe70fe17696d901bb2a460469ae318bccfac95e0fe6f0ca0e157308641615d1
    Image:          localhost:32000/simple_http:v2
    Image ID:       localhost:32000/simple_http@sha256:213ba4174b3afac02b48af19258c03b32a426d31ca27742e05aacea7a7a6edc1
    Port:           8888/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 22 May 2023 21:32:18 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-5z9dp (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-5z9dp:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  38s   default-scheduler  Successfully assigned default/simple-http-deployment-576c865db-k48mn to fangliang-virtual-machine
  Normal  Pulling    38s   kubelet            Pulling image "localhost:32000/simple_http:v2"
  Normal  Pulled     38s   kubelet            Successfully pulled image "localhost:32000/simple_http:v2" in 119.472724ms (119.476524ms including waiting)
  Normal  Created    38s   kubelet            Created container simple-http-container
  Normal  Started    37s   kubelet            Started container simple-http-container


Name:             simple-http-deployment-576c865db-bjwns
Namespace:        default
Priority:         0
Service Account:  default
Node:             fangliang-virtual-machine/172.30.45.36
Start Time:       Mon, 22 May 2023 21:32:18 +0800
Labels:           app=simple_http
                  pod-template-hash=576c865db
Annotations:      cni.projectcalico.org/containerID: 11f76fe799f1b5a3d4899305e9443d2bcedc5f815c28c8c44f8664f93cc150e4
                  cni.projectcalico.org/podIP: 10.1.62.156/32
                  cni.projectcalico.org/podIPs: 10.1.62.156/32
Status:           Running
IP:               10.1.62.156
IPs:
  IP:           10.1.62.156
Controlled By:  ReplicaSet/simple-http-deployment-576c865db
Containers:
  simple-http-container:
    Container ID:   containerd://2459b017ee5fb29ac61f488ffc0eabb0016f5a18bf6b031345480d9d2fb3c84a
    Image:          localhost:32000/simple_http:v2
    Image ID:       localhost:32000/simple_http@sha256:213ba4174b3afac02b48af19258c03b32a426d31ca27742e05aacea7a7a6edc1
    Port:           8888/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 22 May 2023 21:32:19 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-4lp5j (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-4lp5j:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  37s   default-scheduler  Successfully assigned default/simple-http-deployment-576c865db-bjwns to fangliang-virtual-machine
  Normal  Pulled     36s   kubelet            Container image "localhost:32000/simple_http:v2" already present on machine
  Normal  Created    36s   kubelet            Created container simple-http-container
  Normal  Started    36s   kubelet            Started container simple-http-container

老的Pod(simple-http-deployment-5995f574dc-lzs8v和simple-http-deployment-5995f574dc-l7zwv)被删除了,新的Pod( simple-http-deployment-576c865db-k48mn和simple-http-deployment-576c865db-bjwns)被创建出来。

查看ReplicaSet

kubectl describe replicasets.apps 
Name:           simple-http-deployment-576c865db
Namespace:      default
Selector:       app=simple_http,pod-template-hash=576c865db
Labels:         app=simple_http
                pod-template-hash=576c865db
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 2
Controlled By:  Deployment/simple-http-deployment
Replicas:       2 current / 2 desired
Pods Status:    2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=576c865db
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v2
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulCreate  97s   replicaset-controller  Created pod: simple-http-deployment-576c865db-k48mn
  Normal  SuccessfulCreate  95s   replicaset-controller  Created pod: simple-http-deployment-576c865db-bjwns


Name:           simple-http-deployment-5995f574dc
Namespace:      default
Selector:       app=simple_http,pod-template-hash=5995f574dc
Labels:         app=simple_http
                pod-template-hash=5995f574dc
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 1
Controlled By:  Deployment/simple-http-deployment
Replicas:       0 current / 0 desired
Pods Status:    0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=5995f574dc
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v1
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulDelete  95s   replicaset-controller  Deleted pod: simple-http-deployment-5995f574dc-l7zwv
  Normal  SuccessfulDelete  93s   replicaset-controller  Deleted pod: simple-http-deployment-5995f574dc-lzs8v

可以看到老的ReplicaSet在删除老Pod,新的则创建了新的Pod。
再过段时间执行上述命令,可以看到老的ReplicaSet并没有被删除。

Name:           simple-http-deployment-576c865db
Namespace:      default
Selector:       app=simple_http,pod-template-hash=576c865db
Labels:         app=simple_http
                pod-template-hash=576c865db
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 2
Controlled By:  Deployment/simple-http-deployment
Replicas:       2 current / 2 desired
Pods Status:    2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=576c865db
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v2
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:           <none>


Name:           simple-http-deployment-5995f574dc
Namespace:      default
Selector:       app=simple_http,pod-template-hash=5995f574dc
Labels:         app=simple_http
                pod-template-hash=5995f574dc
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 1
Controlled By:  Deployment/simple-http-deployment
Replicas:       0 current / 0 desired
Pods Status:    0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=5995f574dc
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v1
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:           <none>

查看Deployment更新后信息

kubectl describe deployments.apps 
Name:                   simple-http-deployment
Namespace:              default
CreationTimestamp:      Mon, 22 May 2023 21:27:01 +0800
Labels:                 <none>
Annotations:            deployment.kubernetes.io/revision: 2
Selector:               app=simple_http
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=simple_http
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v2
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   simple-http-deployment-576c865db (2/2 replicas created)
Events:          <none>

可以看到NewReplicaSet被更新为新的ReplicaSet simple-http-deployment-576c865db 。老的ReplicaSet simple-http-deployment-5995f574dcz在这儿没有体现。

回滚

 kubectl rollout undo deployment simple-http-deployment

deployment.apps/simple-http-deployment rolled back

查看Deployment

kubectl describe deployments.apps
Name:                   simple-http-deployment
Namespace:              default
CreationTimestamp:      Mon, 22 May 2023 21:27:01 +0800
Labels:                 <none>
Annotations:            deployment.kubernetes.io/revision: 3
Selector:               app=simple_http
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=simple_http
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v1
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   simple-http-deployment-5995f574dc (2/2 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  4s    deployment-controller  Scaled up replica set simple-http-deployment-5995f574dc to 1 from 0
  Normal  ScalingReplicaSet  3s    deployment-controller  Scaled down replica set simple-http-deployment-576c865db to 1 from 2
  Normal  ScalingReplicaSet  3s    deployment-controller  Scaled up replica set simple-http-deployment-5995f574dc to 2 from 1
  Normal  ScalingReplicaSet  1s    deployment-controller  Scaled down replica set simple-http-deployment-576c865db to 0 from 1

可以看到最开始V1版本对应的ReplicaSet simple-http-deployment-5995f574dc又被启用,镜像也变成了三个版本localhost:32000/simple_http:v1。

查看ReplicaSet

kubectl describe replicasets.apps 
Name:           simple-http-deployment-5995f574dc
Namespace:      default
Selector:       app=simple_http,pod-template-hash=5995f574dc
Labels:         app=simple_http
                pod-template-hash=5995f574dc
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 3
                deployment.kubernetes.io/revision-history: 1
Controlled By:  Deployment/simple-http-deployment
Replicas:       2 current / 2 desired
Pods Status:    2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=5995f574dc
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v1
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulCreate  24s   replicaset-controller  Created pod: simple-http-deployment-5995f574dc-6dmtt
  Normal  SuccessfulCreate  23s   replicaset-controller  Created pod: simple-http-deployment-5995f574dc-547sp


Name:           simple-http-deployment-576c865db
Namespace:      default
Selector:       app=simple_http,pod-template-hash=576c865db
Labels:         app=simple_http
                pod-template-hash=576c865db
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 2
Controlled By:  Deployment/simple-http-deployment
Replicas:       0 current / 0 desired
Pods Status:    2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=576c865db
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v2
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulDelete  23s   replicaset-controller  Deleted pod: simple-http-deployment-576c865db-bjwns
  Normal  SuccessfulDelete  21s   replicaset-controller  Deleted pod: simple-http-deployment-576c865db-k48mn

可以看到V2版本对应的ReplicaSet还存在。
这是否意味着再次回滚又会回滚到V2呢?是的。

再回滚

再将kubectl rollout undo deployment simple-http-deployment执行一遍,可以发现Deployment又启用了V2版本对应的simple-http-deployment-576c865db,弃用了V1版本对应的simple-http-deployment-5995f574dc。

kubectl describe replicasets.apps
Name:           simple-http-deployment-576c865db
Namespace:      default
Selector:       app=simple_http,pod-template-hash=576c865db
Labels:         app=simple_http
                pod-template-hash=576c865db
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 4
                deployment.kubernetes.io/revision-history: 2
Controlled By:  Deployment/simple-http-deployment
Replicas:       2 current / 2 desired
Pods Status:    2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=576c865db
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v2
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulCreate  8s    replicaset-controller  Created pod: simple-http-deployment-576c865db-qm5gp
  Normal  SuccessfulCreate  7s    replicaset-controller  Created pod: simple-http-deployment-576c865db-bzbbw


Name:           simple-http-deployment-5995f574dc
Namespace:      default
Selector:       app=simple_http,pod-template-hash=5995f574dc
Labels:         app=simple_http
                pod-template-hash=5995f574dc
Annotations:    deployment.kubernetes.io/desired-replicas: 2
                deployment.kubernetes.io/max-replicas: 3
                deployment.kubernetes.io/revision: 3
                deployment.kubernetes.io/revision-history: 1
Controlled By:  Deployment/simple-http-deployment
Replicas:       0 current / 0 desired
Pods Status:    2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=simple_http
           pod-template-hash=5995f574dc
  Containers:
   simple-http-container:
    Image:        localhost:32000/simple_http:v1
    Port:         8888/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulDelete  7s    replicaset-controller  Deleted pod: simple-http-deployment-5995f574dc-6dmtt
  Normal  SuccessfulDelete  5s    replicaset-controller  Deleted pod: simple-http-deployment-5995f574dc-547sp

通过这次实验,我们就更好理解Deployment是如何使用ReplicaSet来做版本管理的了。
在这里插入图片描述

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

TypeScript - Interfaces(接口)

目录 1、接口介绍 1.1 接口示例 2、可选属性 3、只读属性 4、额外的属性检查 5、函数类型 6、可索引的类型 &#xff17;、类类型 &#xff17;.1 类静态部分和实例部分 &#xff18;、继承接口 &#xff19;、混合类型 1&#xff10;、接口继承类 1、接口介绍 Ty…

探索未来:物联网的无限可能

连接万物&#xff0c;创造未来。从智能家居到智慧医疗&#xff0c;从智能车联到智慧城市&#xff0c;物联网技术的影响已经悄然渗透到了我们的方方面面。欢迎大家积极讨论联网技术如何影响了我们的生活。 物联网技术概述 物联网技术&#xff08;Internet of Things&#xff0…

WebStorm 固定 调试版 Chrome

WebStorm 固定 调试版 Chrome 每次升级 WebStorm 都会打开一个新的 Chrome&#xff0c;导致调试时需要重新登录&#xff0c;重新安装插件等问题。 解决办法&#xff1a; 固定 WebStorm 中 Chrome UserData 的路径&#xff0c;这样每次打开的 Chrome 都是同一个。 文件 | 设…

HJ73 计算日期到天数转换

1.题目&#xff1a; 2.分析&#xff1a; 1. 通过枚举每个月的1号是这一年的第几天&#xff0c;从而进行累加求和即可&#xff0c;其中注意闰年的处理 3.我的代码&#xff1a; #include <iostream> using namespace std;int main() {int arr[13] { 0, 31, 28, 31, 30,…

设计模式基础-面向对象基础

✨作者&#xff1a;猫十二懿 ❤️‍&#x1f525;账号&#xff1a;CSDN 、掘金 、个人博客 、Github &#x1f389;公众号&#xff1a;猫十二懿 这里只是简单的将《大话设计模式【Java溢彩加强版】》的内容简单是复述一下&#xff0c;并加上自己的理解 在学习Java设计模式的时候…

Hadoop集群实现时间同步

一.为什么要对集群实现时间同步 因为我们在集群使用hive&#xff0c;mysql&#xff0c;hdfs之间等使用sqoop传输数据的时候&#xff0c;如果集群之间没有同步时间的话&#xff0c;那么就会报错&#xff0c;无法实现数据的传输。 不仅如此&#xff0c;在集群的使用当中&#xff…

logstash的快速使用

同品&#xff1a; filebeat&#xff1a;只做数据收集&#xff0c;讲数据输出到指定目的地&#xff0c;占用资源小 logstash:收集日志数据&#xff0c;还能过滤&#xff0c;转换数据&#xff0c;组需要更多资源 目录 1.logstash的安装 2.配置文件 3.创建容器 4.引入依赖 …

设计模式期末程序题(只是一个简单整理)

1.下图是某系统的数据部分的类图。因为该层次结构中的操作需要经常变化&#xff0c;所以需要用访问者模式对其进行重构&#xff0c;请按以下要求完成题目&#xff1a; &#xff08;1&#xff09;绘制重构后系统完整类图。&#xff08;4分&#xff09; &#xff08;2&#xff09…

第一章 数学基础

目录 一、线性代数二、微积分三、概率 一、线性代数 理解范数概念区分向量的内积 a ⋅ b \mathbf{a} \cdot \mathbf{b} a⋅b 与外积 a b \mathbf{a} \times \mathbf{b} ab区分矩阵的乘法 A ⊗ B \mathbf{A} \otimes \mathbf{B} A⊗B、内积 A B \mathbf{A} \mathbf{B} AB 、…

通过Python的PyPDF2库提取pdf中的图片

文章目录 前言一、PyPDF2库是什么&#xff1f;二、安装PyPDF2库三、查看PyPDF2库版本四、使用方法待提取的pdf截图1.引入库2.定义pdf路径3.打开PDF文件4.创建PDF阅读器对象5.获取PDF文件中的页数6.遍历每一页进行处理7.提取出来的图片 总结 前言 大家好&#xff0c;我是空空sta…

【Linux初阶】进程程序替换 | 初识、原理、函数、应用 makefile工具的多文件编译

&#x1f31f;hello&#xff0c;各位读者大大们你们好呀&#x1f31f; &#x1f36d;&#x1f36d;系列专栏&#xff1a;【Linux初阶】 ✒️✒️本篇内容&#xff1a;替换初识&#xff0c;替换原理&#xff0c;替换函数理解和使用&#xff0c;makefile工具的多文件编译&#xf…

C++(4):表达式

表达式由一个或多个运算对象(operand)组成,对表达式求值将得到一个结果(result&#xff09;。字面值和变量是最简单的表达式&#xff08;expression)&#xff0c;其结果就是字面值和变量的值。把一个运算符&#xff08;operator)和一个或多个运算对象组合起来可以生成较复杂的表…

倒挂的解决方案你现在是一位计算机专家,来聊一聊:“美国的火星探测器Mars Path-finder 就是因为优先级倒挂而出现故障的故事”

目录 倒挂的解决方案 你现在是一位计算机专家&#xff0c;来聊一聊&#xff1a;“美国的火星探测器Mars Path-finder 就是因为优先级倒挂而出现故障的故事” ●使用中断禁止 具体证明请参阅Liu和Kayland于1973年发表的论文。 ● 因时序或外部中断或进程挂起而导致操作系统获…

数据结构-关键路径-理论

1.AOE-网 与AOV-网相对应的是AOE-网&#xff08;Activity On Netword&#xff09;&#xff0c;即以边表示活动的网。AOE-网是带权的有向无环图&#xff0c;其中&#xff0c;定点表示时间&#xff0c;弧表示活动&#xff0c;权表示活动持续的时间。通常AOE-网可用来估算工程的完…

Base64字符串从前台传到后台以后,“+”加号消失

记录一下问题&#xff1a; 使用 encodeURI(str) 对字符串进行加密的时候&#xff0c;后端解密会丢失 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content&…

第一章.机器学习的基础概念

第一章.机器学习的基础概念 1.1 机器学习的基础概念 1.机器学的概念&#xff1a; 机器学习就是机器从数据中总结经验。从数据中找出某种规律或者模型&#xff0c;并用他来解决某种实际问题。 2.机器学习的应用场景 1).事物本身存在某种潜在规律 2).某些问题难以使用普通编程…

two-stage目标检测算法

R-CNN 现在&#xff0c;将目光穿越回2012年&#xff0c;hinton刚刚提出alexnet的时代。 此时&#xff0c;该如何审视目标检测任务&#xff1f; 当时的目标检测采用的是滑动窗口手动特征分类器的思路。 该方法的弱点包括 速度慢 精度差 精度差的问题是由手工特征造成的&am…

【VS安装记录】Visual Studio 2022安装教程(超详细)

大家好&#xff0c;我是雷工&#xff01; 由于更换了电脑&#xff0c;很多软件需要重新安装&#xff0c;为了方便学习C#&#xff0c;今天有时间安装下Visual Studio 2022&#xff0c;顺便记录安装过程。 1、从官网下载并解压软件压缩包&#xff0c;然后打开文件夹。 2、双击…

切比雪夫不等式,大数定律及极限定理。

一.切比雪夫不等式 1.定理 若随机变量X的期望EX和方差DX存在,则对任意ε > 0,有   P{ |X - EX| > ε } < DX/ε2 或 P{ |X - EX| < ε } > 1 - DX/ε2 2.解析定理 ①该定理对 X 服从什么分布不做要求&#xff0c;仅EX DX存在即可。 ②“| |” 由于X某次…

linux kernel pwn 基础知识

基础知识 内核概述 内核架构 通常来说我们可以把内核架构分为两种&#xff1a;宏内核和微内核&#xff0c;现在还有一种内核是混合了宏内核与微内核的特性&#xff0c;称为混合内核。 宏内核&#xff08;Monolithic kernel&#xff09;&#xff0c;也译为集成式内核、单体…