zoukankan      html  css  js  c++  java
  • 16.Kubernetes之Deployment

    Deployment在继承Pod和Replicaset的所有特性的同时, 它可以实现对template模板进行实时滚动更新并具备我们线上的Application life circle的特性。

    1.创建Deployment

    # vi deployment.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: httpd-deployment
      labels:
        app: httpd-deployment
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: httpd-demo
      template:
        metadata:
          labels:
            app: httpd-demo
        spec:
          containers:
          - name: httpd
            image: httpd
            imagePullPolicy: Always
            ports:
            - containerPort: 80
            env:
            - name: VERSION
              value: "v1"
    # kubectl create -f deployment.yaml
    

    2.查看Deployment

    # kubectl get deployment
    NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
    httpd-deployment   2         2         2            2           8d
    # kubectl get pods -o wide
    NAME                               READY     STATUS    RESTARTS   AGE       IP            NODE
    httpd-deployment-956697567-8mqch   1/1       Running   0          8d        10.244.0.36   kube-master
    httpd-deployment-956697567-wcbs6   1/1       Running   0          8d        10.244.0.37   kube-master
    # kubectl describe deployment
    ...
    

    3.更新deployment

    通过此命令可以呼出vi编辑器对模板进行编辑.

    # kubectl edit -f deployment.yaml
    

    通过此命令使当前编辑结果生效.

    # kubectl apply -f deployment.yaml
    

    再次查看可以看到老版本的deployment已经下架, 新版本的已经生效.

    # kubectl get deployment
    NAME                          DESIRED   CURRENT   READY     AGE
    httpd-deployment-6b98d94474   0         0         0         1m
    httpd-deployment-956697567    2         2         2         7m
    

    4.扩容与缩容

    可以修改replicas的赋值对deployment进行扩容与缩容

    #  kubectl scale deployment/httpd-deployment --replicas=1
    

    5.删除deployment

    # kubectl delete deployment httpd-deployment


    链接:https://www.orchome.com/1259
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
     
  • 相关阅读:
    Iso-seq 必备基础
    html 段落
    html 标题
    html 简介
    motiMaker 软件安装测试
    ggplot2 提取stat计算出来的数据
    R包 randomForest 进行随机森林分析
    AJAX应用【股票案例、验证码校验】
    Servlet第二篇【Servlet调用图、Servlet细节、ServletConfig、ServletContext】
    Servlet第一篇【介绍Servlet、HTTP协议、WEB目录结构、编写入门Servlet程序、Servlet生命周期】
  • 原文地址:https://www.cnblogs.com/linux20190409/p/10976293.html
Copyright © 2011-2022 走看看