01 - Core Concepts - ReplicaSets
ReplicaSets
$ kubectl get replicaset
$ kubectl get rs
Get the current ReplicaSets deployed.$ kubectl describe rs <replicaset-name>
Get detailed information about ReplicaSet.
$ kubectl delete pod <pod-name1> <pod-name2> <pod-name3>
$ kubectl delete rs <replicaset-name>
$ kubectl delete -f <file-name>.yaml
Delete pods/ReplicaSet.
Q: Why are there still 4 PODs, even after you deleted one?
A: ReplicaSet ensures that desired number of PODs always run
Fix YAML file
$ kubectl create -f replicaset-definition-1.yaml
➥ 先用此指令,得到 Error Msg
$ kubectl api-resources | grep replicaset
Print the supported API resources.
$ kubectl explain replicaset
Get the documentation of the resource and its fields.$ vim replicaset-definition-1.yaml
$ kubectl create -f replicaset-definition-1.yaml
Create a resource from a file or from stdin.$ kubectl apply -f replicaset-definition-1.yaml
Apply a configuration to a resource by file name or stdin.
- The resource name must be specified. This resource will be created if it doesn't exist yet.
- To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.
Fix the original ReplicaSet
$ kubectl edit rs <replicaset-name>
※ 若更改了 image,還需要將原始的 pod 刪除,才會套用新的 image。
```yaml
spec:
template:
spec:
containers:
image: busybox
```
※ 若更改了 replicas,無需將原始的 pod 刪除,會自動套用新的 replicas 設定。
```yaml
spec:
replicas: 5
```
$ kubectl scale rs <replicaset-name> --replicas=5
※ 若更改了 replicas,無需將原始的 pod 刪除,會自動套用新的 replicas 設定。
留言
張貼留言