环境:kubernet1.17
1、容器按照持续运行的时间可分为两类:服务类容器server和工作类容器job。服务类容器通常持续提供服务,需要一直运行,比如 http server,daemon 等。工作类容器则是一次性任务,比如批处理程序,完成后容器就退出。
[root@master1 ~]# kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 64d mysql ClusterIP 10.108.4.142 <none> 3306/TCP 60d nacos-headless NodePort 10.107.129.42 <none> 8848:32000/TCP 60d [root@master1 ~]# kubectl get pod NAME READY STATUS RESTARTS AGE mysql-2h86g 1/1 Running 2 60d nacos-0 1/1 Running 1 60d nacos-1 1/1 Running 1 60d nacos-2 1/1 Running 1 60d nfs-client-provisioner-6f6478c949-s4pjs 1/1 Running 2 63d redis-tribe 1/1 Running 0 18h [root@master1 ~]# kubectl get job --all-namespaces NAMESPACE NAME COMPLETIONS DURATION AGE istio-system istio-init-crd-10-1.3.3 1/1 10s 63d istio-system istio-init-crd-11-1.3.3 1/1 9s 63d istio-system istio-init-crd-12-1.3.3 1/1 9s 63d
2、对于 Kubernetes 里个各种 Controller 来说:
Deployment、ReplicaSet 和 DaemonSet 都用于管理服务类容器。
[root@master1 ~]# kubectl get deployments.apps -n istio-system NAME READY UP-TO-DATE AVAILABLE AGE istio-citadel 1/1 1 1 63d istio-galley 1/1 1 1 63d [root@master1 ~]# kubectl get DaemonSet --all-namespaces NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE kube-system calico-node 15 15 15 15 15 beta.kubernetes.io/os=linux 64d kube-system kube-proxy 15 15 15 15 15 beta.kubernetes.io/os=linux 64d [root@master1 ~]# kubectl get ReplicaSet --all-namespaces NAMESPACE NAME DESIRED CURRENT READY AGE chinapopin-prod datasource-aytzgf-56db5fbc94 0 0 0 13d chinapopin-prod datasource-aytzgf-57f6bb858c 0 0 0 35d chinapopin-prod datasource-aytzgf-5f766997dc 0 0 0 24d
3、Job、CronJon 则用于管理工作类容器。
[root@master1 ~]# kubectl get cronjobs.batch --all-namespaces NAMESPACE NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE kubesphere-logging-system elasticsearch-logging-curator-elasticsearch-curator 0 1 * * * False 0 15h 63d [root@master1 ~]# kubectl get jobs.batch --all-namespaces NAMESPACE NAME COMPLETIONS DURATION AGE istio-system istio-init-crd-10-1.3.3 1/1 10s 63d istio-system istio-init-crd-11-1.3.3 1/1 9s 63d istio-system istio-init-crd-12-1.3.3 1/1 9s 63d