示例配置文件:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

查询部署状态:

[root@node-1 k8s]# kubectl describe deployments.apps 
Name:                   nginx
Namespace:              default
CreationTimestamp:      Tue, 21 Jan 2020 16:29:41 +0800
Labels:                 app=nginx
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=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:  app=nginx
  Containers:
   nginx:
    Image:        nginx:1.7.9
    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-54f57cf6bf (3/3 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  14m   deployment-controller  Scaled up replica set nginx-54f57cf6bf to 3

查看pod状态:

[root@node-1 k8s]# kubectl get pod
NAME                     READY   STATUS    RESTARTS   AGE
nginx-54f57cf6bf-2t2qd   1/1     Running   0          16m
nginx-54f57cf6bf-smwfh   1/1     Running   0          16m
nginx-54f57cf6bf-wztl4   1/1     Running   0          16m

查看部署位置:

[root@node-1 k8s]# kubectl get pod -o wide
NAME                     READY   STATUS    RESTARTS   AGE   IP             NODE     NOMINATED NODE   READINESS GATES
nginx-54f57cf6bf-2t2qd   1/1     Running   0          16m   192.168.1.23   node-2   <none>           <none>
nginx-54f57cf6bf-smwfh   1/1     Running   0          16m   192.168.1.21   node-2   <none>           <none>
nginx-54f57cf6bf-wztl4   1/1     Running   0          16m   192.168.1.22   node-2   <none>           <none>
Logo

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

更多推荐