ReplicaSet

Overview

  1. ReplicaSet is a process of monitoring pods, when pod is down, it will startup a new one.
  2. ReplicaSet identify which pods to monitor by labels.
  3. RelicatSet monitor and keep the pod number as described in yaml file or command line setting. In order word, if part of the pods is down, ReplicaSet will automatically start new pods to keep the pod number as described in ReplicaSet yaml.
  4. According to #2 and #3, suppose that there is a number of pods running as described in ReplicaSet yaml. We start a new pod with the same label described in RelipcaSet in some way, (e.g. start a new pod by pod.yaml), the newly created pod will be terminated since ReplicaSet will keep the pod number by labels described in ReplicaSet yaml.

Yaml

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: my-rc
  labels:
    app: myapp
    type: front-end
spec:
  # RelicaSet - template - pod description
  # RelicaSet - replicas - pod number
  # RelicaSet - selector - pod finder
  replicas: 3
  selector:              # match the pod label @1
    matchLabels:
      type: front-end
  template:
    metadata:
      labels:            # pod label @1
        type: front-end
    spec:
      containers:
        - name: ngx-container
          image: nginx

Test

kubectl apply -f replicaset.yaml
kubectl describe pod ngx-container
kubectl apply -f replicaset.yaml # change replicas from 3 to 5.
kubectl get pods
kubectl delete -f replicaset.yaml
posted @   608088  阅读(42)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示