diff --git a/modules/oc-adm-by-example-content.adoc b/modules/oc-adm-by-example-content.adoc index 738698cffe..ea295d6135 100644 --- a/modules/oc-adm-by-example-content.adoc +++ b/modules/oc-adm-by-example-content.adoc @@ -54,6 +54,30 @@ Mirror an operator-registry catalog +== oc adm certificate approve +Approve a certificate signing request + +.Example usage +[source,bash,options="nowrap"] +---- + # Approve CSR 'csr-sqgzp' + kubectl certificate approve csr-sqgzp +---- + + + +== oc adm certificate deny +Deny a certificate signing request + +.Example usage +[source,bash,options="nowrap"] +---- + # Deny CSR 'csr-sqgzp' + kubectl certificate deny csr-sqgzp +---- + + + == oc adm completion Output shell completion code for the specified shell (bash or zsh) @@ -65,13 +89,13 @@ Output shell completion code for the specified shell (bash or zsh) brew install bash-completion ## or, if running Bash 4.1+ brew install bash-completion@2 - ## If oc is installed via homebrew, this should start working immediately. + ## If oc is installed via homebrew, this should start working immediately ## If you've installed via other means, you may need add the completion to your completion directory oc completion bash > $(brew --prefix)/etc/bash_completion.d/oc # Installing bash completion on Linux - ## If bash-completion is not installed on Linux, please install the 'bash-completion' package + ## If bash-completion is not installed on Linux, install the 'bash-completion' package ## via your distribution's package manager. ## Load the oc completion code for bash into the current shell source <(oc completion bash) @@ -92,7 +116,7 @@ Output shell completion code for the specified shell (bash or zsh) == oc adm config current-context -Displays the current-context +Display the current-context .Example usage [source,bash,options="nowrap"] @@ -145,7 +169,7 @@ Display clusters defined in the kubeconfig .Example usage [source,bash,options="nowrap"] ---- - # List the clusters oc knows about + # List the clusters that oc knows about oc config get-clusters ---- @@ -160,7 +184,7 @@ Describe one or many contexts # List all the contexts in your kubeconfig file oc config get-contexts - # Describe one context in your kubeconfig file. + # Describe one context in your kubeconfig file oc config get-contexts my-context ---- @@ -172,14 +196,14 @@ Display users defined in the kubeconfig .Example usage [source,bash,options="nowrap"] ---- - # List the users oc knows about + # List the users that oc knows about oc config get-users ---- == oc adm config rename-context -Renames a context from the kubeconfig file. +Rename a context from the kubeconfig file .Example usage [source,bash,options="nowrap"] @@ -191,33 +215,33 @@ Renames a context from the kubeconfig file. == oc adm config set -Sets an individual value in a kubeconfig file +Set an individual value in a kubeconfig file .Example usage [source,bash,options="nowrap"] ---- - # Set server field on the my-cluster cluster to https://1.2.3.4 + # Set the server field on the my-cluster cluster to https://1.2.3.4 oc config set clusters.my-cluster.server https://1.2.3.4 - # Set certificate-authority-data field on the my-cluster cluster. + # Set the certificate-authority-data field on the my-cluster cluster oc config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -) - # Set cluster field in the my-context context to my-cluster. + # Set the cluster field in the my-context context to my-cluster oc config set contexts.my-context.cluster my-cluster - # Set client-key-data field in the cluster-admin user using --set-raw-bytes option. + # Set the client-key-data field in the cluster-admin user using --set-raw-bytes option oc config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true ---- == oc adm config set-cluster -Sets a cluster entry in kubeconfig +Set a cluster entry in kubeconfig .Example usage [source,bash,options="nowrap"] ---- - # Set only the server field on the e2e cluster entry without touching other values. + # Set only the server field on the e2e cluster entry without touching other values oc config set-cluster e2e --server=https://1.2.3.4 # Embed certificate authority data for the e2e cluster entry @@ -233,7 +257,7 @@ Sets a cluster entry in kubeconfig == oc adm config set-context -Sets a context entry in kubeconfig +Set a context entry in kubeconfig .Example usage [source,bash,options="nowrap"] @@ -245,13 +269,13 @@ Sets a context entry in kubeconfig == oc adm config set-credentials -Sets a user entry in kubeconfig +Set a user entry in kubeconfig .Example usage [source,bash,options="nowrap"] ---- # Set only the "client-key" field on the "cluster-admin" - # entry, without touching other values: + # entry, without touching other values oc config set-credentials cluster-admin --client-key=~/.kube/admin.key # Set basic auth for the "cluster-admin" entry @@ -285,22 +309,22 @@ Sets a user entry in kubeconfig == oc adm config unset -Unsets an individual value in a kubeconfig file +Unset an individual value in a kubeconfig file .Example usage [source,bash,options="nowrap"] ---- - # Unset the current-context. + # Unset the current-context oc config unset current-context - # Unset namespace in foo context. + # Unset namespace in foo context oc config unset contexts.foo.namespace ---- == oc adm config use-context -Sets the current-context in a kubeconfig file +Set the current-context in a kubeconfig file .Example usage [source,bash,options="nowrap"] @@ -317,10 +341,10 @@ Display merged kubeconfig settings or a specified kubeconfig file .Example usage [source,bash,options="nowrap"] ---- - # Show merged kubeconfig settings. + # Show merged kubeconfig settings oc config view - # Show merged kubeconfig settings and raw certificate data. + # Show merged kubeconfig settings and raw certificate data oc config view --raw # Get the password for the e2e user @@ -335,7 +359,7 @@ Mark node as unschedulable .Example usage [source,bash,options="nowrap"] ---- - # Mark node "foo" as unschedulable. + # Mark node "foo" as unschedulable oc adm cordon foo ---- @@ -395,11 +419,11 @@ Drain node in preparation for maintenance .Example usage [source,bash,options="nowrap"] ---- - # Drain node "foo", even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet on it. - $ oc adm drain foo --force + # Drain node "foo", even if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set on it + oc adm drain foo --force - # As above, but abort if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet, and use a grace period of 15 minutes. - $ oc adm drain foo --grace-period=900 + # 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 + oc adm drain foo --grace-period=900 ---- @@ -782,7 +806,7 @@ Remove unreferenced images # To actually perform the prune operation, the confirm flag must be appended oc adm prune images --prune-over-size-limit --confirm - + # Force the insecure http protocol with the particular registry host name oc adm prune images --registry-url=http://registry.example.org --confirm @@ -885,11 +909,11 @@ Update the taints on one or more nodes .Example usage [source,bash,options="nowrap"] ---- - # Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'. - # If a taint with that key and effect already exists, its value is replaced as specified. + # Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule' + # If a taint with that key and effect already exists, its value is replaced as specified oc adm taint nodes foo dedicated=special-user:NoSchedule - # Remove from node 'foo' the taint with key 'dedicated' and effect 'NoSchedule' if one exists. + # Remove from node 'foo' the taint with key 'dedicated' and effect 'NoSchedule' if one exists oc adm taint nodes foo dedicated:NoSchedule- # Remove from node 'foo' all the taints with key 'dedicated' @@ -929,7 +953,7 @@ Show usage statistics for image streams == oc adm top node -Display Resource (CPU/Memory) usage of nodes +Display resource (CPU/memory) usage of nodes .Example usage [source,bash,options="nowrap"] @@ -944,7 +968,7 @@ Display Resource (CPU/Memory) usage of nodes == oc adm top pod -Display Resource (CPU/Memory) usage of pods +Display resource (CPU/memory) usage of pods .Example usage [source,bash,options="nowrap"] @@ -970,8 +994,8 @@ Mark node as schedulable .Example usage [source,bash,options="nowrap"] ---- - # Mark node "foo" as schedulable. - $ oc adm uncordon foo + # Mark node "foo" as schedulable + oc adm uncordon foo ---- diff --git a/modules/oc-by-example-content.adoc b/modules/oc-by-example-content.adoc index e32af6437e..025df29374 100644 --- a/modules/oc-by-example-content.adoc +++ b/modules/oc-by-example-content.adoc @@ -13,24 +13,24 @@ Update the annotations on a resource .Example usage [source,bash,options="nowrap"] ---- - # Update pod 'foo' with the annotation 'description' and the value 'my frontend'. + # Update pod 'foo' with the annotation 'description' and the value 'my frontend' # If the same annotation is set multiple times, only the last value will be applied oc annotate pods foo description='my frontend' # Update a pod identified by type and name in "pod.json" oc annotate -f pod.json description='my frontend' - # Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', overwriting any existing value. + # Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', overwriting any existing value oc annotate --overwrite pods foo description='my frontend running nginx' # Update all pods in the namespace oc annotate pods --all description='my frontend running nginx' - # Update pod 'foo' only if the resource is unchanged from version 1. + # Update pod 'foo' only if the resource is unchanged from version 1 oc annotate pods foo description='my frontend running nginx' --resource-version=1 - # Update pod 'foo' by removing an annotation named 'description' if it exists. - # Does not require the --overwrite flag. + # Update pod 'foo' by removing an annotation named 'description' if it exists + # Does not require the --overwrite flag oc annotate pods foo description- ---- @@ -42,13 +42,13 @@ Print the supported API resources on the server .Example usage [source,bash,options="nowrap"] ---- - # Print the supported API Resources + # Print the supported API resources oc api-resources - # Print the supported API Resources with more information + # Print the supported API resources with more information oc api-resources -o wide - # Print the supported API Resources sorted by a column + # Print the supported API resources sorted by a column oc api-resources --sort-by=name # Print the supported namespaced resources @@ -57,7 +57,7 @@ Print the supported API resources on the server # Print the supported non-namespaced resources oc api-resources --namespaced=false - # Print the supported API Resources with specific APIGroup + # Print the supported API resources with a specific APIGroup oc api-resources --api-group=extensions ---- @@ -76,25 +76,25 @@ Print the supported API versions on the server, in the form of "group/version" == oc apply -Apply a configuration to a resource by filename or stdin +Apply a configuration to a resource by file name or stdin .Example usage [source,bash,options="nowrap"] ---- - # Apply the configuration in pod.json to a pod. + # Apply the configuration in pod.json to a pod oc apply -f ./pod.json - # Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml. + # Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml oc apply -k dir/ - # Apply the JSON passed into stdin to a pod. + # Apply the JSON passed into stdin to a pod cat pod.json | oc apply -f - # Note: --prune is still in Alpha - # Apply the configuration in manifest.yaml that matches label app=nginx and delete all the other resources that are not in the file and match label app=nginx. + # 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 oc apply --prune -f manifest.yaml -l app=nginx - # Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file. + # Apply the configuration in manifest.yaml and delete all the other config maps that are not in the file oc apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap ---- @@ -106,40 +106,40 @@ Edit latest last-applied-configuration annotations of a resource/object .Example usage [source,bash,options="nowrap"] ---- - # Edit the last-applied-configuration annotations by type/name in YAML. + # Edit the last-applied-configuration annotations by type/name in YAML oc apply edit-last-applied deployment/nginx - # Edit the last-applied-configuration annotations by file in JSON. + # Edit the last-applied-configuration annotations by file in JSON oc apply edit-last-applied -f deploy.yaml -o json ---- == oc apply set-last-applied -Set the last-applied-configuration annotation on a live object to match the contents of a file. +Set the last-applied-configuration annotation on a live object to match the contents of a file .Example usage [source,bash,options="nowrap"] ---- - # Set the last-applied-configuration of a resource to match the contents of a file. + # Set the last-applied-configuration of a resource to match the contents of a file oc apply set-last-applied -f deploy.yaml - # Execute set-last-applied against each configuration file in a directory. + # Execute set-last-applied against each configuration file in a directory oc apply set-last-applied -f path/ - # Set the last-applied-configuration of a resource to match the contents of a file, will create the annotation if it does not already exist. + # Set the last-applied-configuration of a resource to match the contents of a file; will create the annotation if it does not already exist oc apply set-last-applied -f deploy.yaml --create-annotation=true ---- == oc apply view-last-applied -View latest last-applied-configuration annotations of a resource/object +View the latest last-applied-configuration annotations of a resource/object .Example usage [source,bash,options="nowrap"] ---- - # View the last-applied-configuration annotations by type/name in YAML. + # View the last-applied-configuration annotations by type/name in YAML oc apply view-last-applied deployment/nginx # View the last-applied-configuration annotations by file in JSON @@ -154,18 +154,18 @@ Attach to a running container .Example usage [source,bash,options="nowrap"] ---- - # Get output from running pod mypod, use the oc.kubernetes.io/default-container annotation + # Get output from running pod mypod; use the 'oc.kubernetes.io/default-container' annotation # for selecting the container to be attached or the first container in the pod will be chosen oc attach mypod # Get output from ruby-container from pod mypod oc attach mypod -c ruby-container - # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod mypod + # Switch to raw terminal mode; sends stdin to 'bash' in ruby-container from pod mypod # and sends stdout/stderr from 'bash' back to the client oc attach mypod -c ruby-container -i -t - # Get output from the first pod of a ReplicaSet named nginx + # Get output from the first pod of a replica set named nginx oc attach rs/nginx ---- @@ -202,12 +202,12 @@ Check whether an action is allowed == oc auth reconcile -Reconciles rules for RBAC Role, RoleBinding, ClusterRole, and ClusterRoleBinding objects +Reconciles rules for RBAC role, role binding, cluster role, and cluster role binding objects .Example usage [source,bash,options="nowrap"] ---- - # Reconcile rbac resources from a file + # Reconcile RBAC resources from a file oc auth reconcile -f my-rbac-rules.yaml ---- @@ -219,10 +219,10 @@ Autoscale a deployment config, deployment, replica set, stateful set, or replica .Example usage [source,bash,options="nowrap"] ---- - # Auto scale a deployment "foo", with the number of pods between 2 and 10, no target CPU utilization specified so a default autoscaling policy will be used: + # Auto scale a deployment "foo", with the number of pods between 2 and 10, no target CPU utilization specified so a default autoscaling policy will be used oc autoscale deployment foo --min=2 --max=10 - # Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%: + # Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80% oc autoscale rc foo --max=5 --cpu-percent=80 ---- @@ -253,7 +253,7 @@ Cancel running, pending, or new builds == oc cluster-info -Display cluster info +Display cluster information .Example usage [source,bash,options="nowrap"] @@ -265,7 +265,7 @@ Display cluster info == oc cluster-info dump -Dump lots of relevant info for debugging and diagnosis +Dump relevant information for debugging and diagnosis .Example usage [source,bash,options="nowrap"] @@ -296,13 +296,13 @@ Output shell completion code for the specified shell (bash or zsh) brew install bash-completion ## or, if running Bash 4.1+ brew install bash-completion@2 - ## If oc is installed via homebrew, this should start working immediately. + ## If oc is installed via homebrew, this should start working immediately ## If you've installed via other means, you may need add the completion to your completion directory oc completion bash > $(brew --prefix)/etc/bash_completion.d/oc # Installing bash completion on Linux - ## If bash-completion is not installed on Linux, please install the 'bash-completion' package + ## If bash-completion is not installed on Linux, install the 'bash-completion' package ## via your distribution's package manager. ## Load the oc completion code for bash into the current shell source <(oc completion bash) @@ -323,7 +323,7 @@ Output shell completion code for the specified shell (bash or zsh) == oc config current-context -Displays the current-context +Display the current-context .Example usage [source,bash,options="nowrap"] @@ -376,7 +376,7 @@ Display clusters defined in the kubeconfig .Example usage [source,bash,options="nowrap"] ---- - # List the clusters oc knows about + # List the clusters that oc knows about oc config get-clusters ---- @@ -391,7 +391,7 @@ Describe one or many contexts # List all the contexts in your kubeconfig file oc config get-contexts - # Describe one context in your kubeconfig file. + # Describe one context in your kubeconfig file oc config get-contexts my-context ---- @@ -403,14 +403,14 @@ Display users defined in the kubeconfig .Example usage [source,bash,options="nowrap"] ---- - # List the users oc knows about + # List the users that oc knows about oc config get-users ---- == oc config rename-context -Renames a context from the kubeconfig file. +Rename a context from the kubeconfig file .Example usage [source,bash,options="nowrap"] @@ -422,33 +422,33 @@ Renames a context from the kubeconfig file. == oc config set -Sets an individual value in a kubeconfig file +Set an individual value in a kubeconfig file .Example usage [source,bash,options="nowrap"] ---- - # Set server field on the my-cluster cluster to https://1.2.3.4 + # Set the server field on the my-cluster cluster to https://1.2.3.4 oc config set clusters.my-cluster.server https://1.2.3.4 - # Set certificate-authority-data field on the my-cluster cluster. + # Set the certificate-authority-data field on the my-cluster cluster oc config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -) - # Set cluster field in the my-context context to my-cluster. + # Set the cluster field in the my-context context to my-cluster oc config set contexts.my-context.cluster my-cluster - # Set client-key-data field in the cluster-admin user using --set-raw-bytes option. + # Set the client-key-data field in the cluster-admin user using --set-raw-bytes option oc config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true ---- == oc config set-cluster -Sets a cluster entry in kubeconfig +Set a cluster entry in kubeconfig .Example usage [source,bash,options="nowrap"] ---- - # Set only the server field on the e2e cluster entry without touching other values. + # Set only the server field on the e2e cluster entry without touching other values oc config set-cluster e2e --server=https://1.2.3.4 # Embed certificate authority data for the e2e cluster entry @@ -464,7 +464,7 @@ Sets a cluster entry in kubeconfig == oc config set-context -Sets a context entry in kubeconfig +Set a context entry in kubeconfig .Example usage [source,bash,options="nowrap"] @@ -476,13 +476,13 @@ Sets a context entry in kubeconfig == oc config set-credentials -Sets a user entry in kubeconfig +Set a user entry in kubeconfig .Example usage [source,bash,options="nowrap"] ---- # Set only the "client-key" field on the "cluster-admin" - # entry, without touching other values: + # entry, without touching other values oc config set-credentials cluster-admin --client-key=~/.kube/admin.key # Set basic auth for the "cluster-admin" entry @@ -516,22 +516,22 @@ Sets a user entry in kubeconfig == oc config unset -Unsets an individual value in a kubeconfig file +Unset an individual value in a kubeconfig file .Example usage [source,bash,options="nowrap"] ---- - # Unset the current-context. + # Unset the current-context oc config unset current-context - # Unset namespace in foo context. + # Unset namespace in foo context oc config unset contexts.foo.namespace ---- == oc config use-context -Sets the current-context in a kubeconfig file +Set the current-context in a kubeconfig file .Example usage [source,bash,options="nowrap"] @@ -548,10 +548,10 @@ Display merged kubeconfig settings or a specified kubeconfig file .Example usage [source,bash,options="nowrap"] ---- - # Show merged kubeconfig settings. + # Show merged kubeconfig settings oc config view - # Show merged kubeconfig settings and raw certificate data. + # Show merged kubeconfig settings and raw certificate data oc config view --raw # Get the password for the e2e user @@ -561,7 +561,7 @@ Display merged kubeconfig settings or a specified kubeconfig file == oc cp -Copy files and directories to and from containers. +Copy files and directories to and from containers .Example usage [source,bash,options="nowrap"] @@ -571,7 +571,7 @@ Copy files and directories to and from containers. # image. If 'tar' is not present, 'oc cp' will fail. # # For advanced use cases, such as symlinks, wildcard expansion or - # file mode preservation consider using 'oc exec'. + # file mode preservation, consider using 'oc exec'. # Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace tar cf - /tmp/foo | oc exec -i -n -- tar xf - -C /tmp/bar @@ -595,18 +595,18 @@ Copy files and directories to and from containers. == oc create -Create a resource from a file or from stdin. +Create a resource from a file or from stdin .Example usage [source,bash,options="nowrap"] ---- - # Create a pod using the data in pod.json. + # Create a pod using the data in pod.json oc create -f ./pod.json - # Create a pod based on the JSON passed into stdin. + # Create a pod based on the JSON passed into stdin cat pod.json | oc create -f - - # Edit the data in docker-registry.yaml in JSON then create the resource using the edited data. + # Edit the data in docker-registry.yaml in JSON then create the resource using the edited data oc create -f docker-registry.yaml --edit -o json ---- @@ -637,99 +637,99 @@ Create a cluster resource quota == oc create clusterrole -Create a ClusterRole. +Create a cluster role .Example usage [source,bash,options="nowrap"] ---- - # Create a ClusterRole named "pod-reader" that allows user to perform "get", "watch" and "list" on pods + # Create a cluster role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods oc create clusterrole pod-reader --verb=get,list,watch --resource=pods - # Create a ClusterRole named "pod-reader" with ResourceName specified + # Create a cluster role named "pod-reader" with ResourceName specified oc create clusterrole pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod - # Create a ClusterRole named "foo" with API Group specified + # Create a cluster role named "foo" with API Group specified oc create clusterrole foo --verb=get,list,watch --resource=rs.extensions - # Create a ClusterRole named "foo" with SubResource specified + # Create a cluster role named "foo" with SubResource specified oc create clusterrole foo --verb=get,list,watch --resource=pods,pods/status - # Create a ClusterRole name "foo" with NonResourceURL specified + # Create a cluster role name "foo" with NonResourceURL specified oc create clusterrole "foo" --verb=get --non-resource-url=/logs/* - # Create a ClusterRole name "monitoring" with AggregationRule specified + # Create a cluster role name "monitoring" with AggregationRule specified oc create clusterrole monitoring --aggregation-rule="rbac.example.com/aggregate-to-monitoring=true" ---- == oc create clusterrolebinding -Create a ClusterRoleBinding for a particular ClusterRole +Create a cluster role binding for a particular cluster role .Example usage [source,bash,options="nowrap"] ---- - # Create a ClusterRoleBinding for user1, user2, and group1 using the cluster-admin ClusterRole + # Create a cluster role binding for user1, user2, and group1 using the cluster-admin cluster role oc create clusterrolebinding cluster-admin --clusterrole=cluster-admin --user=user1 --user=user2 --group=group1 ---- == oc create configmap -Create a configmap from a local file, directory or literal value +Create a config map from a local file, directory or literal value .Example usage [source,bash,options="nowrap"] ---- - # Create a new configmap named my-config based on folder bar + # Create a new config map named my-config based on folder bar oc create configmap my-config --from-file=path/to/bar - # Create a new configmap named my-config with specified keys instead of file basenames on disk + # Create a new config map named my-config with specified keys instead of file basenames on disk oc create configmap my-config --from-file=key1=/path/to/bar/file1.txt --from-file=key2=/path/to/bar/file2.txt - # Create a new configmap named my-config with key1=config1 and key2=config2 + # Create a new config map named my-config with key1=config1 and key2=config2 oc create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2 - # Create a new configmap named my-config from the key=value pairs in the file + # Create a new config map named my-config from the key=value pairs in the file oc create configmap my-config --from-file=path/to/bar - # Create a new configmap named my-config from an env file + # Create a new config map named my-config from an env file oc create configmap my-config --from-env-file=path/to/bar.env ---- == oc create cronjob -Create a cronjob with the specified name. +Create a cron job with the specified name .Example usage [source,bash,options="nowrap"] ---- - # Create a cronjob + # Create a cron job oc create cronjob my-job --image=busybox --schedule="*/1 * * * *" - # Create a cronjob with command + # Create a cron job with a command oc create cronjob my-job --image=busybox --schedule="*/1 * * * *" -- date ---- == oc create deployment -Create a deployment with the specified name. +Create a deployment with the specified name .Example usage [source,bash,options="nowrap"] ---- - # Create a deployment named my-dep that runs the busybox image. + # Create a deployment named my-dep that runs the busybox image oc create deployment my-dep --image=busybox - # Create a deployment with command + # Create a deployment with a command oc create deployment my-dep --image=busybox -- date - # Create a deployment named my-dep that runs the nginx image with 3 replicas. + # Create a deployment named my-dep that runs the nginx image with 3 replicas oc create deployment my-dep --image=nginx --replicas=3 - # Create a deployment named my-dep that runs the busybox image and expose port 5701. + # Create a deployment named my-dep that runs the busybox image and expose port 5701 oc create deployment my-dep --image=busybox --port=5701 ---- @@ -784,7 +784,7 @@ Create a new image stream tag == oc create ingress -Create an ingress with the specified name. +Create an ingress with the specified name .Example usage [source,bash,options="nowrap"] @@ -829,7 +829,7 @@ Create an ingress with the specified name. == oc create job -Create a job with the specified name. +Create a job with the specified name .Example usage [source,bash,options="nowrap"] @@ -837,10 +837,10 @@ Create a job with the specified name. # Create a job oc create job my-job --image=busybox - # Create a job with command + # Create a job with a command oc create job my-job --image=busybox -- date - # Create a job from a CronJob named "a-cronjob" + # Create a job from a cron job named "a-cronjob" oc create job test-job --from=cronjob/a-cronjob ---- @@ -859,83 +859,83 @@ Create a namespace with the specified name == oc create poddisruptionbudget -Create a pod disruption budget with the specified name. +Create a pod disruption budget with the specified name .Example usage [source,bash,options="nowrap"] ---- # Create a pod disruption budget named my-pdb that will select all pods with the app=rails label - # and require at least one of them being available at any point in time. + # and require at least one of them being available at any point in time oc create poddisruptionbudget my-pdb --selector=app=rails --min-available=1 # Create a pod disruption budget named my-pdb that will select all pods with the app=nginx label - # and require at least half of the pods selected to be available at any point in time. + # and require at least half of the pods selected to be available at any point in time oc create pdb my-pdb --selector=app=nginx --min-available=50% ---- == oc create priorityclass -Create a priorityclass with the specified name. +Create a priority class with the specified name .Example usage [source,bash,options="nowrap"] ---- - # Create a priorityclass named high-priority + # Create a priority class named high-priority oc create priorityclass high-priority --value=1000 --description="high priority" - # Create a priorityclass named default-priority that considered as the global default priority + # Create a priority class named default-priority that is considered as the global default priority oc create priorityclass default-priority --value=1000 --global-default=true --description="default priority" - # Create a priorityclass named high-priority that can not preempt pods with lower priority + # Create a priority class named high-priority that cannot preempt pods with lower priority oc create priorityclass high-priority --value=1000 --description="high priority" --preemption-policy="Never" ---- == oc create quota -Create a quota with the specified name. +Create a quota with the specified name .Example usage [source,bash,options="nowrap"] ---- - # Create a new resourcequota named my-quota + # Create a new resource quota named my-quota oc create quota my-quota --hard=cpu=1,memory=1G,pods=2,services=3,replicationcontrollers=2,resourcequotas=1,secrets=5,persistentvolumeclaims=10 - # Create a new resourcequota named best-effort + # Create a new resource quota named best-effort oc create quota best-effort --hard=pods=100 --scopes=BestEffort ---- == oc create role -Create a role with single rule. +Create a role with single rule .Example usage [source,bash,options="nowrap"] ---- - # Create a Role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods + # Create a role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods oc create role pod-reader --verb=get --verb=list --verb=watch --resource=pods - # Create a Role named "pod-reader" with ResourceName specified + # Create a role named "pod-reader" with ResourceName specified oc create role pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod - # Create a Role named "foo" with API Group specified + # Create a role named "foo" with API Group specified oc create role foo --verb=get,list,watch --resource=rs.extensions - # Create a Role named "foo" with SubResource specified + # Create a role named "foo" with SubResource specified oc create role foo --verb=get,list,watch --resource=pods,pods/status ---- == oc create rolebinding -Create a RoleBinding for a particular Role or ClusterRole +Create a role binding for a particular role or cluster role .Example usage [source,bash,options="nowrap"] ---- - # Create a RoleBinding for user1, user2, and group1 using the admin ClusterRole + # Create a role binding for user1, user2, and group1 using the admin cluster role oc create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1 ---- @@ -1006,7 +1006,7 @@ Create a secret for use with a Docker registry == oc create secret generic -Create a secret from a local file, directory or literal value +Create a secret from a local file, directory, or literal value .Example usage [source,bash,options="nowrap"] @@ -1035,14 +1035,14 @@ Create a TLS secret .Example usage [source,bash,options="nowrap"] ---- - # Create a new TLS secret named tls-secret with the given key pair: + # Create a new TLS secret named tls-secret with the given key pair oc create secret tls tls-secret --cert=path/to/tls.cert --key=path/to/tls.key ---- == oc create service clusterip -Create a ClusterIP service. +Create a ClusterIP service .Example usage [source,bash,options="nowrap"] @@ -1057,7 +1057,7 @@ Create a ClusterIP service. == oc create service externalname -Create an ExternalName service. +Create an ExternalName service .Example usage [source,bash,options="nowrap"] @@ -1069,7 +1069,7 @@ Create an ExternalName service. == oc create service loadbalancer -Create a LoadBalancer service. +Create a LoadBalancer service .Example usage [source,bash,options="nowrap"] @@ -1081,7 +1081,7 @@ Create a LoadBalancer service. == oc create service nodeport -Create a NodePort service. +Create a NodePort service .Example usage [source,bash,options="nowrap"] @@ -1165,24 +1165,24 @@ Launch a new instance of a pod for debugging == oc delete -Delete resources by filenames, stdin, resources and names, or by resources and label selector +Delete resources by file names, stdin, resources and names, or by resources and label selector .Example usage [source,bash,options="nowrap"] ---- - # Delete a pod using the type and name specified in pod.json. + # Delete a pod using the type and name specified in pod.json oc delete -f ./pod.json - # Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml. + # Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml oc delete -k dir - # Delete a pod based on the type and name in the JSON passed into stdin. + # Delete a pod based on the type and name in the JSON passed into stdin cat pod.json | oc delete -f - # Delete pods and services with same names "baz" and "foo" oc delete pod,service baz foo - # Delete pods and services with label name=myLabel. + # Delete pods and services with label name=myLabel oc delete pods,services -l name=myLabel # Delete a pod with minimal delay @@ -1219,19 +1219,19 @@ Show details of a specific resource or group of resources oc describe po -l name=myLabel # Describe all pods managed by the 'frontend' replication controller (rc-created pods - # get the name of the rc as a prefix in the pod the name). + # get the name of the rc as a prefix in the pod the name) oc describe pods frontend ---- == oc diff -Diff live version against would-be applied version +Diff the live version against a would-be applied version .Example usage [source,bash,options="nowrap"] ---- - # Diff resources included in pod.json. + # Diff resources included in pod.json oc diff -f pod.json # Diff file read from stdin @@ -1246,16 +1246,16 @@ Edit a resource on the server .Example usage [source,bash,options="nowrap"] ---- - # Edit the service named 'docker-registry': + # Edit the service named 'docker-registry' oc edit svc/docker-registry # Use an alternative editor KUBE_EDITOR="nano" oc edit svc/docker-registry - # Edit the job 'myjob' in JSON using the v1 API format: + # Edit the job 'myjob' in JSON using the v1 API format oc edit job.v1.batch/myjob -o json - # Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation: + # Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation oc edit deployment/mydeployment -o yaml --save-config ---- @@ -1279,21 +1279,21 @@ Execute a command in a container .Example usage [source,bash,options="nowrap"] ---- - # Get output from running 'date' command from pod mypod, using the first container by default + # Get output from running the 'date' command from pod mypod, using the first container by default oc exec mypod -- date - # Get output from running 'date' command in ruby-container from pod mypod + # Get output from running the 'date' command in ruby-container from pod mypod oc exec mypod -c ruby-container -- date - # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod mypod + # Switch to raw terminal mode; sends stdin to 'bash' in ruby-container from pod mypod # and sends stdout/stderr from 'bash' back to the client oc exec mypod -c ruby-container -i -t -- bash -il - # List contents of /usr from the first container of pod mypod and sort by modification time. + # List contents of /usr from the first container of pod mypod and sort by modification time # If the command you want to execute in the pod has any flags in common (e.g. -i), - # you must use two dashes (--) to separate your command's flags/arguments. + # you must use two dashes (--) to separate your command's flags/arguments # Also note, do not surround your command and its flags/arguments with quotes - # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr"). + # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr") oc exec mypod -i -t -- ls -t /usr # Get output from running 'date' command from the first pod of the deployment mydeployment, using the first container by default @@ -1306,7 +1306,7 @@ Execute a command in a container == oc explain -Documentation of resources +Get documentation for a resource .Example usage [source,bash,options="nowrap"] @@ -1382,37 +1382,37 @@ Display one or many resources .Example usage [source,bash,options="nowrap"] ---- - # List all pods in ps output format. + # List all pods in ps output format oc get pods - # List all pods in ps output format with more information (such as node name). + # List all pods in ps output format with more information (such as node name) oc get pods -o wide - # List a single replication controller with specified NAME in ps output format. + # List a single replication controller with specified NAME in ps output format oc get replicationcontroller web - # List deployments in JSON output format, in the "v1" version of the "apps" API group: + # List deployments in JSON output format, in the "v1" version of the "apps" API group oc get deployments.v1.apps -o json - # List a single pod in JSON output format. + # List a single pod in JSON output format oc get -o json pod web-pod-13je7 - # List a pod identified by type and name specified in "pod.yaml" in JSON output format. + # List a pod identified by type and name specified in "pod.yaml" in JSON output format oc get -f pod.yaml -o json - # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml. + # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml oc get -k dir/ - # Return only the phase value of the specified pod. + # Return only the phase value of the specified pod oc get -o template pod/web-pod-13je7 --template={{.status.phase}} - # List resource information in custom columns. + # List resource information in custom columns oc get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image - # List all replication controllers and services together in ps output format. + # List all replication controllers and services together in ps output format oc get rc,services - # List one or more resources by their type and names. + # List one or more resources by their type and names oc get rc/web service/frontend pods/web-pod-13je7 ---- @@ -1639,10 +1639,10 @@ Update the labels on a resource .Example usage [source,bash,options="nowrap"] ---- - # Update pod 'foo' with the label 'unhealthy' and the value 'true'. + # Update pod 'foo' with the label 'unhealthy' and the value 'true' oc label pods foo unhealthy=true - # Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value. + # Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value oc label --overwrite pods foo status=unhealthy # Update all pods in the namespace @@ -1651,11 +1651,11 @@ Update the labels on a resource # Update a pod identified by the type and name in "pod.json" oc label -f pod.json status=unhealthy - # Update pod 'foo' only if the resource is unchanged from version 1. + # Update pod 'foo' only if the resource is unchanged from version 1 oc label pods foo status=unhealthy --resource-version=1 - # Update pod 'foo' by removing a label named 'bar' if it exists. - # Does not require the --overwrite flag. + # Update pod 'foo' by removing a label named 'bar' if it exists + # Does not require the --overwrite flag oc label pods foo bar- ---- @@ -1840,24 +1840,24 @@ Observe changes to resources and react to them (experimental) == oc patch -Update field(s) of a resource +Update fields of a resource .Example usage [source,bash,options="nowrap"] ---- - # Partially update a node using a strategic merge patch. Specify the patch as JSON. + # Partially update a node using a strategic merge patch, specifying the patch as JSON oc patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}' - # Partially update a node using a strategic merge patch. Specify the patch as YAML. + # Partially update a node using a strategic merge patch, specifying the patch as YAML oc patch node k8s-node-1 -p $'spec:\n unschedulable: true' - # Partially update a node identified by the type and name specified in "node.json" using strategic merge patch. + # Partially update a node identified by the type and name specified in "node.json" using strategic merge patch oc patch -f node.json -p '{"spec":{"unschedulable":true}}' - # Update a container's image; spec.containers[*].name is required because it's a merge key. + # Update a container's image; spec.containers[*].name is required because it's a merge key oc patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}' - # Update a container's image using a json patch with positional arrays. + # Update a container's image using a JSON patch with positional arrays oc patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]' ---- @@ -2011,26 +2011,26 @@ Run a proxy to the Kubernetes API server .Example usage [source,bash,options="nowrap"] ---- - # To proxy all of the kubernetes api and nothing else. + # To proxy all of the Kubernetes API and nothing else oc proxy --api-prefix=/ - # To proxy only part of the kubernetes api and also some static files. + # To proxy only part of the Kubernetes API and also some static files # You can get pods info with 'curl localhost:8001/api/v1/pods' oc proxy --www=/my/files --www-prefix=/static/ --api-prefix=/api/ - # To proxy the entire kubernetes api at a different root. + # To proxy the entire Kubernetes API at a different root # You can get pods info with 'curl localhost:8001/custom/api/v1/pods' oc proxy --api-prefix=/custom/ - # Run a proxy to kubernetes apiserver on port 8011, serving static content from ./local/www/ + # Run a proxy to the Kubernetes API server on port 8011, serving static content from ./local/www/ oc proxy --port=8011 --www=./local/www/ - # Run a proxy to kubernetes apiserver on an arbitrary local port. - # The chosen port for the server will be output to stdout. + # Run a proxy to the Kubernetes API server on an arbitrary local port + # The chosen port for the server will be output to stdout oc proxy --port=0 - # Run a proxy to kubernetes apiserver, changing the api prefix to k8s-api - # This makes e.g. the pods api available at localhost:8001/k8s-api/v1/pods/ + # Run a proxy to the Kubernetes API server, changing the API prefix to k8s-api + # This makes e.g. the pods API available at localhost:8001/k8s-api/v1/pods/ oc proxy --api-prefix=/k8s-api ---- @@ -2067,15 +2067,15 @@ Log in to the integrated registry == oc replace -Replace a resource by filename or stdin +Replace a resource by file name or stdin .Example usage [source,bash,options="nowrap"] ---- - # Replace a pod using the data in pod.json. + # Replace a pod using the data in pod.json oc replace -f ./pod.json - # Replace a pod based on the JSON passed into stdin. + # Replace a pod based on the JSON passed into stdin cat pod.json | oc replace -f - # Update a single-container pod's image version (tag) to v4 @@ -2176,7 +2176,7 @@ Restart a resource # Restart a deployment oc rollout restart deployment/nginx - # Restart a daemonset + # Restart a daemon set oc rollout restart daemonset/abc ---- @@ -2280,55 +2280,55 @@ Run a particular image on the cluster .Example usage [source,bash,options="nowrap"] ---- - # Start a nginx pod. + # Start a nginx pod oc run nginx --image=nginx - # Start a hazelcast pod and let the container expose port 5701. + # Start a hazelcast pod and let the container expose port 5701 oc run hazelcast --image=hazelcast/hazelcast --port=5701 - # Start a hazelcast pod and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container. + # Start a hazelcast pod and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container oc run hazelcast --image=hazelcast/hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default" - # Start a hazelcast pod and set labels "app=hazelcast" and "env=prod" in the container. + # Start a hazelcast pod and set labels "app=hazelcast" and "env=prod" in the container oc run hazelcast --image=hazelcast/hazelcast --labels="app=hazelcast,env=prod" - # Dry run. Print the corresponding API objects without creating them. + # Dry run; print the corresponding API objects without creating them oc run nginx --image=nginx --dry-run=client - # Start a nginx pod, but overload the spec with a partial set of values parsed from JSON. + # Start a nginx pod, but overload the spec with a partial set of values parsed from JSON oc run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }' - # Start a busybox pod and keep it in the foreground, don't restart it if it exits. + # Start a busybox pod and keep it in the foreground, don't restart it if it exits oc run -i -t busybox --image=busybox --restart=Never - # Start the nginx pod using the default command, but use custom arguments (arg1 .. argN) for that command. + # Start the nginx pod using the default command, but use custom arguments (arg1 .. argN) for that command oc run nginx --image=nginx -- ... - # Start the nginx pod using a different command and custom arguments. + # Start the nginx pod using a different command and custom arguments oc run nginx --image=nginx --command -- ... ---- == oc scale -Set a new size for a Deployment, ReplicaSet or Replication Controller +Set a new size for a deployment, replica set, or replication controller .Example usage [source,bash,options="nowrap"] ---- - # Scale a replicaset named 'foo' to 3. + # Scale a replica set named 'foo' to 3 oc scale --replicas=3 rs/foo - # Scale a resource identified by type and name specified in "foo.yaml" to 3. + # Scale a resource identified by type and name specified in "foo.yaml" to 3 oc scale --replicas=3 -f foo.yaml - # If the deployment named mysql's current size is 2, scale mysql to 3. + # If the deployment named mysql's current size is 2, scale mysql to 3 oc scale --current-replicas=2 --replicas=3 deployment/mysql - # Scale multiple replication controllers. + # Scale multiple replication controllers oc scale --replicas=5 rc/foo rc/bar rc/baz - # Scale statefulset named 'web' to 3. + # Scale stateful set named 'web' to 3 oc scale --replicas=3 statefulset/web ---- @@ -2524,7 +2524,7 @@ Update environment variables on a pod template == oc set image -Update image of a pod template +Update the image of a pod template .Example usage [source,bash,options="nowrap"] @@ -2590,10 +2590,10 @@ Update a probe on a pod template oc set probe rc/mysql --readiness --open-tcp=3306 # Set an HTTP startup probe for port 8080 and path /healthz over HTTP on the pod IP - oc probe dc/webapp --startup --get-url=http://:8080/healthz + oc set probe dc/webapp --startup --get-url=http://:8080/healthz # Set an HTTP readiness probe for port 8080 and path /healthz over HTTP on the pod IP - oc probe dc/webapp --readiness --get-url=http://:8080/healthz + oc set probe dc/webapp --readiness --get-url=http://:8080/healthz # Set an HTTP readiness probe over HTTPS on 127.0.0.1 for a hostNetwork pod oc set probe dc/router --readiness --get-url=https://127.0.0.1:1936/stats @@ -2666,7 +2666,7 @@ Set the selector on a resource == oc set serviceaccount -Update ServiceAccount of a resource +Update the service account of a resource .Example usage [source,bash,options="nowrap"] @@ -2681,7 +2681,7 @@ Update ServiceAccount of a resource == oc set subject -Update User, Group or ServiceAccount in a RoleBinding/ClusterRoleBinding +Update the user, group, or service account in a role binding or cluster role binding .Example usage [source,bash,options="nowrap"] @@ -2858,18 +2858,18 @@ Print the client and server version information == oc wait -Experimental: Wait for a specific condition on one or many resources. +Experimental: Wait for a specific condition on one or many resources .Example usage [source,bash,options="nowrap"] ---- - # Wait for the pod "busybox1" to contain the status condition of type "Ready". + # Wait for the pod "busybox1" to contain the status condition of type "Ready" oc wait --for=condition=Ready pod/busybox1 - # The default value of status condition is true, you can set false. + # The default value of status condition is true; you can set it to false oc wait --for=condition=Ready=false pod/busybox1 - # Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command. + # Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command oc delete pod/busybox1 oc wait --for=delete pod/busybox1 --timeout=60s ----