You must know
selector
is to find the matched labels for managing the POD
s in the ReplicaSet
.
YAML - rs-definition.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| apiVersion: apps/v1
kind: ReplicaSet
metadata: # -> ReplicaSet
name: myapp-replicaset
labels:
app: myapp
type: front-end
spec: # -> ReplicaSet
template:
metadata: # -> POD
name: myapp-pod
labels:
app: myapp
type: front-end
spec: # -> POD
containers:
- name: nginx-continer
image: nginx
replicas: 3
selector: # -> `selector` is not required by Replication Controller
matchLabels:
type: front-end
|
Create a ReplicaSet
1
| kubectl create -f rs-definition.yml
|
Show ReplicaSet List
Show ReplicaSet Detail
1
| kubectl describe replicaset myapp-replicaset
|
Change Running ReplicaSet
1
| kubectl edit replicaset myapp-replicaset
|
Delete ReplicaSet
1
| kubectl delete replicaset myapp-replicaset
|
Scale
Change replicas
in the YAML file with replace
1
| kubectl replace -f rs-definition.yml
|
Origin YAML file and --replicas
option with scale
1
| kubectl scale --replicas=6 -f rs-definition.yml
|
Change Running ReplicaSet’s name and --replicas
option with scale
1
| kubectl scale --replicas=6 replicaset myapp-replicaset
|