ReplicationController(也简称为 rc)用来确保容器应用的副本数始终保持在用户定义的副本数,即如果有容器异常退出,会自动创建新的 Pod 来替代;而异常多出来的容器也会自动回收。ReplicationController 的典型应用场景包括确保健康 Pod 的数量、弹性伸缩、滚动升级以及应用多版本发布跟踪等。
apiVersion:extensions/v1beta1kind:ReplicaSetmetadata:name:frontend# these labels can be applied automatically# from the labels in the pod template if not set# labels:# app: guestbook# tier: frontendspec:# this replicas value is default# modify it according to your casereplicas:3# selector can be applied automatically# from the labels in the pod template if not set,# but we are specifying the selector here to# demonstrate its usage.selector:matchLabels:tier:frontendmatchExpressions: - {key:tier,operator:In,values: [frontend]}template:metadata:labels:app:guestbooktier:frontendspec:containers: - name:php-redisimage:gcr.io/google_samples/gb-frontend:v3resources:requests:cpu:100mmemory:100Mienv: - name:GET_HOSTS_FROMvalue:dns# If your cluster config does not include a dns service, then to# instead access environment variables to find service host# info, comment out the 'value: dns' line above, and uncomment the# line below.# value: envports: - containerPort:80