mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
115 lines
3.7 KiB
Plaintext
115 lines
3.7 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
//* microshift-oc-cli-commands-list/microshift-oc-by-example-content.adoc
|
|
|
|
:_content-type: REFERENCE
|
|
[id="microshift-oc-by-example-content_{context}"]
|
|
= Brief oc commands list for {product-title}
|
|
|
|
The following lists a few examples of `oc` commands you can use to administer, deploy, and observe a {product-title} node.
|
|
|
|
== oc apply
|
|
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
|
|
oc apply -f ./pod.json
|
|
|
|
# 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
|
|
cat pod.json | oc apply -f -
|
|
|
|
# Apply the configuration from all files that end with '.json' - i.e. expand wildcard characters in file names
|
|
oc apply -f '*.json'
|
|
|
|
# Note: --prune is still in Alpha
|
|
# 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 config maps that are not in the file
|
|
oc apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap
|
|
----
|
|
|
|
[id="oc-delete"_{context}]
|
|
== oc delete
|
|
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
|
|
oc delete -f ./pod.json
|
|
|
|
# Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
|
|
oc delete -k dir
|
|
|
|
# Delete resources from all files that end with '.json' - i.e. expand wildcard characters in file names
|
|
oc delete -f '*.json'
|
|
|
|
# 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
|
|
oc delete pods,services -l name=myLabel
|
|
|
|
# Delete a pod with minimal delay
|
|
oc delete pod foo --now
|
|
|
|
# Force delete a pod on a dead node
|
|
oc delete pod foo --force
|
|
|
|
# Delete all pods
|
|
oc delete pods --all
|
|
----
|
|
|
|
[id="oc-get"_{context}]
|
|
== oc get
|
|
Display one or many resources
|
|
|
|
.Example usage
|
|
[source,bash,options="nowrap"]
|
|
----
|
|
# List all pods in ps output format
|
|
oc get pods
|
|
|
|
# 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
|
|
oc get replicationcontroller web
|
|
|
|
# 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
|
|
oc get -o json pod web-pod-13je7
|
|
|
|
# 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.
|
|
oc get -k dir/
|
|
|
|
# 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
|
|
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
|
|
oc get rc,services
|
|
|
|
# List one or more resources by their type and names
|
|
oc get rc/web service/frontend pods/web-pod-13je7
|
|
|
|
# List status subresource for a single pod.
|
|
oc get pod web-pod-13je7 --subresource status
|
|
----
|