精华内容
下载资源
问答
  • Deployment

    2020-11-30 09:04:57
    什么是Deployment 在Pod:Kubernetes中的最小调度对象这个章节介绍了Pod,Pod是Kubernetes创建或部署的最小单位,但是Pod是被设计为相对短暂的一次性实体,Pod可以被驱逐(当节点资源不足时)、随着集群的节点崩溃而...

    什么是Deployment

    Pod:Kubernetes中的最小调度对象这个章节介绍了Pod,Pod是Kubernetes创建或部署的最小单位,但是Pod是被设计为相对短暂的一次性实体,Pod可以被驱逐(当节点资源不足时)、随着集群的节点崩溃而消失。Kubernetes提供了Controller(控制器)来管理Pod,Controller可以创建和管理多个Pod,提供副本管理、滚动升级和自愈能力,其中最为常用的就是Deployment。

    图1 Deployment
    在这里插入图片描述

    一个Deployment可以包含一个或多个Pod副本,每个Pod副本的角色相同,所以系统会自动为Deployment的多个Pod副本分发请求。
    Deployment集成了上线部署、滚动升级、创建副本、恢复上线的功能,在某种程度上,Deployment实现无人值守的上线,大大降低了上线过程的复杂性和操作风险。

    创建Deployment

    以下示例为创建一个名为nginx的Deployment负载,使用nginx:latest镜像创建两个Pod,每个Pod占用100m core CPU、200M内存。

    apiVersion: apps/v1      # 注意这里与Pod的区别,Deployment是apps/v1而不是v1
    kind: Deployment         # 资源类型为Deployment
    metadata:
      name: nginx            # Deployment的名称
    spec:
      replicas: 2            # Pod的数量,Deployment会确保一直有2个Pod运行         
      selector:              # Label Selector
        matchLabels:
          app: nginx
      template:              # Pod的定义,用于创建Pod,也称为Pod template
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - image: nginx:latest
            name: container-0
            resources:
              limits:
                cpu: 100m
                memory: 200Mi
              requests:
                cpu: 100m
                memory: 200Mi
          imagePullSecrets:
          - name: default-secret
    

    从这个定义中可以看到Deployment的名称为nginx,spec.replicas定义了Pod的数量,即这个Deployment控制2个Pod;spec.selector是Label Selector(标签选择器),表示这个Deployment会选择Label为app=nginx的Pod;spec.template是Pod的定义,内容与Pod中的定义完全一致。
    将上面Deployment的定义保存到deployment.yaml文件中,使用kubectl创建这个Deployment。
    使用kubectl get查看Deployment和Pod,可以看到READY值为2/2,前一个2表示当前有2个Pod运行,后一个2表示期望有2个Pod,AVAILABLE为2表示有2个Pod是可用的。

    $ kubectl create -f deployment.yaml
    deployment.apps/nginx created
    
    $ kubectl get deploy
    NAME           READY     UP-TO-DATE   AVAILABLE   AGE
    nginx          2/2       2            2           4m5s
    

    Deployment如何控制Pod

    继续查询Pod,如下所示。

    $ kubectl get pods
    NAME                     READY     STATUS    RESTARTS   AGE
    nginx-7f98958cdf-tdmqk   1/1       Running   0          13s
    nginx-7f98958cdf-txckx   1/1       Running   0          13s
    

    如果删掉一个Pod,您会发现立马会有一个新的Pod被创建出来,如下所示,这就是前面所说的Deployment会确保有2个Pod在运行,如果删掉一个,Deployment会重新创建一个,如果某个Pod故障或有其他问题,Deployment会自动拉起这个Pod。

    $ kubectl delete pod nginx-7f98958cdf-txckx
    
    $ kubectl get pods
    NAME                     READY     STATUS    RESTARTS   AGE
    nginx-7f98958cdf-tdmqk   1/1       Running   0          21s
    nginx-7f98958cdf-tesqr   1/1       Running   0          21s
    

    看到有如下两个名为nginx-7f98958cdf-tdmqk和nginx-7f98958cdf-tesqr的Pod, 其中nginx是直接使用Deployment的名称,-7f98958cdf-tdmqk和-7f98958cdf-tesqr是kubernetes随机生成的后缀。
    您也许会发现这两个后缀中前面一部分是相同的,都是7f98958cdf,这是因为Deployment不是直接控制Pod的,Deployment是通过一种名为ReplicaSet的控制器控制Pod,通过如下命令可以查询ReplicaSet,其中rs是ReplicaSet的缩写。

    $ kubectl get rs
    NAME               DESIRED   CURRENT   READY     AGE
    nginx-7f98958cdf   2         2         2         1m
    

    这个ReplicaSet的名称为nginx-7f98958cdf,后缀-7f98958cdf也是随机生成的。
    Deployment控制Pod的方式如图2所示,Deployment控制ReplicaSet,ReplicaSet控制Pod。

    图2 Deployment通过ReplicaSet控制Pod
    在这里插入图片描述

    如果使用kubectl describe命令查看Deployment的详情,您就可以看到ReplicaSet,如下所示,可以看到有一行NewReplicaSet: nginx-7f98958cdf (2/2 replicas created),而且Events里面事件确是把ReplicaSet的实例扩容到2个。在实际使用中您也许不会直接操作ReplicaSet,但了解Deployment通过控制ReplicaSet来控制Pod会有助于您定位问题。

    $ kubectl describe deploy nginx
    Name:                   nginx
    Namespace:              default
    CreationTimestamp:      Sun, 16 Dec 2018 19:21:58 +0800
    Labels:                 app=nginx
    
    ...
    
    NewReplicaSet:   nginx-7f98958cdf (2/2 replicas created)
    Events:
      Type    Reason             Age   From                   Message
      ----    ------             ----  ----                   -------
      Normal  ScalingReplicaSet  5m    deployment-controller  Scaled up replica set nginx-7f98958cdf to 2
    

    升级

    在实际应用中,升级是一个常见的场景,Deployment能够很方便的支撑应用升级。
    Deployment可以设置不同的升级策略,有如下两种。

    • RollingUpdate:滚动升级,即逐步创建新Pod再删除旧Pod,为默认策略。
    • Recreate:替换升级,即先把当前Pod删掉再重新创建Pod。

    Deployment的升级可以是声明式的,也就是说只需要修改Deployment的YAML定义即可,比如使用kubectl edit命令将上面Deployment中的镜像修改为nginx:alpine。修改完成后再查询ReplicaSet和Pod,发现创建了一个新的ReplicaSet,Pod也重新创建了。

    $ kubectl edit deploy nginx
    
    $ kubectl get rs
    NAME               DESIRED   CURRENT   READY     AGE
    nginx-6f9f58dffd   2         2         2         1m
    nginx-7f98958cdf   0         0         0         48m
    
    $ kubectl get pods
    NAME                     READY     STATUS    RESTARTS   AGE
    nginx-6f9f58dffd-tdmqk   1/1       Running   0          21s
    nginx-6f9f58dffd-tesqr   1/1       Running   0          21s
    

    Deployment可以通过maxSurge和maxUnavailable两个参数控制升级过程中同时重新创建Pod的比例,这在很多时候是非常有用,配置如下所示。

    spec:
      strategy:
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 0
        type: RollingUpdate
    
    • maxSurge:与Deployment中spec.replicas相比,可以有多少个Pod存在,默认值是25%,比如spec.replicas为4,那升级过程中就不能超过5个Pod存在,即按1个的步伐升级,实际升级过程中会换算成数字,且换算会向上取整。这个值也可以直接设置成数字。
    • maxUnavailable:与Deployment中spec.replicas相比,可以有多少个Pod失效,也就是删除的比例,默认值是25%,比如spec.replicas为4,那升级过程中就至少有3个Pod存在,即删除Pod的步伐是1。同样这个值也可以设置成数字。

    在前面的例子中,由于spec.replicas是2,如果maxSurge和maxUnavailable都为默认值25%,那实际升级过程中,maxSurge允许最多3个Pod存在(向上取整,21.25=2.5,取整为3),而maxUnavailable则不允许有Pod Unavailable(向上取整,20.75=1.5,取整为2),也就是说在升级过程中,一直会有2个Pod处于运行状态,每次新建一个Pod,等这个Pod创建成功后再删掉一个旧Pod,直至Pod全部为新Pod。

    回滚

    回滚也称为回退,即当发现升级出现问题时,让应用回到老的版本。Deployment可以非常方便的回滚到老版本。
    例如上面升级的新版镜像有问题,可以执行kubectl rollout undo命令进行回滚。

    $ kubectl rollout undo deployment nginx
    deployment.apps/nginx rolled back
    

    Deployment之所以能如此容易的做到回滚,是因为Deployment是通过ReplicaSet控制Pod的,升级后之前ReplicaSet都一直存在,Deployment回滚做的就是使用之前的ReplicaSet再次把Pod创建出来。Deployment中保存ReplicaSet的数量可以使用revisionHistoryLimit参数限制,默认值为10。

    了解更多Kubernetes集群相关知识和使用方法请猛击这里

    展开全文
  • Deployment status

    2020-12-09 00:32:41
    <div><p>I updated the list of available statuses for deployment <p>Waiting - for a new deployment Completed - for when the deployment is ready and running Failed - for when the deployment has dailed ...
  • <p>Note: A Deployment’s rollout is triggered if and only if the Deployment’s Pod template (that is, .spec.template) is changed, for example if the labels or container images of the template are ...
  • Deployment Delete

    2020-11-22 18:42:37
    <div><p>After looking at the <a href="https://kubernetes.io/docs/api-reference/v1.5/#delete-24">k8s docs on <code>deployment delete</code></a>, it seems like passing <code>orphanDependents: false...
  • rtt deployment

    2020-08-28 22:14:07
    rtt deployment

    rtt deployment

    展开全文
  • 部署Deployment

    2020-12-10 15:50:42
    部署Deployment 1.编写yaml文件 apiVersion: apps/v1 kind: Deployment metadata: name: dev-nginx-deployment spec: replicas: 3 selector: matchLabels: app: dev-nginx-deployment template: metadata: ...

    部署Deployment

    1.编写yaml文件

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: dev-nginx-deployment
    spec:
      replicas: 3
      selector:
        matchLabels:
    	  app: dev-nginx-deployment
      template:
        metadata: 
    	  labels:
    	    app: dev-nginx-deployment
    	spec:
          containers:
          - name: nginx
            image: nginx:1.19.5
    

    2.应用yaml文件

    kubectl apply -f dev-nginx.yml
    

    3.查看deployment

    kubectl get deployment
    

    4.deployment扩缩容

    kubectl scale --replicas=0 deployment/dev-nginx-deployment
    

    5.创建Service

    apiVersion: v1
    kind: Service
    metadata:
      name: nginx-svc
    spec:
      selector:
        app: dev-nginx-deployment
      ports:
      - protocol: TCP
        port: 8080
        targetPort: 80 
    

    注意事项(同部署单个pod)

    1.查看pod部署详细信息

    kubectl describe pod dev-nginx
    

    2.查看pod部署简要信息

    kubectl get pod -o wide
    

    3.复制网络配置
    如果run/flannel下没有subnet.env文件则需要从master复制该配置文件

    scp -r subnet.env 192.168.221.129:/run/flannel/
    

    4.手动下载镜像并打标

    docker pull ggangelo/pause:3.2
    docker pull ggangelo/kube-proxy:v1.19.4
    docker tag ggangelo/pause:3.2 k8s.gcr.io/pause:3.2
    docker tag ggangelo/kube-proxy:v1.19.4 k8s.gcr.io/kube-proxy:v1.19.4
    
    展开全文
  • microservices deployment cookbook.
  • kubernets deployment

    2021-01-06 16:19:32
    [root@dock01 ~]# cat nginx-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: nginx replicas: 2 template: metadata: labels:...

    [root@dock01 ~]# cat nginx-deployment.yaml 
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      selector:
        matchLabels:
          app: nginx
      replicas: 2
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.8
            ports:
            - containerPort: 80
            volumeMounts:
            - mountPath: "/usr/share/nginx/html"
              name: nginx-vol
          volumes:
          - name: nginx-vol
            hostPath:           
             path:  "/var/data"
    [root@dock01 ~]# kubectl get pods -l app=nginx
    NAME                                READY   STATUS    RESTARTS   AGE
    nginx-deployment-66db4f9b59-479w6   1/1     Running   6          11d
    nginx-deployment-66db4f9b59-7wzh6   1/1     Running   6          10d

    展开全文
  • kubernetes Deployment介绍

    2020-11-05 11:19:20
    一、deployment Deployment在继承Pod和Replicaset的所有特性的同时, 它可以实现对template模板进行实时滚动更新并具备我们线上的Application life circle的特性. 二、操作命令 1. 创建deployment vi ...
  • Kubernetes Deployment

    2021-01-03 12:22:34
    Kubernetes Deployment滚动发布蓝绿发布K8S Deployment原理Deployment发布规范样例v1.0.0v1.0.1查看发布历史快速回滚回滚指定版本 滚动发布 滚动发布 Rolling Update: 高级发布策略,按批次一次替换老版本,逐步升级...
  • Deployment Assembly

    2017-01-05 14:58:57
    Deployment Assembly
  • ClickOnce deployment

    2021-01-05 15:31:53
    <div><p>It would be amazing to showcase an example that was a ClickOnce deployment. <p>Kusto Explorer is an application that uses ClickOnce deployment: ...<p>ClickOnce security and deployment ...
  • APP_Deployment-源码

    2021-02-11 06:28:11
    APP_Deployment
  • Reload deployment state

    2020-12-08 21:20:09
    <div><p>These group of commits implements reconciling deployment changes in cases of both known(cached) deployment and unknown deployment.</p><p>该提问来源于开源项目:intel/pmem-csi</p></div>
  • Deployment descriptor

    2019-03-13 22:58:52
    A deployment descriptor (DD) refers to a configuration file for an artifact that is deployed to some container/engine. In the Java Platform, Enterprise Edition, a deployment descriptor describes how a...
  • bosh delete-deployment -n -d this-deployment-doesnt-exist Using environment 'https://192.168.11.2:25555' as client 'admin' Using deployment 'this-deployment-doesnt-exist' ...
  • deployment assembly

    2015-10-30 17:08:26
    deployment assembly
  • 2. Run <code>azure group deploy create -f template.json -e parameters resource-group-name deployment-name</code></p> (I have added development modules from another project to reproduce the problem) ...
  • <div><p>This is the go cli output when you try to delete a missing deployment: <pre><code> Using deployment 'dummy-classic' Continue? [yN]: y Succeeded </code></pre> <p>This is the ruby cli...
  • deployment详解

    2020-03-01 16:39:11
    deployment 管理部署发布的控制器 1.定义了一组pod的期望数量 controller会维持pod数量与期望数量一直 2.配置pod发布方式,controller会按照给定策略更新pod,保证更新过程不可用的pod在范围内 3.支持一件回滚 用例...
  • concourse-bosh-deployment A toolchain for deploying Concourse with BOSH. This repository is a community-maintained set of manifests and ops files useful for deploying Concourse in various ...
  • Deployment 的回滚

    2021-02-17 16:36:01
    有时我们需要将Deployment 回滚到旧版本。默认情况下,所有Deployment的发布历史记录都保留在系统中,以便我们随时进行回滚 例如我们在升级过程中将镜像名称误设置成Nginx:1.91(一个不存在的镜像) $ kubectl set ...
  • In this article, the author talkes about no-touch deploymentand ClickOnce deployment in its ClickOnce topic. Basically, ClickOnce deployment introducedby Whidbeyis an updated version of no-touch de...
  • k8s的deployment应用 Kubernetes 通过各种 Controller 来管理 Pod 的生命周期。为了满足不同业务场景,Kubernetes 开发了 Deployment、ReplicaSet、DaemonSet、StatefuleSet、Job 等多种 Controller。我们首先学习最...
  • 这个问题当时感觉也不是没有思路,当时也有点着急,后来百度了一下,就感觉被他们带到沟沟里边去了,只想着自己打的war有问题,就没有想起来看tomcat日志...Error during artifact deployment. See server log for...
  • <p>Given a deployment key, how can I get the deployment channel/branch name? <h3>Additional Information <p>We use code push in our app and want to be able to display the deployment channel name. Our ...
  • <p>I expect the deployment group to be created/updated with the <code>deployment_style</code> option. <h3>Actual Behavior <p>Terraform exits with the error: <code>invalid or unknown key: deployment_...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 70,429
精华内容 28,171
关键字:

deployment