当前位置:网站首页>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 .
边栏推荐
- GD32F4xx 以太网芯片(enc28j60)驱动移植
- promise方法的简单使用
- Self cultivation (XXI) servlet life cycle, service method source code analysis, thread safety issues
- Redo after JS rotation view (longer full version, can be run)
- Wechat applet user refuses to authorize geographic location information and calls up the authorization window again
- # 《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(四)
- AugFPN:改進多尺度特征學習用於目標檢測
- Debugging H5 page -weinre and spy debugger real machine debugging
- 爱快安装或重置后,PC或手机端获取不到ip
- Western Polytechnic University, one of the "seven national defense schools", was attacked by overseas networks
猜你喜欢

pytorch总结学习系列-操作

如何将谷歌浏览器设置为默认浏览器

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

Augfpn: amélioration de l'apprentissage des caractéristiques à plusieurs échelles pour la détection des cibles

SSD improvements cfenet

Wechat applet user refuses to authorize geographic location information and calls up the authorization window again

AugFPN:改进多尺度特征学习用于目标检测

What is the difference between hyperconverged architecture and traditional architecture?

What exactly does Devops mean?

AugFPN:改進多尺度特征學習用於目標檢測
随机推荐
Training kernel switching using GPU
PAT (Basic Level) Practice (中文)1003 我要通过! (20分) C语言实现
Pytorch summary learning series - operation
CMD enter virtual machine
Wechat applet opens file stream
MH/T 6040航空材料烟密度试验
UE4 蓝图修改Array 中Get a copy 为 reference
Twinmotion beginner tutorial
微信小程序项目:tab导航栏
专业结构record
train_ on_ Batch save the image of the loss function change
深入RC、RS、DaemonSet、StatefulSet(七)
Augfpn: amélioration de l'apprentissage des caractéristiques à plusieurs échelles pour la détection des cibles
Instance error iopub data rate exceeded
如何将谷歌浏览器设置为默认浏览器
Find the most repeated element in the string
pytorch学习总结—运算的内存开销
Mh/t 6040 smoke density test of aviation materials
手机开户一般哪个证券公司好?究竟网上开户是否安全么?
YOLACT实时实例分割