Changing the configuration of a ReplicaSet

The subcommands known as edit, patch, and replace can help to update live Kubernetes resources. All these functionalities change the settings by way of modifying a configuration file. Here we just take edit, for example.

The subcommand edit lets users modify resource configuration through the editor. Try to update your ReplicaSet through the command kubectl edit rs $REPLICASET_NAME; you will access this resource via the default editor with a YAML configuration file:

// demonstrate to change the number of Pod replicas.
$ kubectl get rs
NAME DESIRED CURRENT READY AGE
my-first-replicaset 3 3 3 2m

// get in the editor, modify the replica number, then save and leave
$ kubectl edit rs my-first-replicaset
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
creationTimestamp: 2018-05-05T20:48:38Z
generation: 1
labels:
version: 0.0.1
name: my-first-replicaset
namespace: default
resourceVersion: "1255241"
selfLink: /apis/extensions/v1beta1/namespaces/default/replicasets/my-first-replicaset
uid: 18330fa8-cd55-11e7-a4de-525400a9d353
spec:
replicas: 4
selector:
matchLabels:
...
replicaset "my-first-replicaset" edited
$ kubectl get rs
NAME DESIRED CURRENT READY AGE
my-first-replicaset 4 4 4 4m

In the demonstration, we succeed to add one Pod in the set, yet this is not the best practice for auto-scaling the Pod. Take a look at the Working with configuration files recipe in Chapter 3, Playing with Containers, for Reference, and try to change the other values.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.154.139