当前位置:网站首页>Go deep into RC, RS, daemonset and statefulset (VII)
Go deep into RC, RS, daemonset and statefulset (VII)
2022-06-29 09:29: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: 80
RS 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: 80
Two 、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: NoSchedule
See the effect
kubectl get pod -l name=logging -o wide
3、 ... 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 : " (namespace).svc.cluster.local", that pod The parsing entry is " (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 】
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 .
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 .
边栏推荐
- What is the difference between hyperconverged architecture and traditional architecture?
- Research progress of target detection in the era of deep convolutional neural network
- Pytorch Summary - sensor on GPU
- train_on_batch保存一下loss函数变化的图像
- programing language
- Mysql database and table splitting strategy and application scenarios
- 1.4 机器学习方法之回归问题
- [target detection] | indicator a probabilistic challenge for object detection
- Pat (basic level) practice (Chinese) 1003 I want to pass! (20 points) C language implementation
- LFFD:一种用于边缘检测的轻量化快速人脸检测器
猜你喜欢

微信小程序项目:tab导航栏

Detailed version of two-stage target detection principle

Simplicity Studio无法识别新买的JLink v9解决方法

Wechat applet sub components transfer values to the page (communication between parent and child components) with source code

Wechat applet wx Navigateback returns the parameters carried on the previous page

SSD Improvement cfenet

SSD改進CFENet

Research progress of target detection in the era of deep convolutional neural network

LFFD:一种用于边缘检测的轻量化快速人脸检测器

SSD improvements cfenet
随机推荐
1.4 机器学习方法之回归问题
爱快安装或重置后,PC或手机端获取不到ip
Mh/t 6040 smoke density test of aviation materials
Write down some written test questions
深卷积神经网络时代的目标检测研究进展
Redo after JS rotation view (longer full version, can be run)
记自定义微信小程序顶部导航栏
How to do unit test well
keras转tf.keras中VGG19 input_shape
通识篇:原型设计的认知,设计及最佳实践
UE4 installs the datasmith plug-in in version 4.20-23
UE4 VS的Visual Assist插件设置
The former security director of Uber faced fraud allegations and had concealed data leakage incidents
微信小程序分享页面,分享到朋友圈
cmd进入虚拟机
Yotact real-time instance segmentation
微信小程序子组件向页面传值(父子组件间的通信)带源码
Handwritten virtualdom
Wechat applet latest canvas2d handwritten signature
网络安全问题