2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenShift - oc command Tips - get all

Last updated at Posted at 2024-10-30

OpenShift の様々な操作で使用する oc コマンドの get all に関する留意点をご紹介します。
ここでは、以下の oc コマンドを使用します。

$ oc version --client
Client Version: 4.16.14
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3

get all

Cluster 内で使用可能なリソースの一覧は oc api-resources で取得可能です。そのうち、oc get all で取得できるものは、以下のリソースに限定されます。

pods
replicationcontrollers
services
daemonsets
deployments
replicasets
statefulsets
horizontalpodautoscalers
cronjobs
jobs
deploymentconfigs
buildconfigs
builds
imagestreams
routes

例として、kube-public Project を確認してみます。
oc get all を実行すると No resources found in kube-public namespace. と表示され、リソースが全く存在しないように見えます。

$ oc project -q
kube-public

$ oc get all
No resources found in kube-public namespace.

ここで、oc api-resources--namespaced オプションを追加して、kube-public Project に他のリソースが存在するか確認してみると、以下が存在することが分かります。

$ for R in $(oc api-resources -o name --namespaced)
> do
> oc -o name get $R -n $(oc project -q) 2>/dev/null
> done
configmap/kube-root-ca.crt
configmap/openshift-service-ca.crt
secret/builder-dockercfg-snktc
secret/default-dockercfg-xvj75
secret/deployer-dockercfg-82nxx
serviceaccount/builder
serviceaccount/default
serviceaccount/deployer
rolebinding.authorization.openshift.io/system:controller:bootstrap-signer
rolebinding.authorization.openshift.io/system:deployers
rolebinding.authorization.openshift.io/system:image-builders
rolebinding.authorization.openshift.io/system:image-pullers
role.authorization.openshift.io/system:controller:bootstrap-signer
packagemanifest.packages.operators.coreos.com/ocs-client-operator
packagemanifest.packages.operators.coreos.com/mcg-operator
packagemanifest.packages.operators.coreos.com/odf-prometheus-operator
packagemanifest.packages.operators.coreos.com/recipe
packagemanifest.packages.operators.coreos.com/odf-multicluster-orchestrator
packagemanifest.packages.operators.coreos.com/odf-operator
packagemanifest.packages.operators.coreos.com/local-storage-operator
packagemanifest.packages.operators.coreos.com/odr-hub-operator
packagemanifest.packages.operators.coreos.com/odr-cluster-operator
packagemanifest.packages.operators.coreos.com/odf-csi-addons-operator
packagemanifest.packages.operators.coreos.com/redhat-oadp-operator
packagemanifest.packages.operators.coreos.com/ocs-operator
packagemanifest.packages.operators.coreos.com/rook-ceph-operator
rolebinding.rbac.authorization.k8s.io/system:controller:bootstrap-signer
rolebinding.rbac.authorization.k8s.io/system:deployers
rolebinding.rbac.authorization.k8s.io/system:image-builders
rolebinding.rbac.authorization.k8s.io/system:image-pullers
role.rbac.authorization.k8s.io/system:controller:bootstrap-signer
$ oc get -o wide rolebinding.rbac.authorization.k8s.io/system:image-pullers
NAME                   ROLE                              AGE   USERS   GROUPS                               SERVICEACCOUNTS
system:image-pullers   ClusterRole/system:image-puller   11d           system:serviceaccounts:kube-public

同様に、oc api-resources--namespaced=false オプションで取得できる Project (Namespace) に依存しないリソースを確認することも可能です。

$ for R in $(oc api-resources -o name --namespaced=false)
> do
> oc -o name get $R 2>/dev/null
> done
componentstatus/controller-manager
componentstatus/scheduler
componentstatus/etcd-0
namespace/default
namespace/kube-node-lease
namespace/kube-public
namespace/kube-system
namespace/openshift
namespace/openshift-apiserver
~省略~
$ oc get componentstatus/controller-manager
NAME                 STATUS    MESSAGE   ERROR
controller-manager   Healthy   ok
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?