You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resource creation isn’t the only operation that `kubectl` can perform in bulk. It can also extract resource names from configuration files in order to perform other operations, in particular to delete the same resources you created:
127
127
128
-
```bash
128
+
```console
129
129
$ kubectl delete -f ./nginx/
130
130
replicationcontrollers/my-nginx
131
131
services/my-nginx-svc
132
132
```
133
133
134
134
In the case of just two resources, it’s also easy to specify both on the command line using the resource/name syntax:
@@ -240,8 +240,8 @@ The frontend service would span both sets of replicas by selecting the common su
240
240
241
241
Sometimes existing pods and other resources need to be relabeled before creating new resources. This can be done with `kubectl label`. For example:
242
242
243
-
```bash
244
-
kubectl label pods -lapp=nginx tier=fe
243
+
```console
244
+
$ kubectl label pods -lapp=nginx tier=fe
245
245
NAME READY STATUS RESTARTS AGE
246
246
my-nginx-v4-9gw19 1/1 Running 0 14m
247
247
NAME READY STATUS RESTARTS AGE
@@ -265,7 +265,7 @@ my-nginx-v4-wfof4 1/1 Running 0 16m fe
265
265
266
266
When load on your application grows or shrinks, it’s easy to scale with `kubectl`. For instance, to increase the number of nginx replicas from 2 to 3, do:
267
267
268
-
```bash
268
+
```console
269
269
$ kubectl scale rc my-nginx --replicas=3
270
270
scaled
271
271
$ kubectl get pods -lapp=nginx
@@ -304,14 +304,14 @@ spec:
304
304
305
305
To update to version 1.9.1, you can use [`kubectl rolling-update --image`](../../docs/design/simple-rolling-update.md):
In another window, you can see that `kubectl` added a `deployment` label to the pods, whose value is a hash of the configuration, to distinguish the new pods from the old:
At beginning of loop: my-nginx replicas: 4, my-nginx-v4 replicas: 1
@@ -413,7 +413,7 @@ You can also run the [update demo](update-demo/) to see a visual representation
413
413
414
414
Sometimes it’s necessary to make narrow, non-disruptive updates to resources you’ve created. For instance, you might want to add an [annotation](annotations.md) with a description of your object. That’s easiest to do with `kubectl patch`:
@@ -429,7 +429,7 @@ The patch is specified using json.
429
429
430
430
For more significant changes, you can `get` the resource, edit it, and then `replace` the resource with the updated version:
431
431
432
-
```bash
432
+
```console
433
433
$ kubectl get rc my-nginx-v4 -o yaml > /tmp/nginx.yaml
434
434
$ vi /tmp/nginx.yaml
435
435
$ kubectl replace -f /tmp/nginx.yaml
@@ -443,7 +443,7 @@ The system ensures that you don’t clobber changes made by other users or compo
443
443
444
444
In some cases, you may need to update resource fields that cannot be updated once initialized, or you may just want to make a recursive change immediately, such as to fix broken pods created by a replication controller. To change such fields, use `replace --force`, which deletes and re-creates the resource. In this case, you can simply modify your original configuration file:
0 commit comments