# 分析node
pod
首先,咱们先从最小的调度单位pod开始。
个人k8s集群中目前有一个pod,它的name为admin-mysql-1d29997-5db458497c-h6rrsmysql
[root@k8s-master ~]# kubectl get pod admin-mysql-1d29997-5db458497c-h6rrs NAME READY STATUS RESTARTS AGE admin-mysql-1d29997-5db458497c-h6rrs 1/1 Running 0 5d23h
查看一下pod的详细内容:sql
[root@k8s-master ~]# kubectl describe pod admin-mysql-1d29997-5db458497c-h6rrs Name: admin-mysql-1d29997-5db458497c-h6rrs Namespace: default Priority: 0 PriorityClassName: <none> Node: k8s-node1/192.168.0.247 Start Time: Fri, 01 Nov 2019 10:57:47 +0800 Labels: name=mysql pod-template-hash=5db458497c Annotations: <none> Status: Running IP: 10.244.1.72 Controlled By: ReplicaSet/admin-mysql-1d29997-5db458497c Containers: mysql57-container: Container ID: docker://7e68cae8d4e9840ed908965252ae7aff8281ca81954ab0b5d58e053f5371bb5d Image: mysql57:5.7 Image ID: docker://sha256:f6509bac49801f48628167728aba66d64533aaa7d384e03b75a8fe4e6c0f6599 Port: 3306/TCP Host Port: 0/TCP State: Running Started: Fri, 01 Nov 2019 10:57:48 +0800 Ready: True Restart Count: 0 Environment: MYSQL_ROOT_PASSWORD: welcome1 Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-9rfpv (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: default-token-9rfpv: Type: Secret (a volume populated by a Secret) SecretName: default-token-9rfpv 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: <none> [root@k8s-master ~]#
在这里能看到吗,pod是被一个名字为admin-mysql-1d29997-5db458497c的ReplicaSet管理的,因此咱们认为,RS是比Pod高一级别的专门用来管理pod的组件。一个RS会管理一批pod。docker
Controlled By: ReplicaSet/admin-mysql-1d29997-5db458497c
ide
ReplicateSet(rs)spa
接下来,咱们就看看这个RS的详细状况code
[root@k8s-master ~]# kubectl describe rs admin-mysql-1d29997-5db458497c Name: admin-mysql-1d29997-5db458497c Namespace: default Selector: name=mysql,pod-template-hash=5db458497c Labels: name=mysql pod-template-hash=5db458497c Annotations: deployment.kubernetes.io/desired-replicas: 1 deployment.kubernetes.io/max-replicas: 2 deployment.kubernetes.io/revision: 1 Controlled By: Deployment/admin-mysql-1d29997 Replicas: 1 current / 1 desired Pods Status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed Pod Template: Labels: name=mysql pod-template-hash=5db458497c Containers: mysql57-container: Image: mysql57:5.7 Port: 3306/TCP Host Port: 0/TCP Environment: MYSQL_ROOT_PASSWORD: welcome1 Mounts: <none> Volumes: <none> Events: <none> [root@k8s-master ~]#
抓住关键信息Controlled By: Deployment/admin-mysql-1d29997
token
这个RS被名字为admin-mysql-1d29997的Deployment控制,这样看,Deployment是比RS高一级别用于管理RS的组件。事件
在RS级别上发生的事件,均是对pod的操做,建立pod,删除podget
Deployment
接下来,咱们来看看Delpoyment
[root@k8s-master ~]# kubectl describe deploy admin-mysql-1d29997 Name: admin-mysql-1d29997 Namespace: default CreationTimestamp: Fri, 01 Nov 2019 10:57:46 +0800 Labels: name=mysql Annotations: deployment.kubernetes.io/revision: 1 Selector: name=mysql Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 25% max unavailable, 25% max surge Pod Template: Labels: name=mysql Containers: mysql57-container: Image: mysql57:5.7 Port: 3306/TCP Host Port: 0/TCP Environment: MYSQL_ROOT_PASSWORD: welcome1 Mounts: <none> Volumes: <none> Conditions: Type Status Reason ---- ------ ------ Available True MinimumReplicasAvailable Progressing True NewReplicaSetAvailable OldReplicaSets: <none> NewReplicaSet: admin-mysql-1d29997-5db458497c (1/1 replicas created) Events: <none> [root@k8s-master ~]#
能够看出,在deployment级别上,再也不受其余组件的控制,而他的状态的转变是做为API被调用而产生的。咱们看到,在deployment级别上发生的事件通常是建立服务、滚动升级一个服务,或者是操做RS伸缩Pod集群。
service最后,到这里也很明白量,service实际上是在这一整套基础之上提供给外部的稳定的服务。