Use Replication Controller, Replica Set management Pod
Replication Controller (RC)
Abbreviated as RC, rc can be used as a quick managed objects kubectl tools for managing multiple Pod resource object, the object for more than a pod. If the pod number is too large, delete and more, if the pod to reduce the number, there are pod unhealthy or shoot down, restart a pod, ensure that the total number of the same pod, mainly used to deploy, upgrade Pod
Use RC Management Pod
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx
labels:
app: nginx
spec:
replicat: 3 #设置副本数量
selector:
app: nginx #选择管理的Pod 标签
template:
metadata:
labels:
app: nginx #必须和selector选择的标签一致
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
Pod resources compared to the target deployment template file, rc remained almost the same, need apiVersion, kind, metadata, spec, except that rc in more spec.template field, is under spec.template Pod template and Pod resource object the same format.
Replica Set(RS)
Abbreviated as RS, the RC generation, essentially the same function, except that, the RC supports only equation label selected selector (env = dev or environment! = Qa), RS also supports a set of selector (version in (v1.0 , v2.0))
Official template
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
About summarize RC
/ RS
some of the features and functions of it:
- In most cases, we can define a
RC
realization ofPod
creation and number of copies of control RC
Contains a fullPod
definition module (not includedapiversion
andkind
)RC
Throughlabel selector
to implement the mechanism ofPod
control copies of- By changing the
RC
inside ofPod
number of copies, may be implementedPod
expansion volume reduction function - By changing the
RC
inside ofPod
the template image version, you can achievePod
a rolling upgrade functionality (but does not support a key roll back, you need to modify the mirror address in the same way) - Pod as RS retractable horizontal scaler (HPA)