@@ -91,7 +91,7 @@ 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
94
+ # Apply the configuration from all files that end with '.json'
95
95
oc apply -f '*.json'
96
96
97
97
# Note: --prune is still in Alpha
@@ -333,7 +333,7 @@ Output shell completion code for the specified shell (bash, zsh, fish, or powers
333
333
## Write bash completion code to a file and source it from .bash_profile
334
334
oc completion bash > ~/.kube/completion.bash.inc
335
335
printf "
336
- # Kubectl shell completion
336
+ # oc shell completion
337
337
source '$HOME/.kube/completion.bash.inc'
338
338
" >> $HOME/.bash_profile
339
339
source $HOME/.bash_profile
@@ -542,10 +542,10 @@ Set a cluster entry in kubeconfig
542
542
# Disable cert checking for the e2e cluster entry
543
543
oc config set-cluster e2e --insecure-skip-tls-verify=true
544
544
545
- # Set custom TLS server name to use for validation for the e2e cluster entry
545
+ # Set the custom TLS server name to use for validation for the e2e cluster entry
546
546
oc config set-cluster e2e --tls-server-name=my-cluster-name
547
547
548
- # Set proxy url for the e2e cluster entry
548
+ # Set the proxy URL for the e2e cluster entry
549
549
oc config set-cluster e2e --proxy-url=https://1.2.3.4
550
550
----
551
551
@@ -582,7 +582,7 @@ Set a user entry in kubeconfig
582
582
# Enable the Google Compute Platform auth provider for the "cluster-admin" entry
583
583
oc config set-credentials cluster-admin --auth-provider=gcp
584
584
585
- # Enable the OpenID Connect auth provider for the "cluster-admin" entry with additional args
585
+ # Enable the OpenID Connect auth provider for the "cluster-admin" entry with additional arguments
586
586
oc config set-credentials cluster-admin --auth-provider=oidc --auth-provider-arg=client-id=foo --auth-provider-arg=client-secret=bar
587
587
588
588
# Remove the "client-secret" config value for the OpenID Connect auth provider for the "cluster-admin" entry
@@ -591,7 +591,7 @@ Set a user entry in kubeconfig
591
591
# Enable new exec auth plugin for the "cluster-admin" entry
592
592
oc config set-credentials cluster-admin --exec-command=/path/to/the/executable --exec-api-version=client.authentication.k8s.io/v1beta1
593
593
594
- # Define new exec auth plugin args for the "cluster-admin" entry
594
+ # Define new exec auth plugin arguments for the "cluster-admin" entry
595
595
oc config set-credentials cluster-admin --exec-arg=arg1 --exec-arg=arg2
596
596
597
597
# Create or update exec auth plugin environment variables for the "cluster-admin" entry
@@ -639,7 +639,7 @@ Display merged kubeconfig settings or a specified kubeconfig file
639
639
# Show merged kubeconfig settings
640
640
oc config view
641
641
642
- # Show merged kubeconfig settings and raw certificate data and exposed secrets
642
+ # Show merged kubeconfig settings, raw certificate data, and exposed secrets
643
643
oc config view --raw
644
644
645
645
# Get the password for the e2e user
@@ -878,7 +878,7 @@ Create an ingress with the specified name
878
878
[source,bash,options="nowrap"]
879
879
----
880
880
# Create a single ingress called 'simple' that directs requests to foo.com/bar to svc
881
- # svc1:8080 with a tls secret "my-cert"
881
+ # svc1:8080 with a TLS secret "my-cert"
882
882
oc create ingress simple --rule="foo.com/bar=svc1:8080,tls=my-cert"
883
883
884
884
# Create a catch all ingress of "/path" pointing to service svc:port and Ingress Class as "otheringress"
@@ -1087,7 +1087,7 @@ Create a secret for use with a Docker registry
1087
1087
.Example usage
1088
1088
[source,bash,options="nowrap"]
1089
1089
----
1090
- # If you don't already have a .dockercfg file, you can create a dockercfg secret directly by using:
1090
+ # If you do not already have a .dockercfg file, create a dockercfg secret directly
1091
1091
oc create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
1092
1092
1093
1093
# Create a new secret named my-secret from ~/.docker/config.json
@@ -1216,7 +1216,7 @@ Request a service account token
1216
1216
# Request a token bound to an instance of a Secret object
1217
1217
oc create token myapp --bound-object-kind Secret --bound-object-name mysecret
1218
1218
1219
- # Request a token bound to an instance of a Secret object with a specific uid
1219
+ # Request a token bound to an instance of a Secret object with a specific UID
1220
1220
oc create token myapp --bound-object-kind Secret --bound-object-name mysecret --bound-object-uid 0d4691ed-659b-4935-a832-355f77ee47cc
1221
1221
----
1222
1222
@@ -1261,6 +1261,10 @@ Launch a new instance of a pod for debugging
1261
1261
# Debug a node as an administrator
1262
1262
oc debug node/master-1
1263
1263
1264
+ # Debug a Windows Node
1265
+ # Note: the chosen image must match the Windows Server version (2019, 2022) of the Node
1266
+ oc debug node/win-worker-1 --image=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
1267
+
1264
1268
# Launch a shell in a pod using the provided image stream tag
1265
1269
oc debug istag/mysql:latest -n openshift
1266
1270
@@ -1294,7 +1298,7 @@ Delete resources by file names, stdin, resources and names, or by resources and
1294
1298
# Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
1295
1299
oc delete -k dir
1296
1300
1297
- # Delete resources from all files that end with '.json' - i.e. expand wildcard characters in file names
1301
+ # Delete resources from all files that end with '.json'
1298
1302
oc delete -f '*.json'
1299
1303
1300
1304
# Delete a pod based on the type and name in the JSON passed into stdin
@@ -1337,7 +1341,7 @@ Show details of a specific resource or group of resources
1337
1341
oc describe pods
1338
1342
1339
1343
# Describe pods by label name=myLabel
1340
- oc describe po -l name=myLabel
1344
+ oc describe pods -l name=myLabel
1341
1345
1342
1346
# Describe all pods managed by the 'frontend' replication controller
1343
1347
# (rc-created pods get the name of the rc as a prefix in the pod name)
@@ -1379,7 +1383,7 @@ Edit a resource on the server
1379
1383
# Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation
1380
1384
oc edit deployment/mydeployment -o yaml --save-config
1381
1385
1382
- # Edit the deployment/mydeployment's status subresource
1386
+ # Edit the ' status' subresource for the 'mydeployment' deployment
1383
1387
oc edit deployment mydeployment --subresource='status'
1384
1388
----
1385
1389
@@ -1391,19 +1395,19 @@ List events
1391
1395
.Example usage
1392
1396
[source,bash,options="nowrap"]
1393
1397
----
1394
- # List recent events in the default namespace.
1398
+ # List recent events in the default namespace
1395
1399
oc events
1396
1400
1397
- # List recent events in all namespaces.
1401
+ # List recent events in all namespaces
1398
1402
oc events --all-namespaces
1399
1403
1400
- # List recent events for the specified pod, then wait for more events and list them as they arrive.
1404
+ # List recent events for the specified pod, then wait for more events and list them as they arrive
1401
1405
oc events --for pod/web-pod-13je7 --watch
1402
1406
1403
- # List recent events in given format. Supported ones, apart from default, are json and yaml.
1407
+ # List recent events in YAML format
1404
1408
oc events -oyaml
1405
1409
1406
- # List recent only events in given event types
1410
+ # List recent only events of type 'Warning' or 'Normal'
1407
1411
oc events --types=Warning,Normal
1408
1412
----
1409
1413
@@ -1450,8 +1454,17 @@ Get documentation for a resource
1450
1454
# Get the documentation of the resource and its fields
1451
1455
oc explain pods
1452
1456
1457
+ # Get all the fields in the resource
1458
+ oc explain pods --recursive
1459
+
1460
+ # Get the explanation for deployment in supported api versions
1461
+ oc explain deployments --api-version=apps/v1
1462
+
1453
1463
# Get the documentation of a specific field of a resource
1454
1464
oc explain pods.spec.containers
1465
+
1466
+ # Get the documentation of resources in different format
1467
+ oc explain deployment --output=plaintext-openapiv2
1455
1468
----
1456
1469
1457
1470
@@ -1544,12 +1557,27 @@ Display one or many resources
1544
1557
# List one or more resources by their type and names
1545
1558
oc get rc/web service/frontend pods/web-pod-13je7
1546
1559
1547
- # List status subresource for a single pod.
1560
+ # List the ' status' subresource for a single pod
1548
1561
oc get pod web-pod-13je7 --subresource status
1549
1562
----
1550
1563
1551
1564
1552
1565
1566
+ == oc get-token
1567
+ Experimental: Get token from external OIDC issuer as credentials exec plugin
1568
+
1569
+ .Example usage
1570
+ [source,bash,options="nowrap"]
1571
+ ----
1572
+ # Starts an auth code flow to the issuer url with the client id and the given extra scopes
1573
+ oc get-token --client-id=client-id --issuer-url=test.issuer.url --extra-scopes=email,profile
1574
+
1575
+ # Starts an authe code flow to the issuer url with a different callback address.
1576
+ oc get-token --client-id=client-id --issuer-url=test.issuer.url --callback-address=127.0.0.1:8343
1577
+ ----
1578
+
1579
+
1580
+
1553
1581
== oc idle
1554
1582
Idle scalable resources
1555
1583
@@ -1728,7 +1756,7 @@ Mirror images from one repository to another
1728
1756
# Note that the target registry may reject a manifest list if the platform specific images do not all
1729
1757
# exist. You must use a registry with sparse registry support enabled.
1730
1758
oc image mirror myregistry.com/myimage:latest=myregistry.com/other:test \
1731
- --filter-by-os=os/arch \
1759
+ --filter-by-os=linux/386 \
1732
1760
--keep-manifest-list=true
1733
1761
----
1734
1762
@@ -1827,6 +1855,9 @@ Log in to a server
1827
1855
1828
1856
# Log in to the given server through a browser
1829
1857
oc login localhost:8443 --web --callback-port 8280
1858
+
1859
+ # Log in to the external OIDC issuer through Auth Code + PKCE by starting a local server listening port 8080
1860
+ oc login localhost:8443 --exec-plugin=oc-oidc --client-id=client-id --extra-scopes=email,profile --callback-port=8080
1830
1861
----
1831
1862
1832
1863
@@ -2018,7 +2049,7 @@ Update fields of a resource
2018
2049
# Update a container's image using a JSON patch with positional arrays
2019
2050
oc patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
2020
2051
2021
- # Update a deployment's replicas through the scale subresource using a merge patch.
2052
+ # Update a deployment's replicas through the ' scale' subresource using a merge patch
2022
2053
oc patch deployment nginx-deployment --subresource='scale' --type='merge' -p '{"spec":{"replicas":2}}'
2023
2054
----
2024
2055
@@ -2209,18 +2240,6 @@ Run a proxy to the Kubernetes API server
2209
2240
2210
2241
2211
2242
2212
- == oc registry info
2213
- Print information about the integrated registry
2214
-
2215
- .Example usage
2216
- [source,bash,options="nowrap"]
2217
- ----
2218
- # Display information about the integrated registry
2219
- oc registry info
2220
- ----
2221
-
2222
-
2223
-
2224
2243
== oc registry login
2225
2244
Log in to the integrated registry
2226
2245
@@ -2499,7 +2518,7 @@ Set a new size for a deployment, replica set, or replication controller
2499
2518
oc scale --current-replicas=2 --replicas=3 deployment/mysql
2500
2519
2501
2520
# Scale multiple replication controllers
2502
- oc scale --replicas=5 rc/foo rc/bar rc/baz
2521
+ oc scale --replicas=5 rc/example1 rc/example2 rc/example3
2503
2522
2504
2523
# Scale stateful set named 'web' to 3
2505
2524
oc scale --replicas=3 statefulset/web
@@ -2981,8 +3000,8 @@ Print the client and server version information
2981
3000
# Print the OpenShift client, kube-apiserver, and openshift-apiserver version information for the current context
2982
3001
oc version
2983
3002
2984
- # Print the OpenShift client, kube-apiserver, and openshift-apiserver version numbers for the current context
2985
- oc version --short
3003
+ # Print the OpenShift client, kube-apiserver, and openshift-apiserver version numbers for the current context in json format
3004
+ oc version --output json
2986
3005
2987
3006
# Print the OpenShift client version information for the current context
2988
3007
oc version --client
@@ -2999,12 +3018,15 @@ Experimental: Wait for a specific condition on one or many resources
2999
3018
# Wait for the pod "busybox1" to contain the status condition of type "Ready"
3000
3019
oc wait --for=condition=Ready pod/busybox1
3001
3020
3002
- # 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):
3021
+ # 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)
3003
3022
oc wait --for=condition=Ready=false pod/busybox1
3004
3023
3005
- # Wait for the pod "busybox1" to contain the status phase to be "Running".
3024
+ # Wait for the pod "busybox1" to contain the status phase to be "Running"
3006
3025
oc wait --for=jsonpath='{.status.phase}'=Running pod/busybox1
3007
3026
3027
+ # Wait for the service "loadbalancer" to have ingress.
3028
+ oc wait --for=jsonpath='{.status.loadBalancer.ingress}' service/loadbalancer
3029
+
3008
3030
# Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command
3009
3031
oc delete pod/busybox1
3010
3032
oc wait --for=delete pod/busybox1 --timeout=60s
@@ -3021,5 +3043,3 @@ Return information about the current session
3021
3043
# Display the currently authenticated user
3022
3044
oc whoami
3023
3045
----
3024
-
3025
-
0 commit comments