前面我们介绍了单pod建立service,不过实务上这种做法很没必要。
因为service的工作是提供外部能够找到pod群当中能用的pod,当只有单个pod的时候,坏掉或是更版也是全部都坏掉跟更版,不会有负载平衡的效果。
因此,就该Deployment 和 ReplicaSet 出场了。
ReplicaSet确保一组稳定的replica Pods运行,会确保这些pod会在资源许可下,会启动你要求的数量。
依造官方说法,建议ReplicaSet搭配deployment使用,并且透过deployment运行,而非直接操作ReplicaSet。
因此要使用deployment前,最好先了解ReplicaSet
首先先建立frontend.yaml,并将其内容复制进去:
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
上面可以看到kind种类为ReplicaSet,replicas为3代表会建立三个pod。
再来透过下面指令
kubectl apply -f frontend.yaml
就可以建立ReplicaSet,而要确认有没有正确建立则可以用 get rs
kubectl get rs
kubectl get pods
可以看到也成功建立了三个pod。
想要删除ReplicaSet 一样使用kubectl delete
kubectl delete rs frontend
然後就会像下图那样,将ReplicaSet和pod都删除了
如前述所说,一般情况不会这样直接建立ReplicaSet以及对它操作,都会透过 Deployment去处理,因此下一章会正式进入Deployment,也可以顺便看下如何透过Deployment来跟ReplicaSet互动。
<<: [Day14] swift & kotlin 实作篇!(5) 基本版面配置
今天来将画面做好,我们面对的资料长这样。 需求: 通常一个使用者的 form 表单是用在新增/编辑资...
-保护环(来源:维基百科) 保护环:指令特权级别和操作系统模式(Protection Rings:...
昨天介绍了velero的概念,今天来配置一套velero出来看看吧。 配置velero非常的简单,只...
流程判断 if : 判断式的开头,只有一组且不须其他判断式一起使用。 else if : 判断式的第...
前面提到Raspberry pi有哪些传输方式 IIC/SPI/1-wire/UART 书上建议可以...