Skip to content

Commit 67b8de5

Browse files
authored
Merge pull request #71213 from bergerhoffer/OSDOCS-8476
OSDOCS#8476: Adding CLI docs for 4.15
2 parents 905cbb7 + 18790f5 commit 67b8de5

File tree

2 files changed

+87
-44
lines changed

2 files changed

+87
-44
lines changed

modules/oc-adm-by-example-content.adoc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ Drain node in preparation for maintenance
149149
.Example usage
150150
[source,bash,options="nowrap"]
151151
----
152-
# Drain node "foo", even if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set on it
152+
# Drain node "foo", even if there are pods not managed by a replication controller, replica set, job, daemon set, or stateful set on it
153153
oc adm drain foo --force
154154
155-
# As above, but abort if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set, and use a grace period of 15 minutes
155+
# As above, but abort if there are pods not managed by a replication controller, replica set, job, daemon set, or stateful set, and use a grace period of 15 minutes
156156
oc adm drain foo --grace-period=900
157157
----
158158

@@ -729,6 +729,22 @@ Create a new OpenShift release
729729
== oc adm restart-kubelet
730730
Restarts kubelet on the specified nodes
731731

732+
.Example usage
733+
[source,bash,options="nowrap"]
734+
----
735+
# Restart all the nodes, 10% at a time
736+
oc adm restart-kubelet nodes --all --directive=RemoveKubeletKubeconfig
737+
738+
# Restart all the nodes, 20 nodes at a time
739+
oc adm restart-kubelet nodes --all --parallelism=20 --directive=RemoveKubeletKubeconfig
740+
741+
# Restart all the nodes, 15% at a time
742+
oc adm restart-kubelet nodes --all --parallelism=15% --directive=RemoveKubeletKubeconfig
743+
744+
# Restart all the masters at the same time
745+
oc adm restart-kubelet nodes -l node-role.kubernetes.io/master --parallelism=100% --directive=RemoveKubeletKubeconfig
746+
----
747+
732748

733749

734750
== oc adm taint
@@ -747,7 +763,7 @@ Update the taints on one or more nodes
747763
# Remove from node 'foo' all the taints with key 'dedicated'
748764
oc adm taint nodes foo dedicated-
749765
750-
# Add a taint with key 'dedicated' on nodes having label mylabel=X
766+
# Add a taint with key 'dedicated' on nodes having label myLabel=X
751767
oc adm taint node -l myLabel=X dedicated=foo:PreferNoSchedule
752768
753769
# Add to node 'foo' a taint with key 'bar' and no value
@@ -889,5 +905,12 @@ Wait for nodes to reboot after running `oc adm reboot-machine-config-pool`
889905
== oc adm wait-for-stable-cluster
890906
wait for the platform operators to become stable
891907

908+
.Example usage
909+
[source,bash,options="nowrap"]
910+
----
911+
# Wait for all clusteroperators to become stable
912+
oc adm wait-for-stable-cluster
892913
893-
914+
# Consider operators to be stable if they report as such for 5 minutes straight
915+
oc adm wait-for-stable-cluster --minimum-stable-period 5m
916+
----

modules/oc-by-example-content.adoc

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Apply a configuration to a resource by file name or stdin
9191
# Apply the JSON passed into stdin to a pod
9292
cat pod.json | oc apply -f -
9393
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'
9595
oc apply -f '*.json'
9696
9797
# Note: --prune is still in Alpha
@@ -333,7 +333,7 @@ Output shell completion code for the specified shell (bash, zsh, fish, or powers
333333
## Write bash completion code to a file and source it from .bash_profile
334334
oc completion bash > ~/.kube/completion.bash.inc
335335
printf "
336-
# Kubectl shell completion
336+
# oc shell completion
337337
source '$HOME/.kube/completion.bash.inc'
338338
" >> $HOME/.bash_profile
339339
source $HOME/.bash_profile
@@ -542,10 +542,10 @@ Set a cluster entry in kubeconfig
542542
# Disable cert checking for the e2e cluster entry
543543
oc config set-cluster e2e --insecure-skip-tls-verify=true
544544
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
546546
oc config set-cluster e2e --tls-server-name=my-cluster-name
547547
548-
# Set proxy url for the e2e cluster entry
548+
# Set the proxy URL for the e2e cluster entry
549549
oc config set-cluster e2e --proxy-url=https://1.2.3.4
550550
----
551551

@@ -582,7 +582,7 @@ Set a user entry in kubeconfig
582582
# Enable the Google Compute Platform auth provider for the "cluster-admin" entry
583583
oc config set-credentials cluster-admin --auth-provider=gcp
584584
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
586586
oc config set-credentials cluster-admin --auth-provider=oidc --auth-provider-arg=client-id=foo --auth-provider-arg=client-secret=bar
587587
588588
# 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
591591
# Enable new exec auth plugin for the "cluster-admin" entry
592592
oc config set-credentials cluster-admin --exec-command=/path/to/the/executable --exec-api-version=client.authentication.k8s.io/v1beta1
593593
594-
# Define new exec auth plugin args for the "cluster-admin" entry
594+
# Define new exec auth plugin arguments for the "cluster-admin" entry
595595
oc config set-credentials cluster-admin --exec-arg=arg1 --exec-arg=arg2
596596
597597
# 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
639639
# Show merged kubeconfig settings
640640
oc config view
641641
642-
# Show merged kubeconfig settings and raw certificate data and exposed secrets
642+
# Show merged kubeconfig settings, raw certificate data, and exposed secrets
643643
oc config view --raw
644644
645645
# Get the password for the e2e user
@@ -878,7 +878,7 @@ Create an ingress with the specified name
878878
[source,bash,options="nowrap"]
879879
----
880880
# 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"
882882
oc create ingress simple --rule="foo.com/bar=svc1:8080,tls=my-cert"
883883
884884
# 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
10871087
.Example usage
10881088
[source,bash,options="nowrap"]
10891089
----
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
10911091
oc create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
10921092
10931093
# Create a new secret named my-secret from ~/.docker/config.json
@@ -1216,7 +1216,7 @@ Request a service account token
12161216
# Request a token bound to an instance of a Secret object
12171217
oc create token myapp --bound-object-kind Secret --bound-object-name mysecret
12181218
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
12201220
oc create token myapp --bound-object-kind Secret --bound-object-name mysecret --bound-object-uid 0d4691ed-659b-4935-a832-355f77ee47cc
12211221
----
12221222

@@ -1261,6 +1261,10 @@ Launch a new instance of a pod for debugging
12611261
# Debug a node as an administrator
12621262
oc debug node/master-1
12631263
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+
12641268
# Launch a shell in a pod using the provided image stream tag
12651269
oc debug istag/mysql:latest -n openshift
12661270
@@ -1294,7 +1298,7 @@ Delete resources by file names, stdin, resources and names, or by resources and
12941298
# Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
12951299
oc delete -k dir
12961300
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'
12981302
oc delete -f '*.json'
12991303
13001304
# 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
13371341
oc describe pods
13381342
13391343
# Describe pods by label name=myLabel
1340-
oc describe po -l name=myLabel
1344+
oc describe pods -l name=myLabel
13411345
13421346
# Describe all pods managed by the 'frontend' replication controller
13431347
# (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
13791383
# Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation
13801384
oc edit deployment/mydeployment -o yaml --save-config
13811385
1382-
# Edit the deployment/mydeployment's status subresource
1386+
# Edit the 'status' subresource for the 'mydeployment' deployment
13831387
oc edit deployment mydeployment --subresource='status'
13841388
----
13851389

@@ -1391,19 +1395,19 @@ List events
13911395
.Example usage
13921396
[source,bash,options="nowrap"]
13931397
----
1394-
# List recent events in the default namespace.
1398+
# List recent events in the default namespace
13951399
oc events
13961400
1397-
# List recent events in all namespaces.
1401+
# List recent events in all namespaces
13981402
oc events --all-namespaces
13991403
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
14011405
oc events --for pod/web-pod-13je7 --watch
14021406
1403-
# List recent events in given format. Supported ones, apart from default, are json and yaml.
1407+
# List recent events in YAML format
14041408
oc events -oyaml
14051409
1406-
# List recent only events in given event types
1410+
# List recent only events of type 'Warning' or 'Normal'
14071411
oc events --types=Warning,Normal
14081412
----
14091413

@@ -1450,8 +1454,17 @@ Get documentation for a resource
14501454
# Get the documentation of the resource and its fields
14511455
oc explain pods
14521456
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+
14531463
# Get the documentation of a specific field of a resource
14541464
oc explain pods.spec.containers
1465+
1466+
# Get the documentation of resources in different format
1467+
oc explain deployment --output=plaintext-openapiv2
14551468
----
14561469

14571470

@@ -1544,12 +1557,27 @@ Display one or many resources
15441557
# List one or more resources by their type and names
15451558
oc get rc/web service/frontend pods/web-pod-13je7
15461559
1547-
# List status subresource for a single pod.
1560+
# List the 'status' subresource for a single pod
15481561
oc get pod web-pod-13je7 --subresource status
15491562
----
15501563

15511564

15521565

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+
15531581
== oc idle
15541582
Idle scalable resources
15551583

@@ -1728,7 +1756,7 @@ Mirror images from one repository to another
17281756
# Note that the target registry may reject a manifest list if the platform specific images do not all
17291757
# exist. You must use a registry with sparse registry support enabled.
17301758
oc image mirror myregistry.com/myimage:latest=myregistry.com/other:test \
1731-
--filter-by-os=os/arch \
1759+
--filter-by-os=linux/386 \
17321760
--keep-manifest-list=true
17331761
----
17341762

@@ -1827,6 +1855,9 @@ Log in to a server
18271855
18281856
# Log in to the given server through a browser
18291857
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
18301861
----
18311862

18321863

@@ -2018,7 +2049,7 @@ Update fields of a resource
20182049
# Update a container's image using a JSON patch with positional arrays
20192050
oc patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
20202051
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
20222053
oc patch deployment nginx-deployment --subresource='scale' --type='merge' -p '{"spec":{"replicas":2}}'
20232054
----
20242055

@@ -2209,18 +2240,6 @@ Run a proxy to the Kubernetes API server
22092240

22102241

22112242

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-
22242243
== oc registry login
22252244
Log in to the integrated registry
22262245

@@ -2499,7 +2518,7 @@ Set a new size for a deployment, replica set, or replication controller
24992518
oc scale --current-replicas=2 --replicas=3 deployment/mysql
25002519
25012520
# 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
25032522
25042523
# Scale stateful set named 'web' to 3
25052524
oc scale --replicas=3 statefulset/web
@@ -2981,8 +3000,8 @@ Print the client and server version information
29813000
# Print the OpenShift client, kube-apiserver, and openshift-apiserver version information for the current context
29823001
oc version
29833002
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
29863005
29873006
# Print the OpenShift client version information for the current context
29883007
oc version --client
@@ -2999,12 +3018,15 @@ Experimental: Wait for a specific condition on one or many resources
29993018
# Wait for the pod "busybox1" to contain the status condition of type "Ready"
30003019
oc wait --for=condition=Ready pod/busybox1
30013020
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)
30033022
oc wait --for=condition=Ready=false pod/busybox1
30043023
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"
30063025
oc wait --for=jsonpath='{.status.phase}'=Running pod/busybox1
30073026
3027+
# Wait for the service "loadbalancer" to have ingress.
3028+
oc wait --for=jsonpath='{.status.loadBalancer.ingress}' service/loadbalancer
3029+
30083030
# Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command
30093031
oc delete pod/busybox1
30103032
oc wait --for=delete pod/busybox1 --timeout=60s
@@ -3021,5 +3043,3 @@ Return information about the current session
30213043
# Display the currently authenticated user
30223044
oc whoami
30233045
----
3024-
3025-

0 commit comments

Comments
 (0)