1.项目的生命周期概述

项目的生命周期:创建、发布、更新、回滚、删除

1.1创建

kubectl run命令

kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas]
[--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...] [options]

示例:

[root@master01 ~]# kubectl get all  #查看集群为空
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.0.0.1     <none>        443/TCP   45h
[root@master01 ~]# kubectl run nginx-deployment --image=nginx --port=80 --replicas=3 #创建名称为nginx-deployment,nginx镜像,端口为80端口,副本集为3的pod集群
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx-deployment created
[root@master01 ~]# kubectl get pods   #查看pod
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-5477945587-qgk8z   1/1     Running   0          64s
nginx-deployment-5477945587-vc858   1/1     Running   0          64s
nginx-deployment-5477945587-w6cln   1/1     Running   0          64s
[root@master01 ~]# kubectl get all   #查看所有组件
NAME                                    READY   STATUS    RESTARTS   AGE
pod/nginx-deployment-5477945587-qgk8z   1/1     Running   0          115s
pod/nginx-deployment-5477945587-vc858   1/1     Running   0          115s
pod/nginx-deployment-5477945587-w6cln   1/1     Running   0          115s

NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.0.0.1     <none>        443/TCP   45h

NAME                               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx-deployment   3         3         3            3           114s

NAME                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-deployment-5477945587   3         3         3       115s

1.2 删除

[root@master01 ~]# kubectl delete deploy/nginx-deployment
deployment.extensions "nginx-deployment" deleted
[root@master01 ~]# kubectl get pods
No resources found.

1.kubectl命令管理项目的生命周期

项目的生命周期:创建、发布、更新、回滚、删除

1.1 创建

kubectl run命令
kubectl run NAME --image=image [–env=“key=value”] [–port=port] [–replicas=replicas]
[–dry-run=bool] [–overrides=inline-json] [–command] – [COMMAND] [args…] [options]

[root@master01 ~]# kubectl run nginx --image=nginx:latest --port=80 --replicas=3  #创建名字为nginx镜像nginx 端口为80 副本集为3
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx created

[root@master01 ~]# kubectl get pods -w
NAME                     READY   STATUS              RESTARTS   AGE
nginx-7697996758-cxpgr   0/1     ContainerCreating   0          3s
nginx-7697996758-jqzt9   0/1     ContainerCreating   0          3s
nginx-7697996758-krwtb   0/1     ContainerCreating   0          3s
nginx-7697996758-krwtb   1/1   Running   0     8s
nginx-7697996758-cxpgr   1/1   Running   0     17s
nginx-7697996758-jqzt9   1/1   Running   0     25s
####
[root@master01 ~]#  kubectl get pods,deployment,replicaset   #查看三个组件
NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-7697996758-cxpgr   1/1     Running   0          81s
pod/nginx-7697996758-jqzt9   1/1     Running   0          81s
pod/nginx-7697996758-krwtb   1/1     Running   0          81s

NAME                          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.extensions/nginx   3         3         3            3           84s

NAME                                     DESIRED   CURRENT   READY   AGE
replicaset.extensions/nginx-7697996758   3         3         3       81s

使用dashboard查看
在这里插入图片描述

1.2 发布

1.2.1 发布nginx service提供负载均衡的功能

kubectl expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP|SCTP]
[--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]
[options]
[root@master01 ~]# kubectl expose deployment nginx --port=80 --target-port=80 --name=nginx-service --type=NodePort
service/nginx-service exposed
[root@master01 ~]#  kubectl get pods,svc   #查看pod和service
NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-7697996758-cxpgr   1/1     Running   0          3m2s
pod/nginx-7697996758-jqzt9   1/1     Running   0          3m2s
pod/nginx-7697996758-krwtb   1/1     Running   0          3m2s

NAME                    TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
service/kubernetes      ClusterIP   10.0.0.1     <none>        443/TCP        4d6h
service/nginx-service   NodePort    10.0.0.38    <none>        80:31154/TCP   29s

在这里插入图片描述

[root@master01 ~]# kubectl get svc   #查看服务
NAME            TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
kubernetes      ClusterIP   10.0.0.1     <none>        443/TCP        4d6h
nginx-service   NodePort    10.0.0.38    <none>        80:31154/TCP   98s #port和NodePort映射关系
[root@master01 ~]# kubectl get pod -o wide
NAME                     READY   STATUS    RESTARTS   AGE     IP            NODE              NOMINATED NODE
nginx-7697996758-cxpgr   1/1     Running   0          4m30s   172.17.25.2   192.168.200.110   <none>
nginx-7697996758-jqzt9   1/1     Running   0          4m30s   172.17.4.3    192.168.200.120   <none>
nginx-7697996758-krwtb   1/1     Running   0          4m30s   172.17.25.3   192.168.200.110   <none>
[root@master01 ~]# kubectl get endpoints    //查看关联后端的节点
NAME            ENDPOINTS                                     AGE
kubernetes      192.168.200.100:6443,192.168.200.90:6443      4d6h
nginx-service   172.17.25.2:80,172.17.25.3:80,172.17.4.3:80   2m15s

1.2.2 在node操作,查看负载均衡端口31154

kubernetes里kube-proxy支持三种模式,在v1.8之前我们使用的是iptables 以及 userspace两种模式,在kubernetes 1.8之后引入了ipvs模式
在node01操作,查看负载均衡端口32875

[root@node01 ~]#  yum install ipvsadm -y
[root@node01 ~]# ipvsadm -L -n   
TCP  192.168.200.110:31154 rr   #负载均衡 轮询
  -> 172.17.4.3:80                Masq    1      0          0         
  -> 172.17.25.2:80               Masq    1      0          0         
  -> 172.17.25.3:80               Masq    1      0          0           

在node02操作 同样安装ipvsadmin工具查看

[root@node02 ~]#  yum install ipvsadm -y
[root@node02 ~]# ipvsadm -L -n
TCP  192.168.200.120:31154 rr
  -> 172.17.4.3:80                Masq    1      0          0         
  -> 172.17.25.2:80               Masq    1      0          0         
  -> 172.17.25.3:80               Masq    1      0          0            

1.2.3 打开浏览器,访问对应的node节点ip和端口在这里插入图片描述

在这里插入图片描述

1.2.4 查看pod日志

[root@master01 ~]# kubectl logs nginx-7697996758-cxpgr   # 查看pod1日志
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
172.17.25.1 - - [12/Oct/2020:00:55:30 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
172.17.25.1 - - [12/Oct/2020:00:55:30 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
172.17.25.1 - - [12/Oct/2020:00:55:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
172.17.25.1 - - [12/Oct/2020:00:55:31 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
[root@master01 ~]# kubectl logs nginx-7697996758-krwtb   #查看pod2日志
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
172.17.25.1 - - [12/Oct/2020:00:49:51 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
172.17.25.1 - - [12/Oct/2020:00:49:51 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://192.168.200.110:31154/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
2020/10/12 00:49:51 [error] 28#28: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.25.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.200.110:31154", referrer: "http://192.168.200.110:31154/"
172.17.25.1 - - [12/Oct/2020:00:50:43 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
172.17.25.1 - - [12/Oct/2020:00:50:43 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
[root@master01 ~]# kubectl logs nginx-7697996758-jqzt9   #查看pod3节点
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
172.17.4.1 - - [12/Oct/2020:00:49:11 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
2020/10/12 00:49:12 [error] 28#28: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.4.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.200.120:31154", referrer: "http://192.168.200.120:31154/"
172.17.4.1 - - [12/Oct/2020:00:49:12 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://192.168.200.120:31154/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
172.17.4.1 - - [12/Oct/2020:00:50:48 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"
172.17.4.1 - - [12/Oct/2020:00:50:48 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36" "-"

1.3 更新nginx 为1.14版本

谷歌浏览器重新加载刷新页面查看nginx版本信息
在这里插入图片描述

kubectl set 用法

[root@master01 ~]# kubectl set --help
Available Commands:
  env            Update environment variables on a pod template
  image          更新一个 pod template 的镜像
  resources      在对象的 pod templates 上更新资源的 requests/limits
  selector       设置 resource 的 selector
  serviceaccount Update ServiceAccount of a resource
  subject        Update User, Group or ServiceAccount in a
RoleBinding/ClusterRoleBinding
Usage:
  kubectl set SUBCOMMAND [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all
commands).

获取修改模板

[root@localhost bin]# kubectl set image --help
Examples:
  # Set a deployment's nginx container image to 'nginx:1.9.1', and its busybox
container image to 'busybox'.
  kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1
[root@master01 ~]# kubectl set image deployment/nginx nginx=nginx:1.14   更新nginx 为1.14版本
deployment.extensions/nginx image updated
[root@master01 ~]#  kubectl get pods -w   #处于动态监听状态
NAME                     READY   STATUS              RESTARTS   AGE
nginx-6ff7c89c7c-jv87m   0/1     ContainerCreating   0          3s
nginx-6ff7c89c7c-slst4   1/1     Running             0          6s
nginx-7697996758-cxpgr   1/1     Running             0          16m
nginx-7697996758-krwtb   1/1     Running             0          16m
nginx-6ff7c89c7c-jv87m   1/1   Running   0     3s
nginx-7697996758-cxpgr   1/1   Terminating   0     16m
nginx-6ff7c89c7c-76shn   0/1   Pending   0     <invalid>
nginx-6ff7c89c7c-76shn   0/1   Pending   0     <invalid>
nginx-6ff7c89c7c-76shn   0/1   ContainerCreating   0     0s
nginx-7697996758-cxpgr   0/1   Terminating   0     16m
nginx-7697996758-cxpgr   0/1   Terminating   0     16m
nginx-6ff7c89c7c-76shn   1/1   Running   0     0s
nginx-7697996758-krwtb   1/1   Terminating   0     16m
nginx-7697996758-krwtb   0/1   Terminating   0     16m
nginx-7697996758-cxpgr   0/1   Terminating   0     16m
nginx-7697996758-cxpgr   0/1   Terminating   0     16m
nginx-7697996758-krwtb   0/1   Terminating   0     16m
nginx-7697996758-krwtb   0/1   Terminating   0     16m
[root@master01 ~]# kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
nginx-6ff7c89c7c-76shn   1/1     Running   0          76s
nginx-6ff7c89c7c-jv87m   1/1     Running   0          82s
nginx-6ff7c89c7c-slst4   1/1     Running   0          85s

更新成功
在这里插入图片描述

1.4 回滚nginx

[root@master01 ~]#  kubectl rollout --help
Manage the rollout of a resource.
  
Valid resource types include: 

  * deployments  
  * daemonsets  
  * statefulsets

Examples:
  # Rollback to the previous deployment
  kubectl rollout undo deployment/abc
  
  # Check the rollout status of a daemonset
  kubectl rollout status daemonset/foo

Available Commands:
  history     显示 rollout 历史
  pause       标记提供的 resource 为中止状态
  resume      继续一个停止的 resource
  status      显示 rollout 的状态
  undo        撤销上一次的 rollout

Usage:
  kubectl rollout SUBCOMMAND [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all
commands).
//查看历史版本
[root@master01 ~]# kubectl rollout history deployment/nginx 
deployment.extensions/nginx 
REVISION  CHANGE-CAUSE
1         <none>
2         <none>
//执行回滚
[root@master01 ~]# kubectl rollout undo deployment/nginx     #回滚
deployment.extensions/nginx
[root@master01 ~]# kubectl get pods -w
NAME                     READY   STATUS              RESTARTS   AGE
nginx-6ff7c89c7c-76shn   1/1     Terminating         0          4m6s
nginx-6ff7c89c7c-jv87m   1/1     Running             0          4m12s
nginx-6ff7c89c7c-slst4   1/1     Running             0          4m15s
nginx-7697996758-x4rzc   0/1     ContainerCreating   0          <invalid>
nginx-7697996758-xphcm   1/1     Running             0          3s
nginx-6ff7c89c7c-76shn   0/1   Terminating   0     4m7s
nginx-7697996758-x4rzc   1/1   Running   0     0s
nginx-6ff7c89c7c-jv87m   1/1   Terminating   0     4m15s
nginx-7697996758-jnzgg   0/1   Pending   0     <invalid>
nginx-7697996758-jnzgg   0/1   Pending   0     <invalid>
nginx-7697996758-jnzgg   0/1   ContainerCreating   0     <invalid>
nginx-6ff7c89c7c-jv87m   0/1   Terminating   0     4m16s
nginx-7697996758-jnzgg   1/1   Running   0     1s
nginx-6ff7c89c7c-slst4   1/1   Terminating   0     4m22s
nginx-6ff7c89c7c-slst4   0/1   Terminating   0     4m23s
nginx-6ff7c89c7c-76shn   0/1   Terminating   0     4m14s
nginx-6ff7c89c7c-76shn   0/1   Terminating   0     4m14s
nginx-6ff7c89c7c-jv87m   0/1   Terminating   0     4m25s
nginx-6ff7c89c7c-jv87m   0/1   Terminating   0     4m25s
nginx-6ff7c89c7c-slst4   0/1   Terminating   0     4m28s
nginx-6ff7c89c7c-slst4   0/1   Terminating   0     4m28s
//检查回滚状态
[root@master01 ~]#  kubectl rollout status deployment/nginx
deployment "nginx" successfully rolled out

在这里插入图片描述

[root@master01 ~]# kubectl rollout history deployment/nginx 
deployment.extensions/nginx 
REVISION  CHANGE-CAUSE
2         <none>
3         <none>

1.5 删除nginx

[root@master01 ~]# kubectl get deploy  # 查看deployment
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx   3         3         3            3           23m
[root@master01 ~]# kubectl delete deployment/nginx  # 删除deployment
deployment.extensions "nginx" deleted
[root@master01 ~]# kubectl get svc
NAME            TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
kubernetes      ClusterIP   10.0.0.1     <none>        443/TCP        4d6h
nginx-service   NodePort    10.0.0.38    <none>        80:31154/TCP   21m
[root@master01 ~]# kubectl delete svc/nginx-service
service "nginx-service" deleted
[root@master01 ~]# kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.0.0.1     <none>        443/TCP   4d6h

1.6 查看具体资源的详细信息

[root@master01 ~]#  kubectl run nginx --image=nginx:latest --port=80 --replicas=3
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/nginx created
[root@master01 ~]# kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
nginx-7697996758-pn5lr   1/1     Running   0          119s
nginx-7697996758-qpd4j   1/1     Running   0          119s
nginx-7697996758-v9xzc   1/1     Running   0          119s
[root@master01 ~]# kubectl describe pod nginx-7697996758-pn5lr   #查看pod详细信息
Name:               nginx-7697996758-pn5lr
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               192.168.200.120/192.168.200.120
Start Time:         Mon, 12 Oct 2020 09:08:04 +0800
Labels:             pod-template-hash=7697996758
                    run=nginx
Annotations:        <none>
Status:             Running
IP:                 172.17.4.4
Controlled By:      ReplicaSet/nginx-7697996758
Containers:
  nginx:
    Container ID:   docker://e92ad98ad615ba1248ae426c9923c43ea44ad88fafe891af0d238e7a7184362a
    Image:          nginx:latest
    Image ID:       docker-pullable://nginx@sha256:fc66cdef5ca33809823182c9c5d72ea86fd2cef7713cf3363e1a0b12a5d77500
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 12 Oct 2020 09:08:13 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-r77nm (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-r77nm:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-r77nm
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age    From                      Message
  ----    ------     ----   ----                      -------
  Normal  Scheduled  3m1s   default-scheduler         Successfully assigned default/nginx-7697996758-pn5lr to 192.168.200.120
  Normal  Pulling    3m     kubelet, 192.168.200.120  pulling image "nginx:latest"
  Normal  Pulled     2m52s  kubelet, 192.168.200.120  Successfully pulled image "nginx:latest"
  Normal  Created    2m52s  kubelet, 192.168.200.120  Created container
  Normal  Started    2m52s  kubelet, 192.168.200.120  Started container
[root@master01 ~]# kubectl describe deployment/nginx  #查看deployment资源 
Name:                   nginx
Namespace:              default
CreationTimestamp:      Mon, 12 Oct 2020 09:08:01 +0800
Labels:                 run=nginx
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               run=nginx
Replicas:               3 desired | 3 updated | 3 total | 3 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  run=nginx
  Containers:
   nginx:
    Image:        nginx:latest
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   nginx-7697996758 (3/3 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  4m3s  deployment-controller  Scaled up replica set nginx-7697996758 to 3
[root@master01 ~]#  kubectl exec -it nginx-7697996758-pn5lr bash     # 进入pod
root@nginx-7697996758-pn5lr:/# ls
bin   dev		   docker-entrypoint.sh  home  lib64  mnt  proc  run   srv  tmp  var
boot  docker-entrypoint.d  etc			 lib   media  opt  root  sbin  sys  usr    
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐