MicroShift is Developer Preview software only.
For more information about the support scope of Red Hat Developer Preview software, see Developer Preview Support Scope.第6章 OpenShift CLI コマンドリファレンス
このリファレンスは、OpenShift CLI (oc
) コマンドの説明とコマンド例を示しています。これらのコマンドを使用するには、cluster-admin
または同等のパーミッションが必要です。
oc adm -h
を実行して、すべての管理者コマンドを表示するか、oc <command> --help
を実行して、特定のコマンドに関する追加情報を取得します。
oc <command> --help
を使用すると、oc
コマンドの詳細が一覧表示されます。すべての oc
コマンドが Red Hat build of MicroShift の使用に適用されるわけではありません。
6.1. Red Hat build of MicroShift の oc コマンドリスト
以下に、Red Hat build of MicroShift ノードの管理、デプロイ、監視に使用できる oc
コマンドの例をいくつか示します。
6.1.1. oc apply
設定をファイル名または標準入力 (stdin) 別のリソースに適用します。
使用例
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
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
6.1.2. oc delete
ファイル名、stdin、リソースおよび名前、またはリソースおよびラベルセレクター別にリソースを削除します。
使用例
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
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
6.1.3. oc get
1 つ以上のリソースを表示します。
使用例
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)
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