OpenShift - List deployments using the oc get deployments command

An image contains the code used to create a deployment. Then, a deployment can be created from an image, which should then create a replica set (which is the number of pods that should be created), and then the pods should be created.

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

When deploying an application using the oc new-app command, if the --as-deployment-config flag is not used, the application will be created as a deployment, not a deployment config. In this scenario, the oc get deployments command would be used to list the deployments. On the other hand, if the --as-deployment-config flag is used, the application will be created as a deployment config. In this scenario, the oc get deploymentconfigs command would be used.

The oc get deployments command can be used to list the deployments in the currently selected project / namespace.

TIP

The -A or --all-namespaces flag can be used to list the deployments in every project / namespace.

The -n or --namespace flag can be used to list the deployments in a certain project / namespace.

oc get deployments

 

Something like this should be returned.

NAME      READY   UP-TO-DATE   AVAILABLE   AGE
my-app    1/1     1            1           8d

 

If you have numerous deployments, the -l option can be used to only return the deployments that match the app name.

oc get deployments -l app=my-app

 

If READY is 0/0 or AVAILABLE is 0, you may need to restart the deployment.

NAME      READY   UP-TO-DATE   AVAILABLE   AGE
my-app    0/0     0            0           8d

 

The --output wide option can be used to display more information about the deployment. The oc config view or oc get apiserver commands can be used to display the API Server URL (api.openshift.example.com in this example).

~]$ oc get deployments --output wide
NAME     READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS      IMAGES                            SELECTOR
my-app   1/1     1            1           8d    my-container    api.openshift.example.com/myapp   app=app001

 

The --output yaml or --output json options can be used to display even more information about the deployment.

oc get deployment my-app --output yaml

 

Something like this should be returned.

apiVersion: v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: "2021-03-23T22:06:06Z"
  generation: 1
  name: my-app
  namespace: default
  resourceVersion: "450841867"
  uid: fff40384-0b81-4016-8ff7-6a755c3d1792
spec:
  replicas: 1
  spec:
    - image: api.openshift.example.com/myapp
      imagePullPolicy: IfNotPresent
      name: my-app
      ports:
      - containerPort: 8080
        protocol: TCP
      - containerPort: 8443
        protocol: TCP
      resources: {}
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
    dnsPolicy: ClusterFirst
    restartPolicy: Always
    schedulerName: default-scheduler
    securityContext: {}
    terminationGracePeriodSeconds: 30

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 8399b in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |