@@ -91,6 +91,9 @@ Apply a configuration to a resource by file name or stdin
91
91
# Apply the JSON passed into stdin to a pod
92
92
cat pod.json | oc apply -f -
93
93
94
+ # Apply the configuration from all files that end with '.json' - i.e. expand wildcard characters in file names
95
+ oc apply -f '*.json'
96
+
94
97
# Note: --prune is still in Alpha
95
98
# Apply the configuration in manifest.yaml that matches label app=nginx and delete all other resources that are not in the file and match label app=nginx
96
99
oc apply --prune -f manifest.yaml -l app=nginx
@@ -474,11 +477,14 @@ Set a cluster entry in kubeconfig
474
477
# Embed certificate authority data for the e2e cluster entry
475
478
oc config set-cluster e2e --embed-certs --certificate-authority=~/.kube/e2e/kubernetes.ca.crt
476
479
477
- # Disable cert checking for the dev cluster entry
480
+ # Disable cert checking for the e2e cluster entry
478
481
oc config set-cluster e2e --insecure-skip-tls-verify=true
479
482
480
483
# Set custom TLS server name to use for validation for the e2e cluster entry
481
484
oc config set-cluster e2e --tls-server-name=my-cluster-name
485
+
486
+ # Set proxy url for the e2e cluster entry
487
+ oc config set-cluster e2e --proxy-url=https://1.2.3.4
482
488
----
483
489
484
490
@@ -626,8 +632,8 @@ Create a resource from a file or from stdin
626
632
# Create a pod based on the JSON passed into stdin
627
633
cat pod.json | oc create -f -
628
634
629
- # Edit the data in docker- registry.yaml in JSON then create the resource using the edited data
630
- oc create -f docker- registry.yaml --edit -o json
635
+ # Edit the data in registry.yaml in JSON then create the resource using the edited data
636
+ oc create -f registry.yaml --edit -o json
631
637
----
632
638
633
639
@@ -1124,6 +1130,33 @@ Create a service account with the specified name
1124
1130
1125
1131
1126
1132
1133
+ == oc create token
1134
+ Request a service account token
1135
+
1136
+ .Example usage
1137
+ [source,bash,options="nowrap"]
1138
+ ----
1139
+ # Request a token to authenticate to the kube-apiserver as the service account "myapp" in the current namespace
1140
+ oc create token myapp
1141
+
1142
+ # Request a token for a service account in a custom namespace
1143
+ oc create token myapp --namespace myns
1144
+
1145
+ # Request a token with a custom expiration
1146
+ oc create token myapp --duration 10m
1147
+
1148
+ # Request a token with a custom audience
1149
+ oc create token myapp --audience https://example.com
1150
+
1151
+ # Request a token bound to an instance of a Secret object
1152
+ oc create token myapp --bound-object-kind Secret --bound-object-name mysecret
1153
+
1154
+ # Request a token bound to an instance of a Secret object with a specific uid
1155
+ oc create token myapp --bound-object-kind Secret --bound-object-name mysecret --bound-object-uid 0d4691ed-659b-4935-a832-355f77ee47cc
1156
+ ----
1157
+
1158
+
1159
+
1127
1160
== oc create user
1128
1161
Manually create a user (only needed if automatic creation is disabled)
1129
1162
@@ -1196,6 +1229,9 @@ Delete resources by file names, stdin, resources and names, or by resources and
1196
1229
# Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
1197
1230
oc delete -k dir
1198
1231
1232
+ # Delete resources from all files that end with '.json' - i.e. expand wildcard characters in file names
1233
+ oc apply -f '*.json'
1234
+
1199
1235
# Delete a pod based on the type and name in the JSON passed into stdin
1200
1236
cat pod.json | oc delete -f -
1201
1237
@@ -1266,17 +1302,20 @@ Edit a resource on the server
1266
1302
.Example usage
1267
1303
[source,bash,options="nowrap"]
1268
1304
----
1269
- # Edit the service named 'docker- registry'
1270
- oc edit svc/docker- registry
1305
+ # Edit the service named 'registry'
1306
+ oc edit svc/registry
1271
1307
1272
1308
# Use an alternative editor
1273
- KUBE_EDITOR="nano" oc edit svc/docker- registry
1309
+ KUBE_EDITOR="nano" oc edit svc/registry
1274
1310
1275
1311
# Edit the job 'myjob' in JSON using the v1 API format
1276
1312
oc edit job.v1.batch/myjob -o json
1277
1313
1278
1314
# Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation
1279
1315
oc edit deployment/mydeployment -o yaml --save-config
1316
+
1317
+ # Edit the deployment/mydeployment's status subresource
1318
+ oc edit deployment mydeployment --subresource='status'
1280
1319
----
1281
1320
1282
1321
@@ -1352,13 +1391,6 @@ Expose a replicated application as a service or route
1352
1391
1353
1392
# Expose a service as a route in the specified path
1354
1393
oc expose service nginx --path=/nginx
1355
-
1356
- # Expose a service using different generators
1357
- oc expose service nginx --name=exposed-svc --port=12201 --protocol="TCP" --generator="service/v2"
1358
- oc expose service nginx --name=my-route --port=12201 --generator="route/v1"
1359
-
1360
- # Exposing a service using the "route/v1" generator (default) will create a new exposed route with the "--name" provided
1361
- # (or the name of the service otherwise). You may not specify a "--protocol" or "--target-port" option when using this generator
1362
1394
----
1363
1395
1364
1396
@@ -1422,6 +1454,9 @@ Display one or many resources
1422
1454
1423
1455
# List one or more resources by their type and names
1424
1456
oc get rc/web service/frontend pods/web-pod-13je7
1457
+
1458
+ # List status subresource for a single pod.
1459
+ oc get pod web-pod-13je7 --subresource status
1425
1460
----
1426
1461
1427
1462
@@ -1867,6 +1902,21 @@ Update fields of a resource
1867
1902
1868
1903
# Update a container's image using a JSON patch with positional arrays
1869
1904
oc patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
1905
+
1906
+ # Update a deployment's replicas through the scale subresource using a merge patch.
1907
+ oc patch deployment nginx-deployment --subresource='scale' --type='merge' -p '{"spec":{"replicas":2}}'
1908
+ ----
1909
+
1910
+
1911
+
1912
+ == oc plugin list
1913
+ List all visible plugin executables on a user's PATH
1914
+
1915
+ .Example usage
1916
+ [source,bash,options="nowrap"]
1917
+ ----
1918
+ # List all available plugins
1919
+ oc plugin list
1870
1920
----
1871
1921
1872
1922
@@ -2065,9 +2115,6 @@ Log in to the integrated registry
2065
2115
# Log in to the integrated registry
2066
2116
oc registry login
2067
2117
2068
- # Log in as the default service account in the current namespace
2069
- oc registry login -z default
2070
-
2071
2118
# Log in to different registry using BASIC auth credentials
2072
2119
oc registry login --registry quay.io/myregistry --auth-basic=USER:PASS
2073
2120
----
@@ -2186,6 +2233,9 @@ Restart a resource
2186
2233
2187
2234
# Restart a daemon set
2188
2235
oc rollout restart daemonset/abc
2236
+
2237
+ # Restart deployments with the app=nginx label
2238
+ oc rollout restart deployment --selector=app=nginx
2189
2239
----
2190
2240
2191
2241
@@ -2369,46 +2419,6 @@ Detach secrets from a service account
2369
2419
2370
2420
2371
2421
2372
- == oc serviceaccounts create-kubeconfig
2373
- Generate a kubeconfig file for a service account
2374
-
2375
- .Example usage
2376
- [source,bash,options="nowrap"]
2377
- ----
2378
- # Create a kubeconfig file for service account 'default'
2379
- oc serviceaccounts create-kubeconfig 'default' > default.kubeconfig
2380
- ----
2381
-
2382
-
2383
-
2384
- == oc serviceaccounts get-token
2385
- Get a token assigned to a service account
2386
-
2387
- .Example usage
2388
- [source,bash,options="nowrap"]
2389
- ----
2390
- # Get the service account token from service account 'default'
2391
- oc serviceaccounts get-token 'default'
2392
- ----
2393
-
2394
-
2395
-
2396
- == oc serviceaccounts new-token
2397
- Generate a new token for a service account
2398
-
2399
- .Example usage
2400
- [source,bash,options="nowrap"]
2401
- ----
2402
- # Generate a new token for service account 'default'
2403
- oc serviceaccounts new-token 'default'
2404
-
2405
- # Generate a new token for service account 'default' and apply
2406
- # labels 'foo' and 'bar' to the new token for identification
2407
- oc serviceaccounts new-token 'default' --labels foo=foo-value,bar=bar-value
2408
- ----
2409
-
2410
-
2411
-
2412
2422
== oc set build-hook
2413
2423
Update a build hook on a build config
2414
2424
@@ -2871,7 +2881,7 @@ Experimental: Wait for a specific condition on one or many resources
2871
2881
# Wait for the pod "busybox1" to contain the status condition of type "Ready"
2872
2882
oc wait --for=condition=Ready pod/busybox1
2873
2883
2874
- # The default value of status condition is true; you can set it to false
2884
+ # The default value of status condition is true; you can wait for other targets after an equal delimiter (compared after Unicode simple case folding, which is a more general form of case-insensitivity):
2875
2885
oc wait --for=condition=Ready=false pod/busybox1
2876
2886
2877
2887
# Wait for the pod "busybox1" to contain the status phase to be "Running".
0 commit comments