当前位置:网站首页>[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 .
边栏推荐
- Ue5 how to convert screen coordinates to world coordinates and World Directions
- 在启牛开户安全么
- 超强实操!手把手教学Kinect深度图与RGB摄像头的标定与配准
- 【LogoDetection 数据集处理】(1)将数据集切分为训练集和验证集
- The interview at the big factory was held at 10:00 a.m. and came out at 10:09 a.m. the question was really too
- CVPR 2022 Oral | SCI:实现快速、灵活与稳健的低光照图像增强
- Flutter Icon Stack LIsttitle... Learning summary 3
- Docker deploys a redis cluster
- Yanrong looks at how to realize the optimal storage solution of data Lake in a hybrid cloud environment
- 2022 Shandong Province safety officer C certificate retraining question bank and online simulation examination
猜你喜欢

【LogoDetection 数据集处理】(4)提取每张图片的logo区域

2022年制冷与空调设备运行操作理论题库模拟考试平台操作

2022危险化学品经营单位主要负责人考试题库及在线模拟考试
![[Discrete Mathematical period Review Series] Second and first order Logic (precate Logic)](/img/f3/c7e61462a012ca1b88dca7b1ecdb25.png)
[Discrete Mathematical period Review Series] Second and first order Logic (precate Logic)

Beijing / Shanghai internal promotion | recruitment of full-time interns in the system and network group of Microsoft Research Asia

QT 基于QScrollArea的界面嵌套移动
![[notes] notes on C language array pointer, structure + two-dimensional array pointer](/img/77/5923754b12ccfe0bcba7e46617de86.png)
[notes] notes on C language array pointer, structure + two-dimensional array pointer

北京/上海内推 | 微软亚洲研究院系统与网络组招聘全职实习生

CVPR 2022 | 基于序列对比学习的长视频逐帧动作表示

Flutter listview, column, row learning personal summary 2
随机推荐
算力网络照进现实,浩鲸科技如何构建?
博主自白
Review summary of final examination of software architecture principles, methods and practices, Second Edition
消息中间件的消费模式
Blogger Confessions
Mutual transformation among lists, arrays and tensors
C multithreading learning note 2
Does Fortran have a standard library
C multithreading learning note 3
大厂面试上午10:00面试,10:09就出来了 ,问的实在是太...
【離散數學期複習系列】二、一階邏輯(謂詞邏輯)
ScrollView 初始化的时候不在最顶部?
微信小程序 日期比较,计算天数
C#多线程学习笔记一
Gin blog summary 1
Design tools and skills for beginners to build their own blog
Yanrong looks at how to realize the optimal storage solution of data Lake in a hybrid cloud environment
【重庆大学】初试复试资料分享(附考研群)
[logodetection data set processing] (2) draw the label box of the training set picture
北京/上海内推 | 微软亚洲研究院系统与网络组招聘全职实习生