Controller-manager:
Kube-controller-manager
Cloud-controller-manager: Enable CloudProvider in K8S when it needs for engagement control (NodeController, RouteController, ServiceController) cloud service provider
A, Pod Controller
ReplicationController:
ReplicaSet : is a new generation of ReplicationController. Stateless help users manage resources and ensure an accurate reflection of the number of user-defined target.
Core components: the user's desired number of copies, tag selector, pod resource templates
Deployment : build on ReplicaSet. Support scalable capacity to support the rollover, rollback, etc., to provide declarative definition of resources. It is the best controller currently manages stateless applications.
DaemonSet : to ensure that each node in the cluster to run only one copy of a particular Pod, or only on nodes that satisfy the condition, run a Pod copy. Typically used to implement system-level background tasks (in the form of a daemon running), hosted on K8S,. Without defining the desired number of pod, as the number of copies depending on cluster size.
The Job : Pod depends on whether the reconstruction task is complete. You can only perform a single task.
CronJob : run the task.
StatefulSet : Management stateful applications. The need to manually do the operation and maintenance procedures packaged into a script, on the pod template, allowing a controller to do according to script. --- stateful application hosting to K8S difficult, because there are state application, can not extract common characteristics, and to define a model, each application can only be treated separately.
Two, ReplicaSet
[kubelet @ Master YAML] $ CAT RS- demo.yaml [kubelet Master @ ~] $ kubectl PODS --show-GET Labels
[kubelet @ Master YAML] $ kubectl Edit line ## RS MyApp modified yaml, dynamic expansion volume reduction ( change replicas); dynamic update (change of image container versions), the existing version of the pod does not change, only the reconstruction will be a new version.
Three, Deployment
A deployment to manage multiple ReplicaSet. Only one is active. It can provide a declarative update created. Usually apply, instead of using the create. Customization provides rolling control update; may be implemented to control and update logic updates the rhythm, the update size.
[kubelet @ master yaml] $ kubectl explain deployment.spec.strategy # update policy
[kubelet @ master yaml] $ kubectl explain deployment.spec.revisionHistoryLimit # history version number
[kubelet @ Master yaml] $ vim deploy- demo.yaml # yaml directly modify file Replicas
[kubelet @ Master yaml] $ kubectl the Apply -f Deploy-# demo.yaml the Apply again to obtain the following results.
[kubelet@master yaml]$ kubectl rollout history deployment myapp-deploy # 查看滚动更新的历史 [kubelet@master yaml]$ kubectl patch deployment myapp-deploy -p '{"spec":{"replicas":5}}' # 打补丁 [kubelet@master yaml]$ kubectl patch deployment myapp-deploy -p '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":1,"maxUnavailable":0}}}}' #修改更新策略 [kubelet@master yaml]$ kubectl set image deployment myapp-deploy myapp-container=ikubernetes/myapp:v3 && kubectl rollout pause deployment myapp-deploy #更新,然后暂停更新。金丝雀发布 [kubelet@master yaml]$ kubectl rollout resume deployment myapp-deploy # 恢复操作,继续进行更新。 [kubelet@master yaml]$ kubectl rollout status deployment myapp-deploy # 查看更新进度 [kubelet@master yaml]$ kubectl rollout undo deployment myapp-deploy --to-revision=1 #回滚到版本1(不指定默认回滚为上一版本)
查看使用的是v1版本:
[kubelet@master yaml]$ kubectl delete pod myapp-ds-ljlh5 --force --grace-period=0 #强制删除pod,当pod长时间处于Terminating状态时可使用。
四、DaemonSet
也支持滚动更新
kubelet@master yaml]$ kubectl expose deployment redis --port=6379 #暴露端口
[kubelet@master yaml]$ kubectl explain pods.spec.hostNetwork #共享宿主机的网络命名空间,daemonset可以使用,就不需要用service单独暴露端口
日志收集是节点级别的,需要收集所有Pod的日志。
五、Tips
TPR:Third Party Resources 第三方资源 1.2+ 1.7废弃了
CDR:Custom Defined Resources 1.8+ 用户自定义资源
Operator:
Helm:类似于Yum
[kubelet@master yaml]$ kubectl explain deploy # 文档是落后于k8s集群本身的,所以此命令获得的群组可能是不正确的。
[kubelet@master yaml]$ kubectl get pods -l app=myapp –w # 查看pod的动态变化