当前位置:网站首页>[cloud native | kubernetes] in depth RC, RS, daemonset, statefulset (VII)
[cloud native | kubernetes] in depth RC, RS, daemonset, statefulset (VII)
2022-06-10 14:32:00 【Lanson】
thorough RC、RS、DaemonSet、StatefulSet
One 、RC、RS
RC (ReplicationController ) The main function is to ensure that the number of copies of the container application is always kept at the user-defined number of copies . That is, if a container exits abnormally , Will automatically create a new Pod To replace ; And if the extra containers are recovered automatically
Kubernetes Official recommended use RS(ReplicaSet ) replace RC (ReplicationController ) Deployment ,RS Follow RC There is no essential difference , It's just that the names are different , also RS Support for aggregate selector
RC controller
apiVersion: v1
kind: ReplicationController
metadata:
name: frontend
spec:
replicas: 3
selector:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: php-redis
image: lansonlinux/myapp:v1
env:
- name: GET_HOSTS_FROM
value: dns
name: zhangsan
value: "123"
ports:
- containerPort: 80RS controller
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
spec:
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: myapp
image: lansonlinux/myapp:v1
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 80Two 、DaemonSet
DaemonSet The controller ensures that all ( Or part of it ) All nodes run a specified Pod copy .
- Whenever a node is added to the cluster , designated Pod A copy will also be added to the node
- When a node is removed from the cluster ,Pod It's recycled
- Delete one DaemonSet You can clean up all the created Pod
DaemonSet The typical usage scenarios are :
- Run the cluster's storage daemon on each node , for example glusterd、ceph
- Run the log collection daemons on each node , for example fluentd、logstash
- Run monitoring daemons on each node , for example Prometheus Node Exporter、Sysdig Agent、collectd、Dynatrace OneAgent、APPDynamics Agent、Datadog agent、New Relic agent、Ganglia gmond、Instana Agent etc.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: logging
labels:
app: logging
spec:
selector:
matchLabels:
name: logging
template:
metadata:
labels:
name: logging
spec:
containers:
- name: logging
image: nginx
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
tolerations: # Set tolerance master The stain of
- key: node-role.kubernetes.io/master
effect: NoScheduleSee the effect
kubectl get pod -l name=logging -o wide3、 ... and 、StatefulSet
Stateful replica set ;Deployment Such as stateless application deployment (stateless)
- StatefulSet Use scenarios ; For applications with the following requirements ,StatefulSet just the thing :
- Stable 、 The only Internet logo (dnsname)
- StatefulSet Through its associated headless service for each pod Provide DNS Parse entry . If there is no head service DNS The entry is : "$(service name).$(namespace).svc.cluster.local", that pod The parsing entry is "$(pod name).$(service name).$(namespace).svc.cluster.local", Every pod name It's the only one .
- The stability of the 、 Persistent storage ;【 Every Pod Always correspond to their respective storage paths (PersistantVolumeClaimTemplate)】
- Orderly 、 Elegant deployment and scaling .【 Add copies in order 、 Reduce copies , And perform cleanup when reducing copies 】
- Orderly 、 Automatic rollover update .【 Rolling updates are performed automatically in sequence 】
- Stable 、 The only Internet logo (dnsname)
- Limit
- Given Pod Must be stored by PersistentVolume The driver is based on the requested
storage classTo provide , Or by the administrator in advance . - Delete or shrink StatefulSet and Can't Delete its associated storage volume . This is to ensure data security , It's usually better than automatically clearing StatefulSet All the related resources are more valuable .
- StatefulSet Currently, headless services are needed to be responsible for Pod Network identity of . You need to be responsible for creating this service .
- When the delete StatefulSets when ,StatefulSet No termination is provided Pod Guarantee . In order to achieve StatefulSet Medium Pod Can be terminated in an orderly and dignified manner , You can delete StatefulSet Zoom in to 0.
- By default Pod Management strategy (
OrderedReady) When using Scroll to update , It is possible to enter a damaged state that requires human intervention to repair .
- Given Pod Must be stored by PersistentVolume The driver is based on the requested
If an application does not need a stable network identity , Or you don't need to deploy in order 、 Delete 、 Add a copy of the , We should consider using Deployment This kind of Statelessness (stateless) The controller
apiVersion: v1 kind: Service # Define a load balancing network metadata: name: stateful-tomcat labels: app: stateful-tomcat spec: ports: - port: 8123 name: web targetPort: 8080 clusterIP: None #NodePort: Any machine +NodePort All have access to ,ClusterIP: This can be used in the cluster ip、service Domain name can access ,clusterIP: None; Do not assign clusters ip.headless; The headless service . Stable domain name selector: app: stateful-tomcat --- apiVersion: apps/v1 kind: StatefulSet # controller . metadata: name: stateful-tomcat spec: selector: matchLabels: app: stateful-tomcat # has to match .spec.template.metadata.labels serviceName: "stateful-tomcat" # Pay attention here , There must be a service The name is this replicas: 3 # by default is 1 template: metadata: labels: app: stateful-tomcat # has to match .spec.selector.matchLabels spec: terminationGracePeriodSeconds: 10 containers: - name: tomcat image: tomcat:7 ports: - containerPort: 8080 name: web # Observe the effect . Delete one , Name after restart ,ip It's all the same . Ensure the State # details kubectl explain StatefulSet.spec podManagementPolicy: OrderedReady( In order )、Parallel( Concurrent ) serviceName -required- Set the service name , You can use the domain name to access pod 了 . pod-specific-string.serviceName.default.svc.cluster.local # test kubectl run -i --tty --image busybox dns-test --restart=Never --rm /bin/sh ping stateful-tomcat-0.stateful-tomcat # We do not add storage volumes here . If any kubectl get pvc -l app=stateful-tomcat We can see that even if Pod Delete it and then pull it up , The volume is the same .
边栏推荐
- 【离散数学期复习系列】四、图
- [Chongqing University] information sharing of preliminary and second examinations (with postgraduate entrance examination group)
- Cell asynchronously invokes method change records
- [original] poi 5 X xssf and HSSF use custom font colors
- 【离散数学期复习系列】一、命题逻辑
- 2022 practice questions and online simulation test for the third batch of Guangdong Provincial Safety Officer a certificate (principal)
- What is CAS and ABA in CAS
- Shutter wrap button bottomnavigationbar learning summary 4
- 2022 practice questions and online simulation test for the third batch of Guangdong Provincial Safety Officer a certificate (principal)
- [big guy show] aiops in the eyes of Borui data, choosing the right track and the right people
猜你喜欢
![[C language] pointer function, function pointer and array function](/img/3c/e8816c4fe52c1757f4f9e17d19c285.png)
[C language] pointer function, function pointer and array function
![[logodetection data set processing] (3) divide the training set into multiple folders by category](/img/eb/49c65f9af4c899b8cffaeec630be79.png)
[logodetection data set processing] (3) divide the training set into multiple folders by category

【原创】POI 5.x XSSF和HSSF使用自定义字体颜色
![[discrete mathematics review series] IV. figure](/img/70/5b2f783265e7e5f6485b49088400da.png)
[discrete mathematics review series] IV. figure

Binary tree and figure 1

CVPR 2022 | frame by frame motion representation of long video based on sequence contrast learning

NC | Wang Jun / song Mozhi combined with third-generation sequencing to analyze the structural variation and function of intestinal flora

一次主从表集成流程开发过程
[advanced MySQL] optimize SQL by using the execution plan explain (2)

【LogoDetection 数据集处理】(2)画出训练集图片的标注框
随机推荐
【云原生 | Kubernetes篇】深入RC、RS、DaemonSet、StatefulSet(七)
【报名】解决科技创业者核心关切,「星云计划公开课」线上招生开启
【原创】POI 5.x XSSF和HSSF使用自定义字体颜色
[discrete mathematics review series] i. propositional logic
NC | Wang Jun / song Mozhi combined with third-generation sequencing to analyze the structural variation and function of intestinal flora
Adding, deleting, modifying and querying databases with JDBC
[vue/js] realize local caching of variables and objects through localstorage browser (text + full source code)
博主自白
Main features of IIC bus / communication process / read / write process
Blogger Confessions
Ue5 how to convert screen coordinates to world coordinates and World Directions
Ue5 Comment convertir les coordonnées de l'écran en coordonnées du monde et en direction du monde
竟然还有人说ArrayList是2倍扩容,今天带你手撕ArrayList源码
KAtex problem - the style of equal sign alignment in CSDN editing
CG碰撞检测 Collision Testing
[registration] to solve the core concerns of technology entrepreneurs, the online enrollment of "nebula plan open class" was opened
【LogoDetection 数据集处理】(1)将数据集切分为训练集和验证集
UE5如何将屏幕坐标转为世界坐标和世界方向
【离散数学期复习系列】三、集合的概念及运算
Primary master-slave table integration process development process