describe¶
Show details of a specific resource or group of resources
创建一个deployment和service¶
[root@k8s1 ~]# kubectl run nginx-deploy --image=nginx:1.14-alpine --port=80 --replicas=2 -n poppy
deployment.apps/nginx-deploy created
[root@k8s1 ~]# kubectl expose deployment nginx-deploy --name=nginx --port=8000 --target-port=80 --protocol=TCP -n poppy
service/nginx exposed
[root@k8s1 ~]# kubectl get svc,deploy,po -n poppy
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nginx ClusterIP 10.103.107.199 <none> 8000/TCP 33s
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deployment.extensions/nginx-deploy 2 2 2 2 46s
NAME READY STATUS RESTARTS AGE
pod/nginx-deploy-5b595999-g8txz 1/1 Running 0 46s
pod/nginx-deploy-5b595999-tmpsp 1/1 Running 0 46s
查看service的描述信息¶
[root@k8s1 ~]# kubectl describe service nginx -n poppy
Name: nginx
Namespace: poppy
Labels: run=nginx-deploy
Annotations: <none>
Selector: run=nginx-deploy
Type: ClusterIP
IP: 10.103.107.199
Port: <unset> 8000/TCP
TargetPort: 80/TCP
Endpoints: 10.244.1.13:80,10.244.2.12:80
Session Affinity: None
Events: <none>
查看deploy的描述信息¶
[root@k8s1 ~]# kubectl describe deploy nginx-deploy -n poppy
Name: nginx-deploy
Namespace: poppy
CreationTimestamp: Tue, 28 Aug 2018 13:23:02 +0800
Labels: run=nginx-deploy
Annotations: deployment.kubernetes.io/revision=1
Selector: run=nginx-deploy
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: run=nginx-deploy
Containers:
nginx-deploy:
Image: nginx:1.14-alpine
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-deploy-5b595999 (2/2 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 7m deployment-controller Scaled up replica set nginx-deploy-5b595999 to 2
查看pod的描述信息¶
[root@k8s1 ~]# kubectl describe pod nginx-deploy-5b595999-g8txz -n poppy
Name: nginx-deploy-5b595999-g8txz
Namespace: poppy
Priority: 0
PriorityClassName: <none>
Node: k8s2.shenmin.com/192.168.1.52
Start Time: Tue, 28 Aug 2018 13:23:02 +0800
Labels: pod-template-hash=16151555
run=nginx-deploy
Annotations: <none>
Status: Running
IP: 10.244.1.13
Controlled By: ReplicaSet/nginx-deploy-5b595999
Containers:
nginx-deploy:
Container ID: docker://ce781f2c9c844b540540258248b63e387ec2c8d005416ee86487882522a5da86
Image: nginx:1.14-alpine
Image ID: docker-pullable://nginx@sha256:3d36a2c9513a5aa6aa6c41b076201d468bdb94c4f2b4c6e55d32a461ac8f00ee
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Tue, 28 Aug 2018 13:23:02 +0800
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-nnvxp (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-nnvxp:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-nnvxp
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 9m default-scheduler Successfully assigned poppy/nginx-deploy-5b595999-g8txz to k8s2.shenmin.com
Normal Pulled 9m kubelet, k8s2.shenmin.com Container image "nginx:1.14-alpine" already present on machine
Normal Created 9m kubelet, k8s2.shenmin.com Created container
Normal Started 9m kubelet, k8s2.shenmin.com Started container