891c9c69fe
In addition, changed the order of some Linux questions.
1.1 KiB
1.1 KiB
ReplicaSet 01 - Solution
- Create a ReplicaSet with 2 replicas. The app can be anything.
cat >> rs.yaml <<EOL
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: web
labels:
app: somewebapp
type: web
spec:
replicas: 2
selector:
matchLabels:
type: web
template:
metadata:
labels:
type: web
spec:
containers:
- name: httpd
image: registry.redhat.io/rhscl/httpd-24-rhel7
EOL
kubectl apply -f rs.yaml
- Verify a ReplicaSet was created and there are 2 replicas
kubectl get rs
# OR a more specific way: kubectl get -f rs.yaml
- Delete one of the Pods the ReplicaSet has created
kubectl delete po <POD_NAME>
- If you'll list all the Pods now, what will you see?
The same number of Pods. Since we defined 2 replicas, the ReplicaSet will make sure to create another Pod that will replace the one you've deleted.
- Remove the ReplicaSet you've created
kubectl delete -f rs.yaml
- Verify you've deleted the ReplicaSet
kubectl get rs
# OR a more specific way: kubectl get -f rs.yaml