7. ReplicaSetΒΆ
Show minimal ReplicaSet definition
$ tee files/kuard-rs.yaml << EOF
apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
name: kuard
spec:
replicas: 1
selector:
matchLabels:
app: kuard
version: "2"
template:
metadata:
labels:
app: kuard
version: "2"
spec:
containers:
- name: kuard
image: "gcr.io/kuar-demo/kuard-amd64:2"
EOF
Create ReplicaSet
$ kubectl apply -f files/kuard-rs.yaml
Check pods
$ kubectl get pods
Check ReplicaSet details
$ kubectl describe rs kuard
The pods have the same labels as ReplicaSet
$ kubectl get pods -l app=kuard,version=2 --show-labels
Check if pod is part of ReplicaSet
$ kubectl get pods -l app=kuard,version=2 -o json | jq ".items[].metadata"
Scale up ReplicaSet
$ kubectl scale replicasets kuard --replicas=4
New pods are beeing created
$ kubectl get pods -l app=kuard --show-labels
Delete ReplicaSet
$ kubectl delete rs kuard